fix(core): Update types for TypeScript nullability support (#15472)

This commit is contained in:
Miško Hevery
2017-03-29 09:34:45 -07:00
committed by Victor Berchet
parent 331b9f6425
commit 910c0d9ee7
84 changed files with 1287 additions and 1260 deletions

View File

@ -30,7 +30,7 @@ function getSourcePositionForStack(stack: string): {source: string, line: number
const htmlLocations = stack
.split('\n')
// e.g. at View_MyComp_0 (...html:153:40)
.map(line => /\((.*\.html):(\d+):(\d+)/.exec(line))
.map(line => /\((.*\.html):(\d+):(\d+)/.exec(line) !)
.filter(match => !!match)
.map(match => ({
source: match[1],

View File

@ -67,9 +67,9 @@ function codeGenTest() {
angularCompilerOptions: config.ngOptions,
// i18n options.
i18nFormat: null,
i18nFile: null,
locale: null,
i18nFormat: undefined,
i18nFile: undefined,
locale: undefined,
readResource: (fileName: string) => {
readResources.push(fileName);
@ -131,8 +131,8 @@ function i18nTest() {
compilerOptions: config.parsed.options, program, host,
angularCompilerOptions: config.ngOptions,
i18nFormat: 'xlf',
locale: null,
outFile: null,
locale: undefined,
outFile: undefined,
readResource: (fileName: string) => {
readResources.push(fileName);
return hostContext.readResource(fileName);

View File

@ -34,7 +34,8 @@ function main() {
if (/.*\/node_modules\/.*/.test(fileName) && !/.*ngsummary\.json$/.test(fileName) &&
!/package\.json$/.test(fileName)) {
// Only allow to read summaries and package.json files from node_modules
return null;
// TODO (mhevery): Fix this. TypeScript.d.ts does not allow returning null.
return null !;
}
readFiles.push(path.relative(basePath, fileName));
return super.readFile(fileName);

View File

@ -13,7 +13,7 @@ import {platformServer} from '@angular/platform-server';
import {MainModule} from '../src/module';
import {MainModuleNgFactory} from '../src/module.ngfactory';
let mainModuleRef: NgModuleRef<MainModule> = null;
let mainModuleRef: NgModuleRef<MainModule> = null !;
beforeEach((done) => {
platformServer().bootstrapModuleFactory(MainModuleNgFactory).then((moduleRef: any) => {
mainModuleRef = moduleRef;
@ -29,5 +29,5 @@ export function createComponent<C>(comp: {new (...args: any[]): C}): ComponentFi
const moduleRef = createModule();
const compRef =
moduleRef.componentFactoryResolver.resolveComponentFactory(comp).create(moduleRef.injector);
return new ComponentFixture(compRef, null, null);
return new ComponentFixture(compRef, null, false);
}

View File

@ -10,6 +10,8 @@
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": true,
"strictNullChecks": true,
"skipLibCheck": true,
"moduleResolution": "node",
"rootDir": "",
"declaration": true,
@ -32,4 +34,4 @@
"benchmarks/src/largetable/ng2/index_aot.ts",
"benchmarks/src/largetable/ng2_switch/index_aot.ts"
]
}
}