mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-26 00:36:29 -05:00
Test:narrow properties from string index signatures
This commit is contained in:
13
tests/baselines/reference/controlFlowStringIndex.js
Normal file
13
tests/baselines/reference/controlFlowStringIndex.js
Normal file
@@ -0,0 +1,13 @@
|
||||
//// [controlFlowStringIndex.ts]
|
||||
type A = { [index: string]: number | null };
|
||||
declare const value: A;
|
||||
if (value.foo !== null) {
|
||||
value.foo.toExponential()
|
||||
}
|
||||
|
||||
|
||||
//// [controlFlowStringIndex.js]
|
||||
"use strict";
|
||||
if (value.foo !== null) {
|
||||
value.foo.toExponential();
|
||||
}
|
||||
18
tests/baselines/reference/controlFlowStringIndex.symbols
Normal file
18
tests/baselines/reference/controlFlowStringIndex.symbols
Normal file
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/conformance/controlFlow/controlFlowStringIndex.ts ===
|
||||
type A = { [index: string]: number | null };
|
||||
>A : Symbol(A, Decl(controlFlowStringIndex.ts, 0, 0))
|
||||
>index : Symbol(index, Decl(controlFlowStringIndex.ts, 0, 12))
|
||||
|
||||
declare const value: A;
|
||||
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 1, 13))
|
||||
>A : Symbol(A, Decl(controlFlowStringIndex.ts, 0, 0))
|
||||
|
||||
if (value.foo !== null) {
|
||||
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 1, 13))
|
||||
|
||||
value.foo.toExponential()
|
||||
>value.foo.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 1, 13))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
|
||||
26
tests/baselines/reference/controlFlowStringIndex.types
Normal file
26
tests/baselines/reference/controlFlowStringIndex.types
Normal file
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/conformance/controlFlow/controlFlowStringIndex.ts ===
|
||||
type A = { [index: string]: number | null };
|
||||
>A : A
|
||||
>index : string
|
||||
>null : null
|
||||
|
||||
declare const value: A;
|
||||
>value : A
|
||||
>A : A
|
||||
|
||||
if (value.foo !== null) {
|
||||
>value.foo !== null : boolean
|
||||
>value.foo : number | null
|
||||
>value : A
|
||||
>foo : number | null
|
||||
>null : null
|
||||
|
||||
value.foo.toExponential()
|
||||
>value.foo.toExponential() : string
|
||||
>value.foo.toExponential : (fractionDigits?: number | undefined) => string
|
||||
>value.foo : number
|
||||
>value : A
|
||||
>foo : number
|
||||
>toExponential : (fractionDigits?: number | undefined) => string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// @strict: true
|
||||
type A = { [index: string]: number | null };
|
||||
declare const value: A;
|
||||
if (value.foo !== null) {
|
||||
value.foo.toExponential()
|
||||
}
|
||||
Reference in New Issue
Block a user