Skip to content

Commit cc8764f

Browse files
committed
Revert "Remove lib change"
This reverts commit 2cd6752.
1 parent a35bd7e commit cc8764f

5 files changed

+137
-107
lines changed

src/harness/fourslash.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4672,7 +4672,7 @@ namespace FourSlashInterface {
46724672
typeEntry("ReturnType"),
46734673
typeEntry("InstanceType"),
46744674
interfaceEntry("ThisType"),
4675-
// typeEntry("Tag"),
4675+
typeEntry("Tag"),
46764676
varEntry("ArrayBuffer"),
46774677
interfaceEntry("ArrayBufferTypes"),
46784678
typeEntry("ArrayBufferLike"),

src/lib/es5.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1481,9 +1481,9 @@ interface ThisType<T> { }
14811481
/**
14821482
* Constructs a structural tag over property name(s) `K`
14831483
*/
1484-
// type Tag<K extends keyof any> = tag {
1485-
// [_ in K]: void;
1486-
// };
1484+
type Tag<K extends keyof any> = tag {
1485+
[_ in K]: void;
1486+
};
14871487

14881488
/**
14891489
* Represents a raw buffer of binary data, which is used to store data for the

tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt

+39-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(2,17): error TS2304: Cannot find name 'Tag'.
2-
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(3,17): error TS2304: Cannot find name 'Tag'.
3-
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(31,32): error TS2304: Cannot find name 'Tag'.
4-
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(32,30): error TS2304: Cannot find name 'Tag'.
1+
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(53,29): error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'AbsolutePath'.
2+
Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'.
3+
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(55,39): error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'NormalizedAbsolutePath'.
4+
Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
5+
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(60,31): error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedPath'.
6+
Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'.
7+
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(63,39): error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedAbsolutePath'.
8+
Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
9+
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(66,31): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'.
10+
Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'.
11+
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(67,29): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'.
12+
Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'.
13+
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(68,41): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'.
14+
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(69,39): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'.
15+
Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
516

617

7-
==== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts (4 errors) ====
18+
==== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts (8 errors) ====
819
export type Paired = {
920
x: number & Tag<"x">;
10-
~~~
11-
!!! error TS2304: Cannot find name 'Tag'.
1221
y: number & Tag<"y">;
13-
~~~
14-
!!! error TS2304: Cannot find name 'Tag'.
1522
};
1623

1724

@@ -40,11 +47,7 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAli
4047

4148

4249
type NormalizedPath = string & Tag<"NormalizedPath">;
43-
~~~
44-
!!! error TS2304: Cannot find name 'Tag'.
4550
type AbsolutePath = string & Tag<"AbsolutePath">;
46-
~~~
47-
!!! error TS2304: Cannot find name 'Tag'.
4851
type NormalizedAbsolutePath = NormalizedPath & AbsolutePath;
4952

5053
declare function isNormalizedPath(x: string): x is NormalizedPath;
@@ -66,22 +69,45 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAli
6669
else {
6770
consumeNormalizedPath(p);
6871
consumeAbsolutePath(p); // err
72+
~
73+
!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'AbsolutePath'.
74+
!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'.
6975
consumeNormalizedOrAbsolutePath(p);
7076
consumeNormalizedAbsolutePath(p); // err
77+
~
78+
!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'NormalizedAbsolutePath'.
79+
!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
7180
}
7281
}
7382
else {
7483
if (isAbsolutePath(p)) {
7584
consumeNormalizedPath(p); // err
85+
~
86+
!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedPath'.
87+
!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'.
7688
consumeAbsolutePath(p);
7789
consumeNormalizedOrAbsolutePath(p);
7890
consumeNormalizedAbsolutePath(p); // err
91+
~
92+
!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedAbsolutePath'.
93+
!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
7994
}
8095
else {
8196
consumeNormalizedPath(p); // err
97+
~
98+
!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'.
99+
!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'.
82100
consumeAbsolutePath(p); // err
101+
~
102+
!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'.
103+
!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'.
83104
consumeNormalizedOrAbsolutePath(p); // err
105+
~
106+
!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'.
84107
consumeNormalizedAbsolutePath(p); // err
108+
~
109+
!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'.
110+
!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
85111
}
86112
}
87113

tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols

+12-8
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ export type Paired = {
44

55
x: number & Tag<"x">;
66
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
7+
>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --))
78

89
y: number & Tag<"y">;
910
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
11+
>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --))
1012

1113
};
1214

@@ -70,17 +72,17 @@ if (isPaired(b)) {
7072
>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5))
7173

7274
b.x = a.x;
73-
>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11))
75+
>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
7476
>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5))
75-
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11))
77+
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
7678
>a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
7779
>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5))
7880
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
7981

8082
b.y = a.y;
81-
>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16))
83+
>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
8284
>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5))
83-
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16))
85+
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
8486
>a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
8587
>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5))
8688
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
@@ -89,25 +91,27 @@ if (isPaired(b)) {
8991
>a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
9092
>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5))
9193
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
92-
>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11))
94+
>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
9395
>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5))
94-
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11))
96+
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
9597

9698
a.y = b.y;
9799
>a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
98100
>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5))
99101
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
100-
>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16))
102+
>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
101103
>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5))
102-
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16))
104+
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
103105
}
104106

105107

106108
type NormalizedPath = string & Tag<"NormalizedPath">;
107109
>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 27, 1))
110+
>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --))
108111

109112
type AbsolutePath = string & Tag<"AbsolutePath">;
110113
>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 30, 53))
114+
>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --))
111115

112116
type NormalizedAbsolutePath = NormalizedPath & AbsolutePath;
113117
>NormalizedAbsolutePath : Symbol(NormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 31, 49))

0 commit comments

Comments
 (0)