1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
=== tests/cases/conformance/controlFlow/controlFlowElementAccess2.ts ===
declare const config: {
>config : { [key: string]: boolean | { prop: string; }; }
[key: string]: boolean | { prop: string };
>key : string
>prop : string
};
if (typeof config['works'] !== 'boolean') {
>typeof config['works'] !== 'boolean' : boolean
>typeof config['works'] : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>config['works'] : boolean | { prop: string; }
>config : { [key: string]: boolean | { prop: string; }; }
>'works' : "works"
>'boolean' : "boolean"
config.works.prop = 'test'; // ok
>config.works.prop = 'test' : "test"
>config.works.prop : string
>config.works : { prop: string; }
>config : { [key: string]: boolean | { prop: string; }; }
>works : { prop: string; }
>prop : string
>'test' : "test"
config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string }
>config['works'].prop = 'test' : "test"
>config['works'].prop : string
>config['works'] : { prop: string; }
>config : { [key: string]: boolean | { prop: string; }; }
>'works' : "works"
>prop : string
>'test' : "test"
}
if (typeof config.works !== 'boolean') {
>typeof config.works !== 'boolean' : boolean
>typeof config.works : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>config.works : boolean | { prop: string; }
>config : { [key: string]: boolean | { prop: string; }; }
>works : boolean | { prop: string; }
>'boolean' : "boolean"
config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string }
>config['works'].prop = 'test' : "test"
>config['works'].prop : string
>config['works'] : { prop: string; }
>config : { [key: string]: boolean | { prop: string; }; }
>'works' : "works"
>prop : string
>'test' : "test"
config.works.prop = 'test'; // ok
>config.works.prop = 'test' : "test"
>config.works.prop : string
>config.works : { prop: string; }
>config : { [key: string]: boolean | { prop: string; }; }
>works : { prop: string; }
>prop : string
>'test' : "test"
}
|