Skip to content

Commit

Permalink
Revert "Remove lib change"
Browse files Browse the repository at this point in the history
This reverts commit 2cd6752.
  • Loading branch information
weswigham committed Sep 18, 2019
1 parent a35bd7e commit cc8764f
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 107 deletions.
2 changes: 1 addition & 1 deletion src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4672,7 +4672,7 @@ namespace FourSlashInterface {
typeEntry("ReturnType"),
typeEntry("InstanceType"),
interfaceEntry("ThisType"),
// typeEntry("Tag"),
typeEntry("Tag"),
varEntry("ArrayBuffer"),
interfaceEntry("ArrayBufferTypes"),
typeEntry("ArrayBufferLike"),
Expand Down
6 changes: 3 additions & 3 deletions src/lib/es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1481,9 +1481,9 @@ interface ThisType<T> { }
/**
* Constructs a structural tag over property name(s) `K`
*/
// type Tag<K extends keyof any> = tag {
// [_ in K]: void;
// };
type Tag<K extends keyof any> = tag {
[_ in K]: void;
};

/**
* Represents a raw buffer of binary data, which is used to store data for the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(2,17): error TS2304: Cannot find name 'Tag'.
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(3,17): error TS2304: Cannot find name 'Tag'.
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(31,32): error TS2304: Cannot find name 'Tag'.
tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(32,30): error TS2304: Cannot find name 'Tag'.
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'.
Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'.
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'.
Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
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'.
Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'.
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'.
Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
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'.
Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'.
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'.
Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'.
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'.
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'.
Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.


==== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts (4 errors) ====
==== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts (8 errors) ====
export type Paired = {
x: number & Tag<"x">;
~~~
!!! error TS2304: Cannot find name 'Tag'.
y: number & Tag<"y">;
~~~
!!! error TS2304: Cannot find name 'Tag'.
};


Expand Down Expand Up @@ -40,11 +47,7 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAli


type NormalizedPath = string & Tag<"NormalizedPath">;
~~~
!!! error TS2304: Cannot find name 'Tag'.
type AbsolutePath = string & Tag<"AbsolutePath">;
~~~
!!! error TS2304: Cannot find name 'Tag'.
type NormalizedAbsolutePath = NormalizedPath & AbsolutePath;

declare function isNormalizedPath(x: string): x is NormalizedPath;
Expand All @@ -66,22 +69,45 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAli
else {
consumeNormalizedPath(p);
consumeAbsolutePath(p); // err
~
!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'AbsolutePath'.
!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'.
consumeNormalizedOrAbsolutePath(p);
consumeNormalizedAbsolutePath(p); // err
~
!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'NormalizedAbsolutePath'.
!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
}
}
else {
if (isAbsolutePath(p)) {
consumeNormalizedPath(p); // err
~
!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedPath'.
!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'.
consumeAbsolutePath(p);
consumeNormalizedOrAbsolutePath(p);
consumeNormalizedAbsolutePath(p); // err
~
!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedAbsolutePath'.
!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
}
else {
consumeNormalizedPath(p); // err
~
!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'.
!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'.
consumeAbsolutePath(p); // err
~
!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'.
!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'.
consumeNormalizedOrAbsolutePath(p); // err
~
!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'.
consumeNormalizedAbsolutePath(p); // err
~
!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'.
!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'.
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ export type Paired = {

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

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

};

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

b.x = a.x;
>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11))
>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5))
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11))
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
>a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5))
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))

b.y = a.y;
>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16))
>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5))
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16))
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
>a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5))
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
Expand All @@ -89,25 +91,27 @@ if (isPaired(b)) {
>a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5))
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11))
>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))
>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5))
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11))
>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22))

a.y = b.y;
>a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5))
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16))
>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5))
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16))
>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25))
}


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

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

type NormalizedAbsolutePath = NormalizedPath & AbsolutePath;
>NormalizedAbsolutePath : Symbol(NormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 31, 49))
Expand Down
Loading

0 comments on commit cc8764f

Please sign in to comment.