-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a261ad
commit 7c22dcb
Showing
3 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
=== tests/cases/compiler/contextualTypeCaching.ts === | ||
// Repro from #52575 | ||
|
||
export interface Event<T> { | ||
>Event : Symbol(Event, Decl(contextualTypeCaching.ts, 0, 0)) | ||
>T : Symbol(T, Decl(contextualTypeCaching.ts, 2, 23)) | ||
|
||
callback: (response: T) => void; | ||
>callback : Symbol(Event.callback, Decl(contextualTypeCaching.ts, 2, 27)) | ||
>response : Symbol(response, Decl(contextualTypeCaching.ts, 3, 15)) | ||
>T : Symbol(T, Decl(contextualTypeCaching.ts, 2, 23)) | ||
|
||
nested: { | ||
>nested : Symbol(Event.nested, Decl(contextualTypeCaching.ts, 3, 36)) | ||
|
||
nestedCallback: (response: T) => void; | ||
>nestedCallback : Symbol(nestedCallback, Decl(contextualTypeCaching.ts, 4, 13)) | ||
>response : Symbol(response, Decl(contextualTypeCaching.ts, 5, 25)) | ||
>T : Symbol(T, Decl(contextualTypeCaching.ts, 2, 23)) | ||
} | ||
} | ||
|
||
export type CustomEvents = { | ||
>CustomEvents : Symbol(CustomEvents, Decl(contextualTypeCaching.ts, 7, 1)) | ||
|
||
a: Event<string> | ||
>a : Symbol(a, Decl(contextualTypeCaching.ts, 9, 28)) | ||
>Event : Symbol(Event, Decl(contextualTypeCaching.ts, 0, 0)) | ||
|
||
b: Event<number> | ||
>b : Symbol(b, Decl(contextualTypeCaching.ts, 10, 20)) | ||
>Event : Symbol(Event, Decl(contextualTypeCaching.ts, 0, 0)) | ||
|
||
}; | ||
|
||
declare function emit<T extends keyof CustomEvents>(type: T, data: CustomEvents[T]): void | ||
>emit : Symbol(emit, Decl(contextualTypeCaching.ts, 12, 2)) | ||
>T : Symbol(T, Decl(contextualTypeCaching.ts, 14, 22)) | ||
>CustomEvents : Symbol(CustomEvents, Decl(contextualTypeCaching.ts, 7, 1)) | ||
>type : Symbol(type, Decl(contextualTypeCaching.ts, 14, 52)) | ||
>T : Symbol(T, Decl(contextualTypeCaching.ts, 14, 22)) | ||
>data : Symbol(data, Decl(contextualTypeCaching.ts, 14, 60)) | ||
>CustomEvents : Symbol(CustomEvents, Decl(contextualTypeCaching.ts, 7, 1)) | ||
>T : Symbol(T, Decl(contextualTypeCaching.ts, 14, 22)) | ||
|
||
emit('a', { | ||
>emit : Symbol(emit, Decl(contextualTypeCaching.ts, 12, 2)) | ||
|
||
callback: (r) => {}, | ||
>callback : Symbol(callback, Decl(contextualTypeCaching.ts, 16, 11)) | ||
>r : Symbol(r, Decl(contextualTypeCaching.ts, 17, 15)) | ||
|
||
nested: { | ||
>nested : Symbol(nested, Decl(contextualTypeCaching.ts, 17, 24)) | ||
|
||
nestedCallback: (r) => {}, | ||
>nestedCallback : Symbol(nestedCallback, Decl(contextualTypeCaching.ts, 18, 13)) | ||
>r : Symbol(r, Decl(contextualTypeCaching.ts, 19, 25)) | ||
|
||
}, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
=== tests/cases/compiler/contextualTypeCaching.ts === | ||
// Repro from #52575 | ||
|
||
export interface Event<T> { | ||
callback: (response: T) => void; | ||
>callback : (response: T) => void | ||
>response : T | ||
|
||
nested: { | ||
>nested : { nestedCallback: (response: T) => void; } | ||
|
||
nestedCallback: (response: T) => void; | ||
>nestedCallback : (response: T) => void | ||
>response : T | ||
} | ||
} | ||
|
||
export type CustomEvents = { | ||
>CustomEvents : { a: Event<string>; b: Event<number>; } | ||
|
||
a: Event<string> | ||
>a : Event<string> | ||
|
||
b: Event<number> | ||
>b : Event<number> | ||
|
||
}; | ||
|
||
declare function emit<T extends keyof CustomEvents>(type: T, data: CustomEvents[T]): void | ||
>emit : <T extends keyof CustomEvents>(type: T, data: CustomEvents[T]) => void | ||
>type : T | ||
>data : CustomEvents[T] | ||
|
||
emit('a', { | ||
>emit('a', { callback: (r) => {}, nested: { nestedCallback: (r) => {}, },}) : void | ||
>emit : <T extends keyof CustomEvents>(type: T, data: CustomEvents[T]) => void | ||
>'a' : "a" | ||
>{ callback: (r) => {}, nested: { nestedCallback: (r) => {}, },} : { callback: (r: string) => void; nested: { nestedCallback: (r: string) => void; }; } | ||
|
||
callback: (r) => {}, | ||
>callback : (r: string) => void | ||
>(r) => {} : (r: string) => void | ||
>r : string | ||
|
||
nested: { | ||
>nested : { nestedCallback: (r: string) => void; } | ||
>{ nestedCallback: (r) => {}, } : { nestedCallback: (r: string) => void; } | ||
|
||
nestedCallback: (r) => {}, | ||
>nestedCallback : (r: string) => void | ||
>(r) => {} : (r: string) => void | ||
>r : string | ||
|
||
}, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
// Repro from #52575 | ||
|
||
export interface Event<T> { | ||
callback: (response: T) => void; | ||
nested: { | ||
nestedCallback: (response: T) => void; | ||
} | ||
} | ||
|
||
export type CustomEvents = { | ||
a: Event<string> | ||
b: Event<number> | ||
}; | ||
|
||
declare function emit<T extends keyof CustomEvents>(type: T, data: CustomEvents[T]): void | ||
|
||
emit('a', { | ||
callback: (r) => {}, | ||
nested: { | ||
nestedCallback: (r) => {}, | ||
}, | ||
}); |