Skip to content

ES6 class decoration output means property, method & parameter decorations can not get type information from target #6293

Closed
@jamcoupe

Description

@jamcoupe
function Decoration() {}
function PropertyDecoration(target: any) {
  console.log(target);
}

@Decoration
export class ClassName {

  @PropertyDecoration
  property: string = 'null';
}

compiles to:

function Decoration() { }
function PropertyDecoration(target) {
    console.log(target);
}
let ClassName = class {
    constructor() {
        this.property = 'null';
    }
};

However this means that the console.log result will be {}. Removing the @Decoration class decorator outputs:

function PropertyDecoration(target) {
    console.log(target);
}
class ClassName {
    constructor() {
        this.property = 'null';
    }
}

with the better console.log result of ClassName {}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions