Skip to content

Emitted decorator metadata is different when --isolatedModules is set #333

Closed
@jpsfs

Description

@jpsfs

Hi,

I'm facing an issue while compiling an Angular 2 application with the IsolatedModules flag set to true.
If IsolatedModules is set to false everything works as expect.

The emitted decorator metadata is different. If I use tsc directly I have no problem.

I've prepated a repo that easily reproduces the issue.
Just download it, run npm install && typings install.

See diferences on decorator.js when executing gulp build and tsc.

TypeScript Version:

1.8.10

Code

import * as ng from "angular2/core";

@ng.Decorator({
...
})
export class MyClass{
     constructor(private el: ng.ElementRef) {
     }
}

Expected behavior:
If the isolatedModules flag is set to false:

...
MyClass = __decorate([
      ng.Directive({
            selector: '[my-selector]',
      }), 
      __metadata('design:paramtypes', [ng.ElementRef]) // <<<<<<<<<<<<<<<<<<<
], MyClass);

Actual behavior:

If the isolatedModules flag is set to true:

...
MyClass = __decorate([
      ng.Directive({
            selector: '[my-selector]',
      }), 
      __metadata('design:paramtypes', [Object]) // <<<<<<<<<<<<<<<<<<<<<<<
], MyClass);

microsoft/TypeScript#8355

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions