mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Instead of writing text from source file use text property to write text of synthesized node
Fixes #4364
This commit is contained in:
parent
2ed9bdbfb8
commit
060dbd24f4
@ -1519,7 +1519,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
return;
|
||||
}
|
||||
}
|
||||
writeTextOfNode(currentSourceFile, node);
|
||||
|
||||
if (nodeIsSynthesized(node)) {
|
||||
write(node.text);
|
||||
}
|
||||
else {
|
||||
writeTextOfNode(currentSourceFile, node);
|
||||
}
|
||||
}
|
||||
|
||||
function isNameOfNestedRedeclaration(node: Identifier) {
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
//// [decoratorMetadataWithConstructorType.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: A = new A();
|
||||
}
|
||||
|
||||
|
||||
//// [decoratorMetadataWithConstructorType.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', A)
|
||||
], B.prototype, "x");
|
||||
return B;
|
||||
})();
|
||||
exports.B = B;
|
||||
@ -0,0 +1,39 @@
|
||||
=== tests/cases/compiler/decoratorMetadataWithConstructorType.ts ===
|
||||
|
||||
declare var console: {
|
||||
>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11))
|
||||
|
||||
log(msg: string): void;
|
||||
>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22))
|
||||
>msg : Symbol(msg, Decl(decoratorMetadataWithConstructorType.ts, 2, 8))
|
||||
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2))
|
||||
|
||||
constructor() { console.log('new A'); }
|
||||
>console.log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22))
|
||||
>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11))
|
||||
>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22))
|
||||
}
|
||||
|
||||
function decorator(target: Object, propertyKey: string) {
|
||||
>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1))
|
||||
>target : Symbol(target, Decl(decoratorMetadataWithConstructorType.ts, 9, 19))
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
|
||||
>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataWithConstructorType.ts, 9, 34))
|
||||
}
|
||||
|
||||
export class B {
|
||||
>B : Symbol(B, Decl(decoratorMetadataWithConstructorType.ts, 10, 1))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1))
|
||||
|
||||
x: A = new A();
|
||||
>x : Symbol(x, Decl(decoratorMetadataWithConstructorType.ts, 12, 16))
|
||||
>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2))
|
||||
>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2))
|
||||
}
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
=== tests/cases/compiler/decoratorMetadataWithConstructorType.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: A = new A();
|
||||
>x : A
|
||||
>A : A
|
||||
>new A() : A
|
||||
>A : typeof A
|
||||
}
|
||||
|
||||
21
tests/cases/compiler/decoratorMetadataWithConstructorType.ts
Normal file
21
tests/cases/compiler/decoratorMetadataWithConstructorType.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: A = new A();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user