fix(compiler): Update types for TypeScript nullability support

This commit is contained in:
Miško Hevery
2017-03-24 09:59:58 -07:00
committed by Hans
parent d8b73e4223
commit 09d9f5fe54
118 changed files with 2086 additions and 1859 deletions

View File

@ -33,7 +33,7 @@ export class CompilerHost implements AotCompilerHost {
private resolverCache = new Map<string, ModuleMetadata[]>();
private bundleIndexCache = new Map<string, boolean>();
private bundleIndexNames = new Set<string>();
private moduleFileNames = new Map<string, string>();
private moduleFileNames = new Map<string, string|null>();
protected resolveModuleNameHost: CompilerHostContext;
constructor(
@ -71,7 +71,7 @@ export class CompilerHost implements AotCompilerHost {
moduleNameToFileName(m: string, containingFile: string): string|null {
const key = m + ':' + (containingFile || '');
let result = this.moduleFileNames.get(key);
let result: string|null = this.moduleFileNames.get(key) || null;
if (!result) {
if (!containingFile || !containingFile.length) {
if (m.indexOf('.') === 0) {
@ -183,7 +183,7 @@ export class CompilerHost implements AotCompilerHost {
return sf;
}
getMetadataFor(filePath: string): ModuleMetadata[] {
getMetadataFor(filePath: string): ModuleMetadata[]|undefined {
if (!this.context.fileExists(filePath)) {
// If the file doesn't exists then we cannot return metadata for the file.
// This will occur if the user refernced a declared module for which no file
@ -263,6 +263,7 @@ export class CompilerHost implements AotCompilerHost {
if (this.context.fileExists(filePath)) {
return this.context.readFile(filePath);
}
return null;
}
getOutputFileName(sourceFilePath: string): string {
@ -287,7 +288,7 @@ export class CompilerHost implements AotCompilerHost {
calculateEmitPath(filePath: string): string {
// Write codegen in a directory structure matching the sources.
let root = this.options.basePath;
let root = this.options.basePath !;
for (const eachRootDir of this.options.rootDirs || []) {
if (this.options.trace) {
console.error(`Check if ${filePath} is under rootDirs element ${eachRootDir}`);
@ -373,7 +374,7 @@ export class ModuleResolutionHostAdapter extends CompilerHostContextAdapter impl
constructor(private host: ts.ModuleResolutionHost) {
super();
if (host.directoryExists) {
this.directoryExists = (directoryName: string) => host.directoryExists(directoryName);
this.directoryExists = (directoryName: string) => host.directoryExists !(directoryName);
}
}