build(compiler-cli): enable full TypeScript strictness (#29436)

This commit enables strict: true in TypeScript builds of
//packages/compiler-cli.

PR Close #29436
This commit is contained in:
Alex Rickabaugh 2019-03-20 17:47:55 -07:00 committed by Matias Niemelä
parent 6cd3743b44
commit dc10355d61
6 changed files with 18 additions and 9 deletions

View File

@ -267,7 +267,7 @@ export class NgtscProgram implements api.Program {
const writeFile: ts.WriteFileCallback =
(fileName: string, data: string, writeByteOrderMark: boolean,
onError: ((message: string) => void) | undefined,
sourceFiles: ReadonlyArray<ts.SourceFile>) => {
sourceFiles: ReadonlyArray<ts.SourceFile>| undefined) => {
if (this.closureCompilerEnabled && fileName.endsWith('.js')) {
data = nocollapseHack(data);
}

View File

@ -81,7 +81,7 @@ export class GeneratedShimsHostWrapper implements ts.CompilerHost {
writeFile(
fileName: string, data: string, writeByteOrderMark: boolean,
onError: ((message: string) => void)|undefined,
sourceFiles: ReadonlyArray<ts.SourceFile>): void {
sourceFiles: ReadonlyArray<ts.SourceFile>|undefined): void {
return this.delegate.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
}

View File

@ -75,7 +75,7 @@ export class TypeCheckProgramHost implements ts.CompilerHost {
writeFile(
fileName: string, data: string, writeByteOrderMark: boolean,
onError: ((message: string) => void)|undefined,
sourceFiles: ReadonlyArray<ts.SourceFile>): void {
sourceFiles: ReadonlyArray<ts.SourceFile>|undefined): void {
return this.delegate.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
}

View File

@ -54,7 +54,10 @@ export class InlineResourcesMetadataTransformer implements MetadataTransformer {
isMetadataImportedSymbolReferenceExpression(d.expression) &&
d.expression.module === '@angular/core' && d.expression.name === 'Component' &&
d.arguments) {
d.arguments = d.arguments.map(this.updateDecoratorMetadata.bind(this, loader));
// Arguments to an @Component that was compiled successfully are always
// MetadataObject(s).
d.arguments = (d.arguments as MetadataObject[])
.map(this.updateDecoratorMetadata.bind(this, loader));
}
});
}
@ -95,8 +98,8 @@ export function getInlineResourcesTransformFactory(
// Decorator case - before or without decorator downleveling
// @Component()
const newDecorators = ts.visitNodes(node.decorators, (node: ts.Decorator) => {
if (isComponentDecorator(node, program.getTypeChecker())) {
const newDecorators = ts.visitNodes(node.decorators, (node: ts.Node) => {
if (ts.isDecorator(node) && isComponentDecorator(node, program.getTypeChecker())) {
return updateDecorator(node, loader);
}
return node;
@ -104,9 +107,13 @@ export function getInlineResourcesTransformFactory(
// Annotation case - after decorator downleveling
// static decorators: {type: Function, args?: any[]}[]
const newMembers = ts.visitNodes(
node.members,
(node: ts.ClassElement) => updateAnnotations(node, loader, program.getTypeChecker()));
const newMembers = ts.visitNodes(node.members, (node: ts.Node) => {
if (ts.isClassElement(node)) {
return updateAnnotations(node, loader, program.getTypeChecker());
} else {
return node;
}
});
// Create a new AST subtree with our modifications
return ts.updateClassDeclaration(

View File

@ -13,6 +13,7 @@
"paths": {
"@angular/compiler": ["../../dist/packages/compiler"]
},
"strict": true,
"types": [
"node"
],

View File

@ -5,6 +5,7 @@
"lib": [
"es2015"
],
"strict": true,
"types": [
"jasmine"
]