Skip to content

Instead of writing text from source file use text property to write t… #4402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
39 changes: 39 additions & 0 deletions tests/baselines/reference/decoratorMetadataWithConstructorType.js
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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))
}

Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 0 deletions tests/cases/compiler/decoratorMetadataWithConstructorType.ts
Original file line number Diff line number Diff line change
@@ -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();
}