File tree Expand file tree Collapse file tree 5 files changed +18
-21
lines changed
tests/baselines/reference Expand file tree Collapse file tree 5 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ type OriginA1 = `${A}`
18
18
>OriginA1 : "a"
19
19
20
20
type OriginA2 = `${MixA}`
21
- >OriginA2 : `${MixA}`
21
+ >OriginA2 : "a"
22
22
23
23
type B = `${typeof a}`
24
24
>B : "a"
@@ -32,23 +32,23 @@ type OriginB1 = `${B}`
32
32
>OriginB1 : "a"
33
33
34
34
type OriginB2 = `${MixB}`
35
- >OriginB2 : `${MixB}`
35
+ >OriginB2 : "a"
36
36
37
37
type MixC = { foo: string } & A
38
38
>MixC : { foo: string; } & "a"
39
39
>foo : string
40
40
41
41
type OriginC = `${MixC}`
42
- >OriginC : `${MixC}`
42
+ >OriginC : "a"
43
43
44
44
type MixD<T extends string> =
45
- >MixD : `${T & { foo: string; } }`
45
+ >MixD : `${T}`
46
46
47
47
`${T & { foo: string }}`
48
48
>foo : string
49
49
50
50
type OriginD = `${MixD<A & { foo: string }> & { foo: string }}`;
51
- >OriginD : `${`${ "a" & { foo: string; } & { foo: string; }}` & { foo: string; }}`
51
+ >OriginD : "a"
52
52
>foo : string
53
53
>foo : string
54
54
Original file line number Diff line number Diff line change 1
- templateLiteralIntersection2.ts(7,12): error TS2345: Argument of type '"foo/bar"' is not assignable to parameter of type '`${Path}/${Path}`'.
2
1
templateLiteralIntersection2.ts(20,10): error TS2345: Argument of type '""' is not assignable to parameter of type '`a${string}` & `${string}a`'.
3
2
Type '""' is not assignable to type '`a${string}`'.
4
3
templateLiteralIntersection2.ts(22,10): error TS2345: Argument of type '"ab"' is not assignable to parameter of type '`a${string}` & `${string}a`'.
5
4
Type '"ab"' is not assignable to type '`${string}a`'.
6
5
7
6
8
- ==== templateLiteralIntersection2.ts (3 errors) ====
7
+ ==== templateLiteralIntersection2.ts (2 errors) ====
9
8
type Path = string & { _pathBrand: any };
10
9
11
10
type JoinedPath = `${Path}/${Path}`;
12
11
13
12
declare function joinedPath(p: JoinedPath): void;
14
13
15
14
joinedPath("foo/bar");
16
- ~~~~~~~~~
17
- !!! error TS2345: Argument of type '"foo/bar"' is not assignable to parameter of type '`${Path}/${Path}`'.
18
15
19
16
declare const somePath: Path;
20
17
Original file line number Diff line number Diff line change @@ -6,24 +6,24 @@ type Path = string & { _pathBrand: any };
6
6
>_pathBrand : any
7
7
8
8
type JoinedPath = `${Path}/${Path}`;
9
- >JoinedPath : `${Path }/${Path }`
9
+ >JoinedPath : `${string }/${string }`
10
10
11
11
declare function joinedPath(p: JoinedPath): void;
12
12
>joinedPath : (p: JoinedPath) => void
13
- >p : `${Path }/${Path }`
13
+ >p : `${string }/${string }`
14
14
15
15
joinedPath("foo/bar");
16
16
>joinedPath("foo/bar") : void
17
- >joinedPath : (p: `${Path }/${Path }`) => void
17
+ >joinedPath : (p: `${string }/${string }`) => void
18
18
>"foo/bar" : "foo/bar"
19
19
20
20
declare const somePath: Path;
21
21
>somePath : Path
22
22
23
23
joinedPath(`${somePath}/${somePath}`);
24
24
>joinedPath(`${somePath}/${somePath}`) : void
25
- >joinedPath : (p: `${Path }/${Path }`) => void
26
- >`${somePath}/${somePath}` : `${Path }/${Path }`
25
+ >joinedPath : (p: `${string }/${string }`) => void
26
+ >`${somePath}/${somePath}` : `${string }/${string }`
27
27
>somePath : Path
28
28
>somePath : Path
29
29
Original file line number Diff line number Diff line change @@ -24,19 +24,19 @@ options1[`foo/${path}`] = false;
24
24
>options1[`foo/${path}`] = false : false
25
25
>options1[`foo/${path}`] : boolean
26
26
>options1 : { prop: number; } & { [k: string]: boolean; }
27
- >`foo/${path}` : `foo/${Path }`
27
+ >`foo/${path}` : `foo/${string }`
28
28
>path : Path
29
29
>false : false
30
30
31
31
32
32
// Lowercase<`foo/${Path}`> => `foo/${Lowercase<Path>}`
33
33
declare const lowercasePath: Lowercase<`foo/${Path}`>;
34
- >lowercasePath : `foo/${Lowercase<`${Path}` >}`
34
+ >lowercasePath : `foo/${Lowercase<string >}`
35
35
36
36
options1[lowercasePath] = false;
37
37
>options1[lowercasePath] = false : false
38
38
>options1[lowercasePath] : boolean
39
39
>options1 : { prop: number; } & { [k: string]: boolean; }
40
- >lowercasePath : `foo/${Lowercase<`${Path}` >}`
40
+ >lowercasePath : `foo/${Lowercase<string >}`
41
41
>false : false
42
42
Original file line number Diff line number Diff line change @@ -656,20 +656,20 @@ conversionTest2("testDowncast");
656
656
657
657
function conversionTest3(groupName: | "downcast" | "dataDowncast" | "editingDowncast" | `${string & {}}Downcast`) {}
658
658
>conversionTest3 : (groupName: "downcast" | "dataDowncast" | "editingDowncast" | `${string & {}}Downcast`) => void
659
- >groupName : "downcast" | `${string & {}} Downcast`
659
+ >groupName : `${string} Downcast` | "downcast"
660
660
661
661
conversionTest3("testDowncast");
662
662
>conversionTest3("testDowncast") : void
663
- >conversionTest3 : (groupName: "downcast" | `${string & {}} Downcast`) => void
663
+ >conversionTest3 : (groupName: `${string} Downcast` | "downcast" ) => void
664
664
>"testDowncast" : "testDowncast"
665
665
666
666
function conversionTest4(groupName: | "downcast" | "dataDowncast" | "editingDowncast" | `${{} & string}Downcast`) {}
667
667
>conversionTest4 : (groupName: "downcast" | "dataDowncast" | "editingDowncast" | `${{} & string}Downcast`) => void
668
- >groupName : "downcast" | `${{} & string}Downcast`
668
+ >groupName : `${string}Downcast` | "downcast"
669
669
670
670
conversionTest4("testDowncast");
671
671
>conversionTest4("testDowncast") : void
672
- >conversionTest4 : (groupName: "downcast" | `${{} & string}Downcast`) => void
672
+ >conversionTest4 : (groupName: `${string}Downcast` | "downcast" ) => void
673
673
>"testDowncast" : "testDowncast"
674
674
675
675
function foo(str: `${`a${string}` & `${string}a`}Test`) {}
You can’t perform that action at this time.
0 commit comments