mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
parent
5542e396d7
commit
5f78d39662
@ -4939,63 +4939,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitSerializedTypeNode(node: TypeNode) {
|
||||
if (!node) {
|
||||
return;
|
||||
if (node) {
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.VoidKeyword:
|
||||
write("void 0");
|
||||
return;
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
emitSerializedTypeNode((<ParenthesizedTypeNode>node).type);
|
||||
return;
|
||||
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
write("Function");
|
||||
return;
|
||||
|
||||
case SyntaxKind.ArrayType:
|
||||
case SyntaxKind.TupleType:
|
||||
write("Array");
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypePredicate:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
write("Boolean");
|
||||
return;
|
||||
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.StringLiteral:
|
||||
write("String");
|
||||
return;
|
||||
|
||||
case SyntaxKind.NumberKeyword:
|
||||
write("Number");
|
||||
return;
|
||||
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
write("Symbol");
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypeReference:
|
||||
emitSerializedTypeReferenceNode(<TypeReferenceNode>node);
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail("Cannot serialize unexpected type node.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.VoidKeyword:
|
||||
write("void 0");
|
||||
return;
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
emitSerializedTypeNode((<ParenthesizedTypeNode>node).type);
|
||||
return;
|
||||
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
write("Function");
|
||||
return;
|
||||
|
||||
case SyntaxKind.ArrayType:
|
||||
case SyntaxKind.TupleType:
|
||||
write("Array");
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypePredicate:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
write("Boolean");
|
||||
return;
|
||||
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.StringLiteral:
|
||||
write("String");
|
||||
return;
|
||||
|
||||
case SyntaxKind.NumberKeyword:
|
||||
write("Number");
|
||||
return;
|
||||
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
write("Symbol");
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypeReference:
|
||||
emitSerializedTypeReferenceNode(<TypeReferenceNode>node);
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail("Cannot serialize unexpected type node.");
|
||||
break;
|
||||
}
|
||||
|
||||
write("Object");
|
||||
}
|
||||
|
||||
|
||||
39
tests/baselines/reference/decoratorMetadataOnInferredType.js
Normal file
39
tests/baselines/reference/decoratorMetadataOnInferredType.js
Normal file
@ -0,0 +1,39 @@
|
||||
//// [decoratorMetadataOnInferredType.ts]
|
||||
|
||||
declare var console: {
|
||||
log(msg: string): void;
|
||||
};
|
||||
|
||||
class A {
|
||||
constructor() { console.log('new A'); }
|
||||
}
|
||||
|
||||
function decorator(target: Object, propertyKey: string) {
|
||||
}
|
||||
|
||||
export class B {
|
||||
@decorator
|
||||
x = new A();
|
||||
}
|
||||
|
||||
|
||||
//// [decoratorMetadataOnInferredType.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
console.log('new A');
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
function decorator(target, propertyKey) {
|
||||
}
|
||||
var B = (function () {
|
||||
function B() {
|
||||
this.x = new A();
|
||||
}
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata('design:type', Object)
|
||||
], B.prototype, "x");
|
||||
return B;
|
||||
})();
|
||||
exports.B = B;
|
||||
@ -0,0 +1,38 @@
|
||||
=== tests/cases/compiler/decoratorMetadataOnInferredType.ts ===
|
||||
|
||||
declare var console: {
|
||||
>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11))
|
||||
|
||||
log(msg: string): void;
|
||||
>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22))
|
||||
>msg : Symbol(msg, Decl(decoratorMetadataOnInferredType.ts, 2, 8))
|
||||
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2))
|
||||
|
||||
constructor() { console.log('new A'); }
|
||||
>console.log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22))
|
||||
>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11))
|
||||
>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22))
|
||||
}
|
||||
|
||||
function decorator(target: Object, propertyKey: string) {
|
||||
>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1))
|
||||
>target : Symbol(target, Decl(decoratorMetadataOnInferredType.ts, 9, 19))
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
|
||||
>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataOnInferredType.ts, 9, 34))
|
||||
}
|
||||
|
||||
export class B {
|
||||
>B : Symbol(B, Decl(decoratorMetadataOnInferredType.ts, 10, 1))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1))
|
||||
|
||||
x = new A();
|
||||
>x : Symbol(x, Decl(decoratorMetadataOnInferredType.ts, 12, 16))
|
||||
>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2))
|
||||
}
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
=== tests/cases/compiler/decoratorMetadataOnInferredType.ts ===
|
||||
|
||||
declare var console: {
|
||||
>console : { log(msg: string): void; }
|
||||
|
||||
log(msg: string): void;
|
||||
>log : (msg: string) => void
|
||||
>msg : string
|
||||
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
constructor() { console.log('new A'); }
|
||||
>console.log('new A') : void
|
||||
>console.log : (msg: string) => void
|
||||
>console : { log(msg: string): void; }
|
||||
>log : (msg: string) => void
|
||||
>'new A' : string
|
||||
}
|
||||
|
||||
function decorator(target: Object, propertyKey: string) {
|
||||
>decorator : (target: Object, propertyKey: string) => void
|
||||
>target : Object
|
||||
>Object : Object
|
||||
>propertyKey : string
|
||||
}
|
||||
|
||||
export class B {
|
||||
>B : B
|
||||
|
||||
@decorator
|
||||
>decorator : (target: Object, propertyKey: string) => void
|
||||
|
||||
x = new A();
|
||||
>x : A
|
||||
>new A() : A
|
||||
>A : typeof A
|
||||
}
|
||||
|
||||
21
tests/cases/compiler/decoratorMetadataOnInferredType.ts
Normal file
21
tests/cases/compiler/decoratorMetadataOnInferredType.ts
Normal file
@ -0,0 +1,21 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
|
||||
declare var console: {
|
||||
log(msg: string): void;
|
||||
};
|
||||
|
||||
class A {
|
||||
constructor() { console.log('new A'); }
|
||||
}
|
||||
|
||||
function decorator(target: Object, propertyKey: string) {
|
||||
}
|
||||
|
||||
export class B {
|
||||
@decorator
|
||||
x = new A();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user