|
| 1 | +=== tests/cases/compiler/contextualComputedNonBindablePropertyType.ts === |
| 2 | +// repro #51906 |
| 3 | + |
| 4 | +declare function testD(): "d"; |
| 5 | +>testD : Symbol(testD, Decl(contextualComputedNonBindablePropertyType.ts, 0, 0)) |
| 6 | + |
| 7 | +declare function forceMatch<T>(matched: { |
| 8 | +>forceMatch : Symbol(forceMatch, Decl(contextualComputedNonBindablePropertyType.ts, 2, 30)) |
| 9 | +>T : Symbol(T, Decl(contextualComputedNonBindablePropertyType.ts, 4, 28)) |
| 10 | +>matched : Symbol(matched, Decl(contextualComputedNonBindablePropertyType.ts, 4, 31)) |
| 11 | + |
| 12 | + [key in keyof T]: key; |
| 13 | +>key : Symbol(key, Decl(contextualComputedNonBindablePropertyType.ts, 5, 3)) |
| 14 | +>T : Symbol(T, Decl(contextualComputedNonBindablePropertyType.ts, 4, 28)) |
| 15 | +>key : Symbol(key, Decl(contextualComputedNonBindablePropertyType.ts, 5, 3)) |
| 16 | + |
| 17 | +}): void; |
| 18 | + |
| 19 | +forceMatch({ |
| 20 | +>forceMatch : Symbol(forceMatch, Decl(contextualComputedNonBindablePropertyType.ts, 2, 30)) |
| 21 | + |
| 22 | + [testD()]: "d", |
| 23 | +>[testD()] : Symbol([testD()], Decl(contextualComputedNonBindablePropertyType.ts, 8, 12)) |
| 24 | +>testD : Symbol(testD, Decl(contextualComputedNonBindablePropertyType.ts, 0, 0)) |
| 25 | + |
| 26 | +}); |
| 27 | + |
| 28 | +declare function forceMatch2<T>(matched: { |
| 29 | +>forceMatch2 : Symbol(forceMatch2, Decl(contextualComputedNonBindablePropertyType.ts, 10, 3)) |
| 30 | +>T : Symbol(T, Decl(contextualComputedNonBindablePropertyType.ts, 12, 29)) |
| 31 | +>matched : Symbol(matched, Decl(contextualComputedNonBindablePropertyType.ts, 12, 32)) |
| 32 | + |
| 33 | + [key in keyof T]: ({ key }: { key: key }) => void; |
| 34 | +>key : Symbol(key, Decl(contextualComputedNonBindablePropertyType.ts, 13, 3)) |
| 35 | +>T : Symbol(T, Decl(contextualComputedNonBindablePropertyType.ts, 12, 29)) |
| 36 | +>key : Symbol(key, Decl(contextualComputedNonBindablePropertyType.ts, 13, 22)) |
| 37 | +>key : Symbol(key, Decl(contextualComputedNonBindablePropertyType.ts, 13, 31)) |
| 38 | +>key : Symbol(key, Decl(contextualComputedNonBindablePropertyType.ts, 13, 3)) |
| 39 | + |
| 40 | +}): void; |
| 41 | + |
| 42 | +forceMatch2({ |
| 43 | +>forceMatch2 : Symbol(forceMatch2, Decl(contextualComputedNonBindablePropertyType.ts, 10, 3)) |
| 44 | + |
| 45 | + [testD()]: ({ key }) => {}, |
| 46 | +>[testD()] : Symbol([testD()], Decl(contextualComputedNonBindablePropertyType.ts, 16, 13)) |
| 47 | +>testD : Symbol(testD, Decl(contextualComputedNonBindablePropertyType.ts, 0, 0)) |
| 48 | +>key : Symbol(key, Decl(contextualComputedNonBindablePropertyType.ts, 17, 15)) |
| 49 | + |
| 50 | +}); |
| 51 | + |
| 52 | +// repro #52954 |
| 53 | + |
| 54 | +type Original = { foo: 'expects a string literal', baz: boolean, bar: number } |
| 55 | +>Original : Symbol(Original, Decl(contextualComputedNonBindablePropertyType.ts, 18, 3)) |
| 56 | +>foo : Symbol(foo, Decl(contextualComputedNonBindablePropertyType.ts, 22, 17)) |
| 57 | +>baz : Symbol(baz, Decl(contextualComputedNonBindablePropertyType.ts, 22, 50)) |
| 58 | +>bar : Symbol(bar, Decl(contextualComputedNonBindablePropertyType.ts, 22, 64)) |
| 59 | + |
| 60 | +type Mapped = { |
| 61 | +>Mapped : Symbol(Mapped, Decl(contextualComputedNonBindablePropertyType.ts, 22, 78)) |
| 62 | + |
| 63 | + [prop in keyof Original]: (arg: Original[prop]) => Original[prop] |
| 64 | +>prop : Symbol(prop, Decl(contextualComputedNonBindablePropertyType.ts, 25, 3)) |
| 65 | +>Original : Symbol(Original, Decl(contextualComputedNonBindablePropertyType.ts, 18, 3)) |
| 66 | +>arg : Symbol(arg, Decl(contextualComputedNonBindablePropertyType.ts, 25, 29)) |
| 67 | +>Original : Symbol(Original, Decl(contextualComputedNonBindablePropertyType.ts, 18, 3)) |
| 68 | +>prop : Symbol(prop, Decl(contextualComputedNonBindablePropertyType.ts, 25, 3)) |
| 69 | +>Original : Symbol(Original, Decl(contextualComputedNonBindablePropertyType.ts, 18, 3)) |
| 70 | +>prop : Symbol(prop, Decl(contextualComputedNonBindablePropertyType.ts, 25, 3)) |
| 71 | +} |
| 72 | + |
| 73 | +const propSelector = <propName extends string>(propName: propName): propName => propName; |
| 74 | +>propSelector : Symbol(propSelector, Decl(contextualComputedNonBindablePropertyType.ts, 28, 5)) |
| 75 | +>propName : Symbol(propName, Decl(contextualComputedNonBindablePropertyType.ts, 28, 23), Decl(contextualComputedNonBindablePropertyType.ts, 28, 48)) |
| 76 | +>propName : Symbol(propName, Decl(contextualComputedNonBindablePropertyType.ts, 28, 23), Decl(contextualComputedNonBindablePropertyType.ts, 28, 48)) |
| 77 | +>propName : Symbol(propName, Decl(contextualComputedNonBindablePropertyType.ts, 28, 23), Decl(contextualComputedNonBindablePropertyType.ts, 28, 48)) |
| 78 | +>propName : Symbol(propName, Decl(contextualComputedNonBindablePropertyType.ts, 28, 23), Decl(contextualComputedNonBindablePropertyType.ts, 28, 48)) |
| 79 | +>propName : Symbol(propName, Decl(contextualComputedNonBindablePropertyType.ts, 28, 23), Decl(contextualComputedNonBindablePropertyType.ts, 28, 48)) |
| 80 | + |
| 81 | +const unexpectedlyFailingExample: Mapped = { |
| 82 | +>unexpectedlyFailingExample : Symbol(unexpectedlyFailingExample, Decl(contextualComputedNonBindablePropertyType.ts, 30, 5)) |
| 83 | +>Mapped : Symbol(Mapped, Decl(contextualComputedNonBindablePropertyType.ts, 22, 78)) |
| 84 | + |
| 85 | + foo: (arg) => 'expects a string literal', |
| 86 | +>foo : Symbol(foo, Decl(contextualComputedNonBindablePropertyType.ts, 30, 44)) |
| 87 | +>arg : Symbol(arg, Decl(contextualComputedNonBindablePropertyType.ts, 31, 8)) |
| 88 | + |
| 89 | + baz: (arg) => true, |
| 90 | +>baz : Symbol(baz, Decl(contextualComputedNonBindablePropertyType.ts, 31, 43)) |
| 91 | +>arg : Symbol(arg, Decl(contextualComputedNonBindablePropertyType.ts, 32, 8)) |
| 92 | + |
| 93 | + [propSelector('bar')]: (arg) => 51345 |
| 94 | +>[propSelector('bar')] : Symbol([propSelector('bar')], Decl(contextualComputedNonBindablePropertyType.ts, 32, 21)) |
| 95 | +>propSelector : Symbol(propSelector, Decl(contextualComputedNonBindablePropertyType.ts, 28, 5)) |
| 96 | +>arg : Symbol(arg, Decl(contextualComputedNonBindablePropertyType.ts, 33, 26)) |
| 97 | +} |
| 98 | + |
0 commit comments