-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat primitive and object Intersection Type inside TemplateLiteral a…
…s primitive
- Loading branch information
1 parent
34ea32f
commit da3fbd7
Showing
7 changed files
with
268 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
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,35 @@ | ||
//// [tests/cases/compiler/brandedLiteralRevert1.ts] //// | ||
|
||
=== brandedLiteralRevert1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60990 | ||
|
||
type N0 = number & { | ||
>N0 : Symbol(N0, Decl(brandedLiteralRevert1.ts, 0, 0)) | ||
|
||
test: "TEST" | ||
>test : Symbol(test, Decl(brandedLiteralRevert1.ts, 2, 20)) | ||
} | ||
|
||
type N1 = 3 & { | ||
>N1 : Symbol(N1, Decl(brandedLiteralRevert1.ts, 4, 1)) | ||
|
||
test: "TEST" | ||
>test : Symbol(test, Decl(brandedLiteralRevert1.ts, 6, 15)) | ||
} | ||
|
||
declare let n0: N0 | ||
>n0 : Symbol(n0, Decl(brandedLiteralRevert1.ts, 10, 11)) | ||
>N0 : Symbol(N0, Decl(brandedLiteralRevert1.ts, 0, 0)) | ||
|
||
declare let n1: N1 | ||
>n1 : Symbol(n1, Decl(brandedLiteralRevert1.ts, 11, 11)) | ||
>N1 : Symbol(N1, Decl(brandedLiteralRevert1.ts, 4, 1)) | ||
|
||
let m0: `${number}` = `${n0}` // ok | ||
>m0 : Symbol(m0, Decl(brandedLiteralRevert1.ts, 13, 3)) | ||
>n0 : Symbol(n0, Decl(brandedLiteralRevert1.ts, 10, 11)) | ||
|
||
let m1: "3" = `${n1}` // ok | ||
>m1 : Symbol(m1, Decl(brandedLiteralRevert1.ts, 14, 3)) | ||
>n1 : Symbol(n1, Decl(brandedLiteralRevert1.ts, 11, 11)) | ||
|
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,47 @@ | ||
//// [tests/cases/compiler/brandedLiteralRevert1.ts] //// | ||
|
||
=== brandedLiteralRevert1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60990 | ||
|
||
type N0 = number & { | ||
>N0 : N0 | ||
> : ^^ | ||
|
||
test: "TEST" | ||
>test : "TEST" | ||
> : ^^^^^^ | ||
} | ||
|
||
type N1 = 3 & { | ||
>N1 : N1 | ||
> : ^^ | ||
|
||
test: "TEST" | ||
>test : "TEST" | ||
> : ^^^^^^ | ||
} | ||
|
||
declare let n0: N0 | ||
>n0 : N0 | ||
> : ^^ | ||
|
||
declare let n1: N1 | ||
>n1 : N1 | ||
> : ^^ | ||
|
||
let m0: `${number}` = `${n0}` // ok | ||
>m0 : `${number}` | ||
> : ^^^^^^^^^^^ | ||
>`${n0}` : `${number}` | ||
> : ^^^^^^^^^^^ | ||
>n0 : N0 | ||
> : ^^ | ||
|
||
let m1: "3" = `${n1}` // ok | ||
>m1 : "3" | ||
> : ^^^ | ||
>`${n1}` : `${3}` | ||
> : ^^^^^^ | ||
>n1 : N1 | ||
> : ^^ | ||
|
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,50 @@ | ||
//// [tests/cases/compiler/brandedLiteralRevert2.ts] //// | ||
|
||
=== brandedLiteralRevert2.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60990 | ||
|
||
type Brand1 = number & 1 & { | ||
>Brand1 : Symbol(Brand1, Decl(brandedLiteralRevert2.ts, 0, 0)) | ||
|
||
test: "TEST" | ||
>test : Symbol(test, Decl(brandedLiteralRevert2.ts, 2, 28)) | ||
} | ||
|
||
type Brand2 = "a" & { | ||
>Brand2 : Symbol(Brand2, Decl(brandedLiteralRevert2.ts, 4, 1)) | ||
|
||
test: "TEST1" | ||
>test : Symbol(test, Decl(brandedLiteralRevert2.ts, 6, 21)) | ||
} | ||
|
||
let brandN1: Brand1 = 1 as Brand1 | ||
>brandN1 : Symbol(brandN1, Decl(brandedLiteralRevert2.ts, 10, 3)) | ||
>Brand1 : Symbol(Brand1, Decl(brandedLiteralRevert2.ts, 0, 0)) | ||
>Brand1 : Symbol(Brand1, Decl(brandedLiteralRevert2.ts, 0, 0)) | ||
|
||
let brandN2: Brand2 = "a" as Brand2 | ||
>brandN2 : Symbol(brandN2, Decl(brandedLiteralRevert2.ts, 11, 3)) | ||
>Brand2 : Symbol(Brand2, Decl(brandedLiteralRevert2.ts, 4, 1)) | ||
>Brand2 : Symbol(Brand2, Decl(brandedLiteralRevert2.ts, 4, 1)) | ||
|
||
let brandM11: `${number}` = `${brandN1}` // ok | ||
>brandM11 : Symbol(brandM11, Decl(brandedLiteralRevert2.ts, 13, 3)) | ||
>brandN1 : Symbol(brandN1, Decl(brandedLiteralRevert2.ts, 10, 3)) | ||
|
||
let brandM12: "1" = `${brandN1}` // ok | ||
>brandM12 : Symbol(brandM12, Decl(brandedLiteralRevert2.ts, 14, 3)) | ||
>brandN1 : Symbol(brandN1, Decl(brandedLiteralRevert2.ts, 10, 3)) | ||
|
||
let brandM13: `${1}` = `${brandN1}` // ok | ||
>brandM13 : Symbol(brandM13, Decl(brandedLiteralRevert2.ts, 15, 3)) | ||
>brandN1 : Symbol(brandN1, Decl(brandedLiteralRevert2.ts, 10, 3)) | ||
|
||
let brandM21: "a" = `${brandN2}` // ok | ||
>brandM21 : Symbol(brandM21, Decl(brandedLiteralRevert2.ts, 17, 3)) | ||
>brandN2 : Symbol(brandN2, Decl(brandedLiteralRevert2.ts, 11, 3)) | ||
|
||
let brandM22: "1a" = `${brandN1}${brandN2}` // ok | ||
>brandM22 : Symbol(brandM22, Decl(brandedLiteralRevert2.ts, 18, 3)) | ||
>brandN1 : Symbol(brandN1, Decl(brandedLiteralRevert2.ts, 10, 3)) | ||
>brandN2 : Symbol(brandN2, Decl(brandedLiteralRevert2.ts, 11, 3)) | ||
|
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,81 @@ | ||
//// [tests/cases/compiler/brandedLiteralRevert2.ts] //// | ||
|
||
=== brandedLiteralRevert2.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60990 | ||
|
||
type Brand1 = number & 1 & { | ||
>Brand1 : Brand1 | ||
> : ^^^^^^ | ||
|
||
test: "TEST" | ||
>test : "TEST" | ||
> : ^^^^^^ | ||
} | ||
|
||
type Brand2 = "a" & { | ||
>Brand2 : Brand2 | ||
> : ^^^^^^ | ||
|
||
test: "TEST1" | ||
>test : "TEST1" | ||
> : ^^^^^^^ | ||
} | ||
|
||
let brandN1: Brand1 = 1 as Brand1 | ||
>brandN1 : Brand1 | ||
> : ^^^^^^ | ||
>1 as Brand1 : Brand1 | ||
> : ^^^^^^ | ||
>1 : 1 | ||
> : ^ | ||
|
||
let brandN2: Brand2 = "a" as Brand2 | ||
>brandN2 : Brand2 | ||
> : ^^^^^^ | ||
>"a" as Brand2 : Brand2 | ||
> : ^^^^^^ | ||
>"a" : "a" | ||
> : ^^^ | ||
|
||
let brandM11: `${number}` = `${brandN1}` // ok | ||
>brandM11 : `${number}` | ||
> : ^^^^^^^^^^^ | ||
>`${brandN1}` : `${1}` | ||
> : ^^^^^^ | ||
>brandN1 : Brand1 | ||
> : ^^^^^^ | ||
|
||
let brandM12: "1" = `${brandN1}` // ok | ||
>brandM12 : "1" | ||
> : ^^^ | ||
>`${brandN1}` : `${1}` | ||
> : ^^^^^^ | ||
>brandN1 : Brand1 | ||
> : ^^^^^^ | ||
|
||
let brandM13: `${1}` = `${brandN1}` // ok | ||
>brandM13 : "1" | ||
> : ^^^ | ||
>`${brandN1}` : `${1}` | ||
> : ^^^^^^ | ||
>brandN1 : Brand1 | ||
> : ^^^^^^ | ||
|
||
let brandM21: "a" = `${brandN2}` // ok | ||
>brandM21 : "a" | ||
> : ^^^ | ||
>`${brandN2}` : `${"a"}` | ||
> : ^^^^^^^^ | ||
>brandN2 : Brand2 | ||
> : ^^^^^^ | ||
|
||
let brandM22: "1a" = `${brandN1}${brandN2}` // ok | ||
>brandM22 : "1a" | ||
> : ^^^^ | ||
>`${brandN1}${brandN2}` : `${1}${"a"}` | ||
> : ^^^^^^^^^^^^ | ||
>brandN1 : Brand1 | ||
> : ^^^^^^ | ||
>brandN2 : Brand2 | ||
> : ^^^^^^ | ||
|
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,18 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/60990 | ||
|
||
type N0 = number & { | ||
test: "TEST" | ||
} | ||
|
||
type N1 = 3 & { | ||
test: "TEST" | ||
} | ||
|
||
declare let n0: N0 | ||
declare let n1: N1 | ||
|
||
let m0: `${number}` = `${n0}` // ok | ||
let m1: "3" = `${n1}` // ok |
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,22 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/60990 | ||
|
||
type Brand1 = number & 1 & { | ||
test: "TEST" | ||
} | ||
|
||
type Brand2 = "a" & { | ||
test: "TEST1" | ||
} | ||
|
||
let brandN1: Brand1 = 1 as Brand1 | ||
let brandN2: Brand2 = "a" as Brand2 | ||
|
||
let brandM11: `${number}` = `${brandN1}` // ok | ||
let brandM12: "1" = `${brandN1}` // ok | ||
let brandM13: `${1}` = `${brandN1}` // ok | ||
|
||
let brandM21: "a" = `${brandN2}` // ok | ||
let brandM22: "1a" = `${brandN1}${brandN2}` // ok |