|
| 1 | +=== tests/cases/compiler/expressionPropertyLookupIncludesMixins.ts === |
| 2 | +// https://github.com/microsoft/TypeScript/issues/31426 |
| 3 | + |
| 4 | +export type AnyFunction<A = any> = (...input : any[]) => A |
| 5 | +>AnyFunction : Symbol(AnyFunction, Decl(expressionPropertyLookupIncludesMixins.ts, 0, 0)) |
| 6 | +>A : Symbol(A, Decl(expressionPropertyLookupIncludesMixins.ts, 2, 24)) |
| 7 | +>input : Symbol(input, Decl(expressionPropertyLookupIncludesMixins.ts, 2, 43)) |
| 8 | +>A : Symbol(A, Decl(expressionPropertyLookupIncludesMixins.ts, 2, 24)) |
| 9 | + |
| 10 | +export type AnyConstructor<A = object> = new (...input : any[]) => A |
| 11 | +>AnyConstructor : Symbol(AnyConstructor, Decl(expressionPropertyLookupIncludesMixins.ts, 2, 65)) |
| 12 | +>A : Symbol(A, Decl(expressionPropertyLookupIncludesMixins.ts, 3, 27)) |
| 13 | +>input : Symbol(input, Decl(expressionPropertyLookupIncludesMixins.ts, 3, 47)) |
| 14 | +>A : Symbol(A, Decl(expressionPropertyLookupIncludesMixins.ts, 3, 27)) |
| 15 | + |
| 16 | +export type Mixin<T extends AnyFunction> = InstanceType<ReturnType<T>> |
| 17 | +>Mixin : Symbol(Mixin, Decl(expressionPropertyLookupIncludesMixins.ts, 3, 69)) |
| 18 | +>T : Symbol(T, Decl(expressionPropertyLookupIncludesMixins.ts, 4, 18)) |
| 19 | +>AnyFunction : Symbol(AnyFunction, Decl(expressionPropertyLookupIncludesMixins.ts, 0, 0)) |
| 20 | +>InstanceType : Symbol(InstanceType, Decl(lib.es5.d.ts, --, --)) |
| 21 | +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) |
| 22 | +>T : Symbol(T, Decl(expressionPropertyLookupIncludesMixins.ts, 4, 18)) |
| 23 | + |
| 24 | +export const Box = <T extends AnyConstructor<object>>(base : T) => |
| 25 | +>Box : Symbol(Box, Decl(expressionPropertyLookupIncludesMixins.ts, 6, 12), Decl(expressionPropertyLookupIncludesMixins.ts, 9, 1)) |
| 26 | +>T : Symbol(T, Decl(expressionPropertyLookupIncludesMixins.ts, 6, 20)) |
| 27 | +>AnyConstructor : Symbol(AnyConstructor, Decl(expressionPropertyLookupIncludesMixins.ts, 2, 65)) |
| 28 | +>base : Symbol(base, Decl(expressionPropertyLookupIncludesMixins.ts, 6, 54)) |
| 29 | +>T : Symbol(T, Decl(expressionPropertyLookupIncludesMixins.ts, 6, 20)) |
| 30 | + |
| 31 | +class Box extends base { |
| 32 | +>Box : Symbol(Box, Decl(expressionPropertyLookupIncludesMixins.ts, 6, 66)) |
| 33 | +>base : Symbol(base, Decl(expressionPropertyLookupIncludesMixins.ts, 6, 54)) |
| 34 | + |
| 35 | + value : any |
| 36 | +>value : Symbol(Box.value, Decl(expressionPropertyLookupIncludesMixins.ts, 7, 24)) |
| 37 | +} |
| 38 | +export interface Box extends Mixin<typeof Box> {} |
| 39 | +>Box : Symbol(Box, Decl(expressionPropertyLookupIncludesMixins.ts, 6, 12), Decl(expressionPropertyLookupIncludesMixins.ts, 9, 1)) |
| 40 | +>Mixin : Symbol(Mixin, Decl(expressionPropertyLookupIncludesMixins.ts, 3, 69)) |
| 41 | +>Box : Symbol(Box, Decl(expressionPropertyLookupIncludesMixins.ts, 6, 12), Decl(expressionPropertyLookupIncludesMixins.ts, 9, 1)) |
| 42 | + |
| 43 | +export const Observable = <T extends AnyConstructor<object>>(base : T) => |
| 44 | +>Observable : Symbol(Observable, Decl(expressionPropertyLookupIncludesMixins.ts, 12, 12), Decl(expressionPropertyLookupIncludesMixins.ts, 17, 1)) |
| 45 | +>T : Symbol(T, Decl(expressionPropertyLookupIncludesMixins.ts, 12, 27)) |
| 46 | +>AnyConstructor : Symbol(AnyConstructor, Decl(expressionPropertyLookupIncludesMixins.ts, 2, 65)) |
| 47 | +>base : Symbol(base, Decl(expressionPropertyLookupIncludesMixins.ts, 12, 61)) |
| 48 | +>T : Symbol(T, Decl(expressionPropertyLookupIncludesMixins.ts, 12, 27)) |
| 49 | + |
| 50 | +class Observable extends base { |
| 51 | +>Observable : Symbol(Observable, Decl(expressionPropertyLookupIncludesMixins.ts, 12, 73)) |
| 52 | +>base : Symbol(base, Decl(expressionPropertyLookupIncludesMixins.ts, 12, 61)) |
| 53 | + |
| 54 | + observe () : IQuark { |
| 55 | +>observe : Symbol(Observable.observe, Decl(expressionPropertyLookupIncludesMixins.ts, 13, 31)) |
| 56 | +>IQuark : Symbol(IQuark, Decl(expressionPropertyLookupIncludesMixins.ts, 30, 1)) |
| 57 | + |
| 58 | + return |
| 59 | + } |
| 60 | +} |
| 61 | +export interface Observable extends Mixin<typeof Observable> {} |
| 62 | +>Observable : Symbol(Observable, Decl(expressionPropertyLookupIncludesMixins.ts, 12, 12), Decl(expressionPropertyLookupIncludesMixins.ts, 17, 1)) |
| 63 | +>Mixin : Symbol(Mixin, Decl(expressionPropertyLookupIncludesMixins.ts, 3, 69)) |
| 64 | +>Observable : Symbol(Observable, Decl(expressionPropertyLookupIncludesMixins.ts, 12, 12), Decl(expressionPropertyLookupIncludesMixins.ts, 17, 1)) |
| 65 | + |
| 66 | +export const CQuark = <T extends AnyConstructor<Box & Observable>>(base : T) => |
| 67 | +>CQuark : Symbol(CQuark, Decl(expressionPropertyLookupIncludesMixins.ts, 20, 12)) |
| 68 | +>T : Symbol(T, Decl(expressionPropertyLookupIncludesMixins.ts, 20, 23)) |
| 69 | +>AnyConstructor : Symbol(AnyConstructor, Decl(expressionPropertyLookupIncludesMixins.ts, 2, 65)) |
| 70 | +>Box : Symbol(Box, Decl(expressionPropertyLookupIncludesMixins.ts, 6, 12), Decl(expressionPropertyLookupIncludesMixins.ts, 9, 1)) |
| 71 | +>Observable : Symbol(Observable, Decl(expressionPropertyLookupIncludesMixins.ts, 12, 12), Decl(expressionPropertyLookupIncludesMixins.ts, 17, 1)) |
| 72 | +>base : Symbol(base, Decl(expressionPropertyLookupIncludesMixins.ts, 20, 67)) |
| 73 | +>T : Symbol(T, Decl(expressionPropertyLookupIncludesMixins.ts, 20, 23)) |
| 74 | + |
| 75 | +class Quark extends base { |
| 76 | +>Quark : Symbol(Quark, Decl(expressionPropertyLookupIncludesMixins.ts, 20, 79)) |
| 77 | +>base : Symbol(base, Decl(expressionPropertyLookupIncludesMixins.ts, 20, 67)) |
| 78 | + |
| 79 | + observe () : Quark { |
| 80 | +>observe : Symbol(Quark.observe, Decl(expressionPropertyLookupIncludesMixins.ts, 21, 26)) |
| 81 | +>Quark : Symbol(Quark, Decl(expressionPropertyLookupIncludesMixins.ts, 20, 79)) |
| 82 | + |
| 83 | + // No error here! |
| 84 | + this.value |
| 85 | +>this.value : Symbol(Box.value, Decl(expressionPropertyLookupIncludesMixins.ts, 7, 24)) |
| 86 | +>this : Symbol(Quark, Decl(expressionPropertyLookupIncludesMixins.ts, 20, 79)) |
| 87 | +>value : Symbol(Box.value, Decl(expressionPropertyLookupIncludesMixins.ts, 7, 24)) |
| 88 | + |
| 89 | + |
| 90 | + return |
| 91 | + } |
| 92 | +} |
| 93 | +export interface IQuark extends Mixin<typeof CQuark> {} |
| 94 | +>IQuark : Symbol(IQuark, Decl(expressionPropertyLookupIncludesMixins.ts, 30, 1)) |
| 95 | +>Mixin : Symbol(Mixin, Decl(expressionPropertyLookupIncludesMixins.ts, 3, 69)) |
| 96 | +>CQuark : Symbol(CQuark, Decl(expressionPropertyLookupIncludesMixins.ts, 20, 12)) |
| 97 | + |
| 98 | +const test = (a : IQuark) => a.value // <-- Should not error |
| 99 | +>test : Symbol(test, Decl(expressionPropertyLookupIncludesMixins.ts, 33, 5)) |
| 100 | +>a : Symbol(a, Decl(expressionPropertyLookupIncludesMixins.ts, 33, 14)) |
| 101 | +>IQuark : Symbol(IQuark, Decl(expressionPropertyLookupIncludesMixins.ts, 30, 1)) |
| 102 | +>a.value : Symbol(Box.value, Decl(expressionPropertyLookupIncludesMixins.ts, 7, 24)) |
| 103 | +>a : Symbol(a, Decl(expressionPropertyLookupIncludesMixins.ts, 33, 14)) |
| 104 | +>value : Symbol(Box.value, Decl(expressionPropertyLookupIncludesMixins.ts, 7, 24)) |
| 105 | + |
0 commit comments