Skip to content

Emit changed example #4

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

Open
orta opened this issue Jul 2, 2020 · 4 comments
Open

Emit changed example #4

orta opened this issue Jul 2, 2020 · 4 comments
Labels
has repro indicates there's a twoslash repro in the issue

Comments

@orta
Copy link
Contributor

orta commented Jul 2, 2020

This looks like it might get merged soon: microsoft/TypeScript#39337

// @filename: service.ts
export class Service {}

// @filename: component.ts
 import type { Service } from "./service";

 declare var decorator: any;

 @decorator
 class MyComponent {
     constructor(public Service: Service) {
     }

     @decorator
     method(x: this) {
     }
 }

// @emitDecoratorMetadata
// @experimentalDecorators
// @showEmit
// @showEmittedFile: component.js
@orta orta added the has repro indicates there's a twoslash repro in the issue label Jul 2, 2020
@typescript-bot

This comment has been minimized.

@typescript-bot

This comment has been minimized.

@typescript-bot
Copy link

typescript-bot commented Jul 5, 2020

It looks like something has changed with this repro on today's nightly build of TypeScript. You can see what has changed on TypeScript between 9a5c007 and 13693 here.


Issue body code block by @orta

Before After

👍 Compiled
Emit:

// @filename: service.ts
export class Service {}

// @filename: component.ts
 import type { Service } from "./service";

 declare var decorator: any;

 @decorator
 class MyComponent {
     constructor(public Service: Service) {
     }

     @decorator
     method(x: this) {
     }
 }

// @showEmit 

👍 Compiled
Emit:

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);
};
let MyComponent = class MyComponent {
    constructor(Service) {
        this.Service = Service;
    }
    method(x) {
    }
};
__decorate([
    decorator,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], MyComponent.prototype, "method", null);
MyComponent = __decorate([
    decorator,
    __metadata("design:paramtypes", [Function])
], MyComponent);
export {};

@typescript-bot
Copy link

typescript-bot commented Apr 13, 2022

👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript.


Issue body code block by @orta

👍 Compiled
Emit:

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);
};
let MyComponent = class MyComponent {
    constructor(Service) {
        this.Service = Service;
    }
    method(x) {
    }
};
__decorate([
    decorator,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], MyComponent.prototype, "method", null);
MyComponent = __decorate([
    decorator,
    __metadata("design:paramtypes", [Function])
], MyComponent);
export {};

Historical Information
Version Reproduction Outputs
4.2.2, 4.3.2, 4.4.2, 4.5.2, 4.6.2

👍 Compiled
Emit:

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);
};
let MyComponent = class MyComponent {
    constructor(Service) {
        this.Service = Service;
    }
    method(x) {
    }
};
__decorate([
    decorator,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], MyComponent.prototype, "method", null);
MyComponent = __decorate([
    decorator,
    __metadata("design:paramtypes", [Function])
], MyComponent);
export {};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has repro indicates there's a twoslash repro in the issue
Projects
None yet
Development

No branches or pull requests

2 participants