|
| 1 | +=== tests/cases/compiler/inferInstanceTypeArgumentsAsConstraint.ts === |
| 2 | +class Unconstrained<T> { |
| 3 | +>Unconstrained : Symbol(Unconstrained, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 0)) |
| 4 | +>T : Symbol(T, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 20)) |
| 5 | + |
| 6 | + value: T; |
| 7 | +>value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 8 | +>T : Symbol(T, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 20)) |
| 9 | +} |
| 10 | + |
| 11 | +declare const x: unknown; |
| 12 | +>x : Symbol(x, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 4, 13)) |
| 13 | + |
| 14 | +if (x instanceof Unconstrained) { |
| 15 | +>x : Symbol(x, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 4, 13)) |
| 16 | +>Unconstrained : Symbol(Unconstrained, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 0)) |
| 17 | + |
| 18 | + x.value.toUpperCase(); |
| 19 | +>x.value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 20 | +>x : Symbol(x, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 4, 13)) |
| 21 | +>value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 22 | + |
| 23 | + x.value++; |
| 24 | +>x.value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 25 | +>x : Symbol(x, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 4, 13)) |
| 26 | +>value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 27 | + |
| 28 | + x.value(); |
| 29 | +>x.value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 30 | +>x : Symbol(x, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 4, 13)) |
| 31 | +>value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 32 | + |
| 33 | + if (typeof x.value === "string") { |
| 34 | +>x.value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 35 | +>x : Symbol(x, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 4, 13)) |
| 36 | +>value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 37 | + |
| 38 | + x.value.toUpperCase(); |
| 39 | +>x.value.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) |
| 40 | +>x.value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 41 | +>x : Symbol(x, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 4, 13)) |
| 42 | +>value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 43 | +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) |
| 44 | + } |
| 45 | + if (typeof x.value === "number") { |
| 46 | +>x.value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 47 | +>x : Symbol(x, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 4, 13)) |
| 48 | +>value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 49 | + |
| 50 | + x.value++; |
| 51 | +>x.value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 52 | +>x : Symbol(x, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 4, 13)) |
| 53 | +>value : Symbol(Unconstrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 0, 24)) |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +class Constrained<T extends number> { |
| 58 | +>Constrained : Symbol(Constrained, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 17, 1)) |
| 59 | +>T : Symbol(T, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 19, 18)) |
| 60 | + |
| 61 | + value: T; |
| 62 | +>value : Symbol(Constrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 19, 37)) |
| 63 | +>T : Symbol(T, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 19, 18)) |
| 64 | +} |
| 65 | + |
| 66 | +declare const y: unknown; |
| 67 | +>y : Symbol(y, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 23, 13)) |
| 68 | + |
| 69 | +if (y instanceof Constrained) { |
| 70 | +>y : Symbol(y, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 23, 13)) |
| 71 | +>Constrained : Symbol(Constrained, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 17, 1)) |
| 72 | + |
| 73 | + y.value++; |
| 74 | +>y.value : Symbol(Constrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 19, 37)) |
| 75 | +>y : Symbol(y, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 23, 13)) |
| 76 | +>value : Symbol(Constrained.value, Decl(inferInstanceTypeArgumentsAsConstraint.ts, 19, 37)) |
| 77 | +} |
| 78 | + |
0 commit comments