chore(typing): enforce --noImplicitAny for tools directory.
Exposed a couple of bugs. Closes #6645
This commit is contained in:
@ -33,7 +33,7 @@ export class MetadataCollector {
|
||||
break;
|
||||
}
|
||||
if (importDecl.importClause.name) {
|
||||
newImport['defaultName'] = importDecl.importClause.name.text;
|
||||
(<any>newImport)['defaultName'] = importDecl.importClause.name.text;
|
||||
}
|
||||
const bindings = importDecl.importClause.namedBindings;
|
||||
if (bindings) {
|
||||
@ -44,14 +44,14 @@ export class MetadataCollector {
|
||||
.elements.forEach(i => {
|
||||
const namedImport = {name: i.name.text};
|
||||
if (i.propertyName) {
|
||||
namedImport['propertyName'] = i.propertyName.text;
|
||||
(<any>namedImport)['propertyName'] = i.propertyName.text;
|
||||
}
|
||||
namedImports.push(namedImport);
|
||||
});
|
||||
newImport['namedImports'] = namedImports;
|
||||
(<any>newImport)['namedImports'] = namedImports;
|
||||
break;
|
||||
case ts.SyntaxKind.NamespaceImport:
|
||||
newImport['namespace'] = (<ts.NamespaceImport>bindings).name.text;
|
||||
(<any>newImport)['namespace'] = (<ts.NamespaceImport>bindings).name.text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -257,14 +257,14 @@ export class Evaluator {
|
||||
const assignment = <ts.PropertyAssignment>child;
|
||||
const propertyName = this.nameOf(assignment.name);
|
||||
const propertyValue = this.evaluateNode(assignment.initializer);
|
||||
obj[propertyName] = propertyValue;
|
||||
(<any>obj)[propertyName] = propertyValue;
|
||||
allPropertiesDefined = isDefined(propertyValue) && allPropertiesDefined;
|
||||
}
|
||||
});
|
||||
if (allPropertiesDefined) return obj;
|
||||
break;
|
||||
case ts.SyntaxKind.ArrayLiteralExpression:
|
||||
let arr = [];
|
||||
let arr: MetadataValue[] = [];
|
||||
let allElementsDefined = true;
|
||||
ts.forEachChild(node, child => {
|
||||
const value = this.evaluateNode(child);
|
||||
@ -320,7 +320,7 @@ export class Evaluator {
|
||||
const propertyAccessExpression = <ts.PropertyAccessExpression>node;
|
||||
const expression = this.evaluateNode(propertyAccessExpression.expression);
|
||||
const member = this.nameOf(propertyAccessExpression.name);
|
||||
if (this.isFoldable(propertyAccessExpression.expression)) return expression[member];
|
||||
if (this.isFoldable(propertyAccessExpression.expression)) return (<any>expression)[member];
|
||||
if (this.findImportNamespace(propertyAccessExpression)) {
|
||||
return this.nodeSymbolReference(propertyAccessExpression);
|
||||
}
|
||||
@ -335,7 +335,7 @@ export class Evaluator {
|
||||
const index = this.evaluateNode(elementAccessExpression.argumentExpression);
|
||||
if (this.isFoldable(elementAccessExpression.expression) &&
|
||||
this.isFoldable(elementAccessExpression.argumentExpression))
|
||||
return expression[<string | number>index];
|
||||
return (<any>expression)[<string | number>index];
|
||||
if (isDefined(expression) && isDefined(index)) {
|
||||
return {__symbolic: "index", expression, index};
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export class Symbols {
|
||||
|
||||
public has(symbol: ts.Symbol): boolean { return this.map.has(symbol.getDeclarations()[0]); }
|
||||
|
||||
public set(symbol: ts.Symbol, value): void { this.map.set(symbol.getDeclarations()[0], value); }
|
||||
public set(symbol: ts.Symbol, value: any): void { this.map.set(symbol.getDeclarations()[0], value); }
|
||||
|
||||
public get(symbol: ts.Symbol): any { return this.map.get(symbol.getDeclarations()[0]); }
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as ts from 'typescript';
|
||||
import {MetadataCollector} from '../src/collector';
|
||||
import {ClassMetadata} from '../src/schema';
|
||||
import {ClassMetadata, ModuleMetadata} from '../src/schema';
|
||||
|
||||
import {Directory, expectValidSources, Host} from './typescript.mocks';
|
||||
|
||||
@ -185,8 +185,8 @@ describe('Collector', () => {
|
||||
expect(metadata).toBeFalsy();
|
||||
});
|
||||
|
||||
let casesFile;
|
||||
let casesMetadata;
|
||||
let casesFile: ts.SourceFile;
|
||||
let casesMetadata: ModuleMetadata;
|
||||
|
||||
beforeEach(() => {
|
||||
casesFile = program.getSourceFile('/app/cases-data.ts');
|
||||
|
@ -37,7 +37,7 @@ export class Host implements ts.LanguageServiceHost {
|
||||
if (names.length && names[0] === '') names.shift();
|
||||
for (const name of names) {
|
||||
if (!current || typeof current === 'string') return undefined;
|
||||
current = current[name];
|
||||
current = (<any>current)[name];
|
||||
}
|
||||
if (typeof current === 'string') return current;
|
||||
}
|
||||
@ -120,7 +120,7 @@ export function expectValidSources(service: ts.LanguageService, program: ts.Prog
|
||||
}
|
||||
}
|
||||
|
||||
export function allChildren<T>(node: ts.Node, cb: (node: ts.Node) => T) {
|
||||
export function allChildren<T>(node: ts.Node, cb: (node: ts.Node) => T): T {
|
||||
return ts.forEachChild(node, child => {
|
||||
const result = cb(node);
|
||||
if (result) {
|
||||
|
Reference in New Issue
Block a user