-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13034 from Microsoft/unionWithNull
Add serialization of typenode for null/undefined/never as part of metadata type
- Loading branch information
Showing
6 changed files
with
399 additions
and
40 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
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,113 @@ | ||
//// [metadataOfUnionWithNull.ts] | ||
function PropDeco(target: Object, propKey: string | symbol) { } | ||
|
||
class A { | ||
} | ||
|
||
class B { | ||
@PropDeco | ||
x: "foo" | null; | ||
|
||
@PropDeco | ||
y: true | never; | ||
|
||
@PropDeco | ||
z: "foo" | undefined; | ||
|
||
@PropDeco | ||
a: null; | ||
|
||
@PropDeco | ||
b: never; | ||
|
||
@PropDeco | ||
c: undefined; | ||
|
||
@PropDeco | ||
d: undefined | null; | ||
|
||
@PropDeco | ||
e: symbol | null; | ||
|
||
@PropDeco | ||
f: symbol | A; | ||
|
||
@PropDeco | ||
g: A | null; | ||
|
||
@PropDeco | ||
h: null | B; | ||
|
||
@PropDeco | ||
j: null | symbol; | ||
} | ||
|
||
//// [metadataOfUnionWithNull.js] | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
function PropDeco(target, propKey) { } | ||
var A = (function () { | ||
function A() { | ||
} | ||
return A; | ||
}()); | ||
var B = (function () { | ||
function B() { | ||
} | ||
return B; | ||
}()); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", String) | ||
], B.prototype, "x"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", Boolean) | ||
], B.prototype, "y"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", String) | ||
], B.prototype, "z"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", void 0) | ||
], B.prototype, "a"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", void 0) | ||
], B.prototype, "b"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", void 0) | ||
], B.prototype, "c"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", void 0) | ||
], B.prototype, "d"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", typeof Symbol === "function" ? Symbol : Object) | ||
], B.prototype, "e"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", Object) | ||
], B.prototype, "f"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", A) | ||
], B.prototype, "g"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", B) | ||
], B.prototype, "h"); | ||
__decorate([ | ||
PropDeco, | ||
__metadata("design:type", typeof Symbol === "function" ? Symbol : Object) | ||
], B.prototype, "j"); |
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,89 @@ | ||
=== tests/cases/compiler/metadataOfUnionWithNull.ts === | ||
function PropDeco(target: Object, propKey: string | symbol) { } | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
>target : Symbol(target, Decl(metadataOfUnionWithNull.ts, 0, 18)) | ||
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) | ||
>propKey : Symbol(propKey, Decl(metadataOfUnionWithNull.ts, 0, 33)) | ||
|
||
class A { | ||
>A : Symbol(A, Decl(metadataOfUnionWithNull.ts, 0, 63)) | ||
} | ||
|
||
class B { | ||
>B : Symbol(B, Decl(metadataOfUnionWithNull.ts, 3, 1)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
x: "foo" | null; | ||
>x : Symbol(B.x, Decl(metadataOfUnionWithNull.ts, 5, 9)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
y: true | never; | ||
>y : Symbol(B.y, Decl(metadataOfUnionWithNull.ts, 7, 20)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
z: "foo" | undefined; | ||
>z : Symbol(B.z, Decl(metadataOfUnionWithNull.ts, 10, 20)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
a: null; | ||
>a : Symbol(B.a, Decl(metadataOfUnionWithNull.ts, 13, 25)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
b: never; | ||
>b : Symbol(B.b, Decl(metadataOfUnionWithNull.ts, 16, 12)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
c: undefined; | ||
>c : Symbol(B.c, Decl(metadataOfUnionWithNull.ts, 19, 13)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
d: undefined | null; | ||
>d : Symbol(B.d, Decl(metadataOfUnionWithNull.ts, 22, 17)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
e: symbol | null; | ||
>e : Symbol(B.e, Decl(metadataOfUnionWithNull.ts, 25, 24)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
f: symbol | A; | ||
>f : Symbol(B.f, Decl(metadataOfUnionWithNull.ts, 28, 21)) | ||
>A : Symbol(A, Decl(metadataOfUnionWithNull.ts, 0, 63)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
g: A | null; | ||
>g : Symbol(B.g, Decl(metadataOfUnionWithNull.ts, 31, 18)) | ||
>A : Symbol(A, Decl(metadataOfUnionWithNull.ts, 0, 63)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
h: null | B; | ||
>h : Symbol(B.h, Decl(metadataOfUnionWithNull.ts, 34, 16)) | ||
>B : Symbol(B, Decl(metadataOfUnionWithNull.ts, 3, 1)) | ||
|
||
@PropDeco | ||
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) | ||
|
||
j: null | symbol; | ||
>j : Symbol(B.j, Decl(metadataOfUnionWithNull.ts, 37, 16)) | ||
} |
Oops, something went wrong.