Skip to content

Template literal types and mapped type 'as' clauses #40336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1a6676e
Initial implementation of string template types
ahejlsberg Aug 24, 2020
27d9164
Accept new API baselines
ahejlsberg Aug 24, 2020
0b9c5f5
Accept new baselines
ahejlsberg Aug 24, 2020
815a408
Unified checking for large cross product union types
ahejlsberg Aug 25, 2020
032e1bf
Accept new baselines
ahejlsberg Aug 25, 2020
ced200f
Ensure errors from union type resolution are reported
ahejlsberg Aug 25, 2020
d2ad4c1
Accept new baselines
ahejlsberg Aug 25, 2020
b5b897d
Compute constraints for string template types
ahejlsberg Aug 25, 2020
3b14f3d
Support `as T` clause in mapped types
ahejlsberg Aug 27, 2020
6a8e070
Accept new API baselines
ahejlsberg Aug 27, 2020
a63a442
Add missing semicolon
ahejlsberg Aug 27, 2020
45ea576
Add checking of `as T` clauses
ahejlsberg Aug 28, 2020
05e2ef1
Support casing modifiers in string template types
ahejlsberg Aug 30, 2020
95ac3d4
Accept new baselines
ahejlsberg Aug 31, 2020
c95c000
Bump keyword maximum length
ahejlsberg Aug 31, 2020
b3178d4
fix anders
egamma Sep 1, 2020
8cac241
Revert "fix anders"
egamma Sep 1, 2020
4061ba9
Properly handle 'as T' clause with keyof for mapped type
ahejlsberg Sep 1, 2020
d68670b
Fix lint error
ahejlsberg Sep 2, 2020
b7b58c7
Single character inferences and anchored end span matching
ahejlsberg Sep 3, 2020
b12681d
Fewer array copy operations in template literal type resolution
ahejlsberg Sep 5, 2020
272b23f
Handle cases where 'as T' maps multiple properties onto one
ahejlsberg Sep 6, 2020
3b6e8c2
Fix lint error
ahejlsberg Sep 6, 2020
6dc0b2a
Store key type instead of type mapper in MappedSymbol
ahejlsberg Sep 6, 2020
9c1f9fb
No constraint on `in T` type when `as N` clause present
ahejlsberg Sep 6, 2020
b2518c6
Rename from TemplateType to TemplateLiteralType
ahejlsberg Sep 7, 2020
2d70ca2
Accept new API baselines
ahejlsberg Sep 7, 2020
096d0ae
Add tests
ahejlsberg Sep 7, 2020
1488f35
Accept new baselines
ahejlsberg Sep 7, 2020
66337ed
Merge branch 'master' of https://github.com/microsoft/TypeScript
ahejlsberg Sep 8, 2020
b5e75dd
Merge branch 'master' into templateTypes
ahejlsberg Sep 8, 2020
6c95951
Address CR feedback
ahejlsberg Sep 10, 2020
e81ebb4
Accept new API baselines
ahejlsberg Sep 10, 2020
6bd94b0
Merge branch 'master' of https://github.com/microsoft/TypeScript
ahejlsberg Sep 10, 2020
d38a388
Merge branch 'master' into templateTypes
ahejlsberg Sep 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accept new baselines
  • Loading branch information
ahejlsberg committed Aug 24, 2020
commit 0b9c5f5fb928c54f482d601559f91dfffaae1cd8
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature.
tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,12): error TS1138: Parameter declaration expected.
tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,19): error TS1005: ';' expected.
tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,12): error TS1003: Identifier expected.


==== tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts (4 errors) ====
==== tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts (1 errors) ====
function f(`hello`);
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
~
!!! error TS2394: This overload signature is not compatible with its implementation signature.
!!! related TS2750 tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts:3:10: The implementation signature is declared here.
~~~~~~~
!!! error TS1138: Parameter declaration expected.
~
!!! error TS1005: ';' expected.
!!! error TS1003: Identifier expected.
function f(x: string);
function f(x: string) {
return x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ function f(x: string) {
}

//// [templateStringInFunctionParameterType.js]
function f() { }
"hello";
;
function f(x) {
return x;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
=== tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts ===
function f(`hello`);
>f : Symbol(f, Decl(templateStringInFunctionParameterType.ts, 0, 0), Decl(templateStringInFunctionParameterType.ts, 0, 20), Decl(templateStringInFunctionParameterType.ts, 1, 22))
> : Symbol((Missing), Decl(templateStringInFunctionParameterType.ts, 0, 11))

function f(x: string);
>f : Symbol(f, Decl(templateStringInFunctionParameterType.ts, 0, 0), Decl(templateStringInFunctionParameterType.ts, 0, 20), Decl(templateStringInFunctionParameterType.ts, 1, 22))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
=== tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts ===
function f(`hello`);
>f : { (): any; (x: string): any; }
>`hello` : "hello"
>f : { (: any): any; (x: string): any; }
> : any

function f(x: string);
>f : { (): any; (x: string): any; }
>f : { (: any): any; (x: string): any; }
>x : string

function f(x: string) {
>f : { (): any; (x: string): any; }
>f : { (: any): any; (x: string): any; }
>x : string

return x;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature.
tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,12): error TS1138: Parameter declaration expected.
tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,19): error TS1005: ';' expected.
tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,12): error TS1003: Identifier expected.


==== tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts (4 errors) ====
==== tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts (1 errors) ====
function f(`hello`);
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
~
!!! error TS2394: This overload signature is not compatible with its implementation signature.
!!! related TS2750 tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts:3:10: The implementation signature is declared here.
~~~~~~~
!!! error TS1138: Parameter declaration expected.
~
!!! error TS1005: ';' expected.
!!! error TS1003: Identifier expected.
function f(x: string);
function f(x: string) {
return x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ function f(x: string) {
}

//// [templateStringInFunctionParameterTypeES6.js]
function f() { }
`hello`;
;
function f(x) {
return x;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
=== tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts ===
function f(`hello`);
>f : Symbol(f, Decl(templateStringInFunctionParameterTypeES6.ts, 0, 0), Decl(templateStringInFunctionParameterTypeES6.ts, 0, 20), Decl(templateStringInFunctionParameterTypeES6.ts, 1, 22))
> : Symbol((Missing), Decl(templateStringInFunctionParameterTypeES6.ts, 0, 11))

function f(x: string);
>f : Symbol(f, Decl(templateStringInFunctionParameterTypeES6.ts, 0, 0), Decl(templateStringInFunctionParameterTypeES6.ts, 0, 20), Decl(templateStringInFunctionParameterTypeES6.ts, 1, 22))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
=== tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts ===
function f(`hello`);
>f : { (): any; (x: string): any; }
>`hello` : "hello"
>f : { (: any): any; (x: string): any; }
> : any

function f(x: string);
>f : { (): any; (x: string): any; }
>f : { (: any): any; (x: string): any; }
>x : string

function f(x: string) {
>f : { (): any; (x: string): any; }
>f : { (: any): any; (x: string): any; }
>x : string

return x;
Expand Down