|
| 1 | +//// [tests/cases/compiler/inferenceContextualReturnTypeUnion2.ts] //// |
| 2 | + |
| 3 | +=== inferenceContextualReturnTypeUnion2.ts === |
| 4 | +type Query = ( |
| 5 | +>Query : Symbol(Query, Decl(inferenceContextualReturnTypeUnion2.ts, 0, 0)) |
| 6 | + |
| 7 | + container: HTMLElement, |
| 8 | +>container : Symbol(container, Decl(inferenceContextualReturnTypeUnion2.ts, 0, 14)) |
| 9 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 10 | + |
| 11 | + ...args: any[] |
| 12 | +>args : Symbol(args, Decl(inferenceContextualReturnTypeUnion2.ts, 1, 25)) |
| 13 | + |
| 14 | +) => |
| 15 | + | Error |
| 16 | +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --)) |
| 17 | + |
| 18 | + | HTMLElement |
| 19 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 20 | + |
| 21 | + | HTMLElement[] |
| 22 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 23 | + |
| 24 | + | Promise<HTMLElement[]> |
| 25 | +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) |
| 26 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 27 | + |
| 28 | + | Promise<HTMLElement> |
| 29 | +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) |
| 30 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 31 | + |
| 32 | + | null; |
| 33 | + |
| 34 | +interface Queries { |
| 35 | +>Queries : Symbol(Queries, Decl(inferenceContextualReturnTypeUnion2.ts, 9, 9)) |
| 36 | + |
| 37 | + [T: string]: Query; |
| 38 | +>T : Symbol(T, Decl(inferenceContextualReturnTypeUnion2.ts, 12, 3)) |
| 39 | +>Query : Symbol(Query, Decl(inferenceContextualReturnTypeUnion2.ts, 0, 0)) |
| 40 | +} |
| 41 | + |
| 42 | +type FindByText<T extends HTMLElement = HTMLElement> = ( |
| 43 | +>FindByText : Symbol(FindByText, Decl(inferenceContextualReturnTypeUnion2.ts, 13, 1)) |
| 44 | +>T : Symbol(T, Decl(inferenceContextualReturnTypeUnion2.ts, 15, 16)) |
| 45 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 46 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 47 | + |
| 48 | + container: HTMLElement, |
| 49 | +>container : Symbol(container, Decl(inferenceContextualReturnTypeUnion2.ts, 15, 56)) |
| 50 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 51 | + |
| 52 | + text: string, |
| 53 | +>text : Symbol(text, Decl(inferenceContextualReturnTypeUnion2.ts, 16, 25)) |
| 54 | + |
| 55 | +) => Promise<T>; |
| 56 | +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) |
| 57 | +>T : Symbol(T, Decl(inferenceContextualReturnTypeUnion2.ts, 15, 16)) |
| 58 | + |
| 59 | +declare function findByLabelText<T extends HTMLElement = HTMLElement>( |
| 60 | +>findByLabelText : Symbol(findByLabelText, Decl(inferenceContextualReturnTypeUnion2.ts, 18, 16)) |
| 61 | +>T : Symbol(T, Decl(inferenceContextualReturnTypeUnion2.ts, 20, 33)) |
| 62 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 63 | +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 64 | + |
| 65 | + ...args: Parameters<FindByText<T>> |
| 66 | +>args : Symbol(args, Decl(inferenceContextualReturnTypeUnion2.ts, 20, 70)) |
| 67 | +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) |
| 68 | +>FindByText : Symbol(FindByText, Decl(inferenceContextualReturnTypeUnion2.ts, 13, 1)) |
| 69 | +>T : Symbol(T, Decl(inferenceContextualReturnTypeUnion2.ts, 20, 33)) |
| 70 | + |
| 71 | +): ReturnType<FindByText<T>>; |
| 72 | +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) |
| 73 | +>FindByText : Symbol(FindByText, Decl(inferenceContextualReturnTypeUnion2.ts, 13, 1)) |
| 74 | +>T : Symbol(T, Decl(inferenceContextualReturnTypeUnion2.ts, 20, 33)) |
| 75 | + |
| 76 | +const queries = { |
| 77 | +>queries : Symbol(queries, Decl(inferenceContextualReturnTypeUnion2.ts, 24, 5)) |
| 78 | + |
| 79 | + findByLabelText, |
| 80 | +>findByLabelText : Symbol(findByLabelText, Decl(inferenceContextualReturnTypeUnion2.ts, 24, 17)) |
| 81 | + |
| 82 | +}; |
| 83 | + |
| 84 | +type MapQueries<Q extends Queries = typeof queries> = { |
| 85 | +>MapQueries : Symbol(MapQueries, Decl(inferenceContextualReturnTypeUnion2.ts, 26, 2)) |
| 86 | +>Q : Symbol(Q, Decl(inferenceContextualReturnTypeUnion2.ts, 28, 16)) |
| 87 | +>Queries : Symbol(Queries, Decl(inferenceContextualReturnTypeUnion2.ts, 9, 9)) |
| 88 | +>queries : Symbol(queries, Decl(inferenceContextualReturnTypeUnion2.ts, 24, 5)) |
| 89 | + |
| 90 | + [P in keyof Q]: Q[P]; |
| 91 | +>P : Symbol(P, Decl(inferenceContextualReturnTypeUnion2.ts, 29, 3)) |
| 92 | +>Q : Symbol(Q, Decl(inferenceContextualReturnTypeUnion2.ts, 28, 16)) |
| 93 | +>Q : Symbol(Q, Decl(inferenceContextualReturnTypeUnion2.ts, 28, 16)) |
| 94 | +>P : Symbol(P, Decl(inferenceContextualReturnTypeUnion2.ts, 29, 3)) |
| 95 | + |
| 96 | +}; |
| 97 | + |
0 commit comments