Skip to content

Commit 59d1f1f

Browse files
committed
Merge pull request microsoft#8284 from Microsoft/Fix8271
Fix microsoft#8271: Add `undefined` type to index signatures
2 parents dc60e68 + 743fa3c commit 59d1f1f

File tree

10 files changed

+31
-14
lines changed

10 files changed

+31
-14
lines changed

src/compiler/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,14 +2513,14 @@ namespace ts {
25132513
types?: string[];
25142514

25152515
list?: string[];
2516-
[option: string]: CompilerOptionsValue;
2516+
[option: string]: CompilerOptionsValue | undefined;
25172517
}
25182518

25192519
export interface TypingOptions {
25202520
enableAutoDiscovery?: boolean;
25212521
include?: string[];
25222522
exclude?: string[];
2523-
[option: string]: string[] | boolean;
2523+
[option: string]: string[] | boolean | undefined;
25242524
}
25252525

25262526
export interface DiscoverTypingsInfo {

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ namespace ts {
10271027
getScriptFileNames(): string[];
10281028
getScriptKind?(fileName: string): ScriptKind;
10291029
getScriptVersion(fileName: string): string;
1030-
getScriptSnapshot(fileName: string): IScriptSnapshot;
1030+
getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
10311031
getLocalizedDiagnosticMessages?(): any;
10321032
getCancellationToken?(): HostCancellationToken;
10331033
getCurrentDirectory(): string;

tests/baselines/reference/APISample_linter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function delint(sourceFile: ts.SourceFile) {
5555
}
5656
}
5757

58-
const fileNames = process.argv.slice(2);
58+
const fileNames: string[] = process.argv.slice(2);
5959
fileNames.forEach(fileName => {
6060
// Parse a file
6161
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);

tests/baselines/reference/APISample_parseConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function printError(error: ts.Diagnostic): void {
1919
console.log(`${error.file && error.file.fileName}: ${error.messageText}`);
2020
}
2121

22-
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program {
22+
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program | undefined {
2323
const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson)
2424
if (error) {
2525
printError(error);

tests/baselines/reference/APISample_watcher.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88

99
declare var process: any;
1010
declare var console: any;
11-
declare var fs: any;
11+
declare var fs: {
12+
existsSync(path: string): boolean;
13+
readdirSync(path: string): string[];
14+
readFileSync(filename: string, encoding?: string): string;
15+
writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
16+
watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void;
17+
};
1218
declare var path: any;
1319

1420
import * as ts from "typescript";

tests/cases/compiler/APISample_compile.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @module: commonjs
22
// @includebuiltfile: typescript_standalone.d.ts
3-
// @stripInternal:true
3+
// @noImplicitAny:true
4+
// @strictNullChecks:true
45

56
/*
67
* Note: This test is a public API sample. The sample sources can be found

tests/cases/compiler/APISample_linter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @module: commonjs
22
// @includebuiltfile: typescript_standalone.d.ts
3-
// @stripInternal:true
3+
// @noImplicitAny:true
4+
// @strictNullChecks:true
45

56
/*
67
* Note: This test is a public API sample. The sample sources can be found
@@ -57,7 +58,7 @@ export function delint(sourceFile: ts.SourceFile) {
5758
}
5859
}
5960

60-
const fileNames = process.argv.slice(2);
61+
const fileNames: string[] = process.argv.slice(2);
6162
fileNames.forEach(fileName => {
6263
// Parse a file
6364
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);

tests/cases/compiler/APISample_parseConfig.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @module: commonjs
22
// @includebuiltfile: typescript_standalone.d.ts
3-
// @stripInternal:true
3+
// @noImplicitAny:true
4+
// @strictNullChecks:true
45

56
/*
67
* Note: This test is a public API sample. The sample sources can be found
@@ -21,7 +22,7 @@ function printError(error: ts.Diagnostic): void {
2122
console.log(`${error.file && error.file.fileName}: ${error.messageText}`);
2223
}
2324

24-
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program {
25+
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program | undefined {
2526
const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson)
2627
if (error) {
2728
printError(error);

tests/cases/compiler/APISample_transform.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @module: commonjs
22
// @includebuiltfile: typescript_standalone.d.ts
3-
// @stripInternal:true
3+
// @noImplicitAny:true
4+
// @strictNullChecks:true
45

56
/*
67
* Note: This test is a public API sample. The sample sources can be found

tests/cases/compiler/APISample_watcher.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @module: commonjs
22
// @includebuiltfile: typescript_standalone.d.ts
3-
// @stripInternal:true
3+
// @noImplicitAny:true
4+
// @strictNullChecks:true
45

56
/*
67
* Note: This test is a public API sample. The sample sources can be found
@@ -10,7 +11,13 @@
1011

1112
declare var process: any;
1213
declare var console: any;
13-
declare var fs: any;
14+
declare var fs: {
15+
existsSync(path: string): boolean;
16+
readdirSync(path: string): string[];
17+
readFileSync(filename: string, encoding?: string): string;
18+
writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
19+
watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void;
20+
};
1421
declare var path: any;
1522

1623
import * as ts from "typescript";

0 commit comments

Comments
 (0)