mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Merge pull request #10009 from Microsoft/null-undefined-allowed-as-index-expressions
`Null` and `undefined` are allowed as index expressions
This commit is contained in:
13
tests/cases/compiler/indexWithUndefinedAndNull.ts
Normal file
13
tests/cases/compiler/indexWithUndefinedAndNull.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// @strictNullChecks: false
|
||||
interface N {
|
||||
[n: number]: string;
|
||||
}
|
||||
interface S {
|
||||
[s: string]: number;
|
||||
}
|
||||
let n: N;
|
||||
let s: S;
|
||||
let str: string = n[undefined];
|
||||
str = n[null];
|
||||
let num: number = s[undefined];
|
||||
num = s[null];
|
||||
@@ -0,0 +1,13 @@
|
||||
// @strictNullChecks: true
|
||||
interface N {
|
||||
[n: number]: string;
|
||||
}
|
||||
interface S {
|
||||
[s: string]: number;
|
||||
}
|
||||
let n: N;
|
||||
let s: S;
|
||||
let str: string = n[undefined];
|
||||
str = n[null];
|
||||
let num: number = s[undefined];
|
||||
num = s[null];
|
||||
Reference in New Issue
Block a user