-
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.
Merge pull request #23430 from Microsoft/taggedTemplateTypeArguments
Allow type arguments in generic tagged templates
- Loading branch information
Showing
18 changed files
with
965 additions
and
19 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
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
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
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
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
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
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
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
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
72 changes: 72 additions & 0 deletions
72
tests/baselines/reference/taggedTemplatesWithTypeArguments1.js
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,72 @@ | ||
//// [taggedTemplatesWithTypeArguments1.ts] | ||
declare function f<T>(strs: TemplateStringsArray, ...callbacks: Array<(x: T) => any>): void; | ||
|
||
interface Stuff { | ||
x: number; | ||
y: string; | ||
z: boolean; | ||
} | ||
|
||
export const a = f<Stuff> ` | ||
hello | ||
${stuff => stuff.x} | ||
brave | ||
${stuff => stuff.y} | ||
world | ||
${stuff => stuff.z} | ||
`; | ||
|
||
declare function g<Input, T, U, V>( | ||
strs: TemplateStringsArray, | ||
t: (i: Input) => T, u: (i: Input) => U, v: (i: Input) => V): T | U | V; | ||
|
||
export const b = g<Stuff, number, string, boolean> ` | ||
hello | ||
${stuff => stuff.x} | ||
brave | ||
${stuff => stuff.y} | ||
world | ||
${stuff => stuff.z} | ||
`; | ||
|
||
declare let obj: { | ||
prop: <T>(strs: TemplateStringsArray, x: (input: T) => T) => { | ||
returnedObjProp: T | ||
} | ||
} | ||
|
||
export let c = obj["prop"]<Stuff> `${(input) => ({ ...input })}` | ||
c.returnedObjProp.x; | ||
c.returnedObjProp.y; | ||
c.returnedObjProp.z; | ||
|
||
c = obj.prop<Stuff> `${(input) => ({ ...input })}` | ||
c.returnedObjProp.x; | ||
c.returnedObjProp.y; | ||
c.returnedObjProp.z; | ||
|
||
//// [taggedTemplatesWithTypeArguments1.js] | ||
export const a = f ` | ||
hello | ||
${stuff => stuff.x} | ||
brave | ||
${stuff => stuff.y} | ||
world | ||
${stuff => stuff.z} | ||
`; | ||
export const b = g ` | ||
hello | ||
${stuff => stuff.x} | ||
brave | ||
${stuff => stuff.y} | ||
world | ||
${stuff => stuff.z} | ||
`; | ||
export let c = obj["prop"] `${(input) => ({ ...input })}`; | ||
c.returnedObjProp.x; | ||
c.returnedObjProp.y; | ||
c.returnedObjProp.z; | ||
c = obj.prop `${(input) => ({ ...input })}`; | ||
c.returnedObjProp.x; | ||
c.returnedObjProp.y; | ||
c.returnedObjProp.z; |
Oops, something went wrong.