| 1 |
//// [tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts] //// |
| 2 |
|
| 3 |
=== typeSatisfaction_propertyValueConformance1.ts === |
| 4 |
type Facts = { [key: string]: boolean }; |
| 5 |
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 0)) |
| 6 |
>key : Symbol(key, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 16)) |
| 7 |
|
| 8 |
declare function checkTruths(x: Facts): void; |
| 9 |
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 40)) |
| 10 |
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 1, 29)) |
| 11 |
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 0)) |
| 12 |
|
| 13 |
declare function checkM(x: { m: boolean }): void; |
| 14 |
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance1.ts, 1, 45)) |
| 15 |
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 2, 24)) |
| 16 |
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 2, 28)) |
| 17 |
|
| 18 |
const x = { |
| 19 |
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5)) |
| 20 |
|
| 21 |
m: true |
| 22 |
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 11)) |
| 23 |
|
| 24 |
}; |
| 25 |
|
| 26 |
// Should be OK |
| 27 |
checkTruths(x); |
| 28 |
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 40)) |
| 29 |
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5)) |
| 30 |
|
| 31 |
// Should be OK |
| 32 |
checkM(x); |
| 33 |
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance1.ts, 1, 45)) |
| 34 |
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5)) |
| 35 |
|
| 36 |
// Should fail under --noPropertyAccessFromIndexSignature |
| 37 |
console.log(x.z); |
| 38 |
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 39 |
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) |
| 40 |
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 41 |
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5)) |
| 42 |
|
| 43 |
const m: boolean = x.m; |
| 44 |
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 13, 5)) |
| 45 |
>x.m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 11)) |
| 46 |
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5)) |
| 47 |
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 11)) |
| 48 |
|
| 49 |
// Should be 'm' |
| 50 |
type M = keyof typeof x; |
| 51 |
>M : Symbol(M, Decl(typeSatisfaction_propertyValueConformance1.ts, 13, 23)) |
| 52 |
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5)) |
| 53 |
|
| 54 |
// Should be able to detect a failure here |
| 55 |
const x2 = { |
| 56 |
>x2 : Symbol(x2, Decl(typeSatisfaction_propertyValueConformance1.ts, 19, 5)) |
| 57 |
|
| 58 |
m: true, |
| 59 |
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 19, 12)) |
| 60 |
|
| 61 |
s: "false" |
| 62 |
>s : Symbol(s, Decl(typeSatisfaction_propertyValueConformance1.ts, 20, 12)) |
| 63 |
|
| 64 |
} satisfies Facts; |
| 65 |
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 0)) |
| 66 |
|