refactor(ShadowCss): add missing types

This commit is contained in:
Victor Berchet 2016-09-30 13:06:14 -07:00 committed by Chuck Jazdzewski
parent a6bb84e02b
commit a121136fae
2 changed files with 7 additions and 7 deletions

View File

@ -509,7 +509,7 @@ export class CssRule {
constructor(public selector: string, public content: string) {}
}
export function processRules(input: string, ruleCallback: Function): string {
export function processRules(input: string, ruleCallback: (rule: CssRule) => CssRule): string {
const inputWithEscapedBlocks = escapeBlocks(input);
let nextBlockIndex = 0;
return inputWithEscapedBlocks.escapedString.replace(_ruleRe, function(...m: string[]) {

View File

@ -207,8 +207,8 @@ export function main() {
describe('processRules', () => {
describe('parse rules', () => {
function captureRules(input: string): CssRule[] {
const result: any[] /** TODO #9100 */ = [];
processRules(input, (cssRule: any /** TODO #9100 */) => {
const result: CssRule[] = [];
processRules(input, (cssRule) => {
result.push(cssRule);
return cssRule;
});
@ -239,15 +239,15 @@ export function main() {
describe('modify rules', () => {
it('should allow to change the selector while preserving whitespaces', () => {
expect(processRules(
'@import a; b {c {d}} e {f}', (cssRule: any /** TODO #9100 */) => new CssRule(
cssRule.selector + '2', cssRule.content)))
'@import a; b {c {d}} e {f}',
(cssRule: CssRule) => new CssRule(cssRule.selector + '2', cssRule.content)))
.toEqual('@import a2; b2 {c {d}} e2 {f}');
});
it('should allow to change the content', () => {
expect(processRules(
'a {b}', (cssRule: any /** TODO #9100 */) =>
new CssRule(cssRule.selector, cssRule.content + '2')))
'a {b}',
(cssRule: CssRule) => new CssRule(cssRule.selector, cssRule.content + '2')))
.toEqual('a {b2}');
});
});