Merge pull request #8284 from Microsoft/Fix8271

Fix #8271: Add `undefined` type to index signatures
This commit is contained in:
Mohamed Hegazy
2016-04-25 14:17:51 -07:00
10 changed files with 31 additions and 14 deletions

View File

@@ -2513,14 +2513,14 @@ namespace ts {
types?: string[];
list?: string[];
[option: string]: CompilerOptionsValue;
[option: string]: CompilerOptionsValue | undefined;
}
export interface TypingOptions {
enableAutoDiscovery?: boolean;
include?: string[];
exclude?: string[];
[option: string]: string[] | boolean;
[option: string]: string[] | boolean | undefined;
}
export interface DiscoverTypingsInfo {

View File

@@ -1027,7 +1027,7 @@ namespace ts {
getScriptFileNames(): string[];
getScriptKind?(fileName: string): ScriptKind;
getScriptVersion(fileName: string): string;
getScriptSnapshot(fileName: string): IScriptSnapshot;
getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
getLocalizedDiagnosticMessages?(): any;
getCancellationToken?(): HostCancellationToken;
getCurrentDirectory(): string;

View File

@@ -55,7 +55,7 @@ export function delint(sourceFile: ts.SourceFile) {
}
}
const fileNames = process.argv.slice(2);
const fileNames: string[] = process.argv.slice(2);
fileNames.forEach(fileName => {
// Parse a file
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);

View File

@@ -19,7 +19,7 @@ function printError(error: ts.Diagnostic): void {
console.log(`${error.file && error.file.fileName}: ${error.messageText}`);
}
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program {
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program | undefined {
const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson)
if (error) {
printError(error);

View File

@@ -8,7 +8,13 @@
declare var process: any;
declare var console: any;
declare var fs: any;
declare var fs: {
existsSync(path: string): boolean;
readdirSync(path: string): string[];
readFileSync(filename: string, encoding?: string): string;
writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void;
};
declare var path: any;
import * as ts from "typescript";

View File

@@ -1,6 +1,7 @@
// @module: commonjs
// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
// @noImplicitAny:true
// @strictNullChecks:true
/*
* Note: This test is a public API sample. The sample sources can be found

View File

@@ -1,6 +1,7 @@
// @module: commonjs
// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
// @noImplicitAny:true
// @strictNullChecks:true
/*
* Note: This test is a public API sample. The sample sources can be found
@@ -57,7 +58,7 @@ export function delint(sourceFile: ts.SourceFile) {
}
}
const fileNames = process.argv.slice(2);
const fileNames: string[] = process.argv.slice(2);
fileNames.forEach(fileName => {
// Parse a file
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);

View File

@@ -1,6 +1,7 @@
// @module: commonjs
// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
// @noImplicitAny:true
// @strictNullChecks:true
/*
* Note: This test is a public API sample. The sample sources can be found
@@ -21,7 +22,7 @@ function printError(error: ts.Diagnostic): void {
console.log(`${error.file && error.file.fileName}: ${error.messageText}`);
}
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program {
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program | undefined {
const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson)
if (error) {
printError(error);

View File

@@ -1,6 +1,7 @@
// @module: commonjs
// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
// @noImplicitAny:true
// @strictNullChecks:true
/*
* Note: This test is a public API sample. The sample sources can be found

View File

@@ -1,6 +1,7 @@
// @module: commonjs
// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
// @noImplicitAny:true
// @strictNullChecks:true
/*
* Note: This test is a public API sample. The sample sources can be found
@@ -10,7 +11,13 @@
declare var process: any;
declare var console: any;
declare var fs: any;
declare var fs: {
existsSync(path: string): boolean;
readdirSync(path: string): string[];
readFileSync(filename: string, encoding?: string): string;
writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void;
};
declare var path: any;
import * as ts from "typescript";