|
| 1 | +//// [tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals2.ts] //// |
| 2 | + |
| 3 | +=== thisInObjectLiterals2.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/54723 |
| 5 | + |
| 6 | +interface State { |
| 7 | +>State : Symbol(State, Decl(thisInObjectLiterals2.ts, 0, 0)) |
| 8 | + |
| 9 | + value: string; |
| 10 | +>value : Symbol(State.value, Decl(thisInObjectLiterals2.ts, 2, 17)) |
| 11 | + |
| 12 | + matches(value: string): boolean; |
| 13 | +>matches : Symbol(State.matches, Decl(thisInObjectLiterals2.ts, 3, 16)) |
| 14 | +>value : Symbol(value, Decl(thisInObjectLiterals2.ts, 4, 10)) |
| 15 | +} |
| 16 | + |
| 17 | +declare function macthesState(state: { value: string }, value: string): boolean; |
| 18 | +>macthesState : Symbol(macthesState, Decl(thisInObjectLiterals2.ts, 5, 1)) |
| 19 | +>state : Symbol(state, Decl(thisInObjectLiterals2.ts, 7, 30)) |
| 20 | +>value : Symbol(value, Decl(thisInObjectLiterals2.ts, 7, 38)) |
| 21 | +>value : Symbol(value, Decl(thisInObjectLiterals2.ts, 7, 55)) |
| 22 | + |
| 23 | +declare function isState(state: unknown): state is State; |
| 24 | +>isState : Symbol(isState, Decl(thisInObjectLiterals2.ts, 7, 80)) |
| 25 | +>state : Symbol(state, Decl(thisInObjectLiterals2.ts, 8, 25)) |
| 26 | +>state : Symbol(state, Decl(thisInObjectLiterals2.ts, 8, 25)) |
| 27 | +>State : Symbol(State, Decl(thisInObjectLiterals2.ts, 0, 0)) |
| 28 | + |
| 29 | +function test(config: unknown, prevConfig: unknown) { |
| 30 | +>test : Symbol(test, Decl(thisInObjectLiterals2.ts, 8, 57)) |
| 31 | +>config : Symbol(config, Decl(thisInObjectLiterals2.ts, 10, 14)) |
| 32 | +>prevConfig : Symbol(prevConfig, Decl(thisInObjectLiterals2.ts, 10, 30)) |
| 33 | + |
| 34 | + if (isState(config)) { |
| 35 | +>isState : Symbol(isState, Decl(thisInObjectLiterals2.ts, 7, 80)) |
| 36 | +>config : Symbol(config, Decl(thisInObjectLiterals2.ts, 10, 14)) |
| 37 | + |
| 38 | + return { |
| 39 | + ...config, |
| 40 | +>config : Symbol(config, Decl(thisInObjectLiterals2.ts, 10, 14)) |
| 41 | + |
| 42 | + matches: isState(prevConfig) |
| 43 | +>matches : Symbol(matches, Decl(thisInObjectLiterals2.ts, 13, 16)) |
| 44 | +>isState : Symbol(isState, Decl(thisInObjectLiterals2.ts, 7, 80)) |
| 45 | +>prevConfig : Symbol(prevConfig, Decl(thisInObjectLiterals2.ts, 10, 30)) |
| 46 | + |
| 47 | + ? prevConfig.matches |
| 48 | +>prevConfig.matches : Symbol(State.matches, Decl(thisInObjectLiterals2.ts, 3, 16)) |
| 49 | +>prevConfig : Symbol(prevConfig, Decl(thisInObjectLiterals2.ts, 10, 30)) |
| 50 | +>matches : Symbol(State.matches, Decl(thisInObjectLiterals2.ts, 3, 16)) |
| 51 | + |
| 52 | + : function (value: string) { |
| 53 | +>value : Symbol(value, Decl(thisInObjectLiterals2.ts, 16, 20)) |
| 54 | + |
| 55 | + return macthesState(this, value); |
| 56 | +>macthesState : Symbol(macthesState, Decl(thisInObjectLiterals2.ts, 5, 1)) |
| 57 | +>this : Symbol(__object, Decl(thisInObjectLiterals2.ts, 12, 10)) |
| 58 | +>value : Symbol(value, Decl(thisInObjectLiterals2.ts, 16, 20)) |
| 59 | + |
| 60 | + }, |
| 61 | + }; |
| 62 | + } |
| 63 | + |
| 64 | + return config; |
| 65 | +>config : Symbol(config, Decl(thisInObjectLiterals2.ts, 10, 14)) |
| 66 | +} |
| 67 | + |
| 68 | +function test2(config: State) { |
| 69 | +>test2 : Symbol(test2, Decl(thisInObjectLiterals2.ts, 23, 1)) |
| 70 | +>config : Symbol(config, Decl(thisInObjectLiterals2.ts, 25, 15)) |
| 71 | +>State : Symbol(State, Decl(thisInObjectLiterals2.ts, 0, 0)) |
| 72 | + |
| 73 | + return { |
| 74 | + ...config, |
| 75 | +>config : Symbol(config, Decl(thisInObjectLiterals2.ts, 25, 15)) |
| 76 | + |
| 77 | + matches: function (value: string) { |
| 78 | +>matches : Symbol(matches, Decl(thisInObjectLiterals2.ts, 27, 14)) |
| 79 | +>value : Symbol(value, Decl(thisInObjectLiterals2.ts, 28, 23)) |
| 80 | + |
| 81 | + return macthesState(this, value); |
| 82 | +>macthesState : Symbol(macthesState, Decl(thisInObjectLiterals2.ts, 5, 1)) |
| 83 | +>this : Symbol(__object, Decl(thisInObjectLiterals2.ts, 26, 8)) |
| 84 | +>value : Symbol(value, Decl(thisInObjectLiterals2.ts, 28, 23)) |
| 85 | + |
| 86 | + }, |
| 87 | + }; |
| 88 | +} |
0 commit comments