Skip to content

Generated *.d.ts files lose decorator information #22980

Closed
@mendrik

Description

@mendrik

When writing a library that relies heavily on decorators in typescript, it would be beneficial if decorator information could be somehow preserved in the generated *.d.t.s file. I don't have any suggestion how it could be done except for maybe just code comments containing the original decorator.

Currently code like this

module feather.ui {

    import Construct = feather.annotations.Construct
    import Widget    = feather.core.Widget
    import deepValue = feather.objects.deepValue
    import TypedMap  = feather.types.TypedMap

    @Construct({selector: 'localization', singleton: true, attributes: ['translations']})
    export class Localization extends Widget {

        translations: TypedMap<any> = {}

        constructor(translations: TypedMap<any>) {
            super()
            this.translations = translations
        }

        translate = (key: string) =>
            deepValue(this.translations, key) || key
    }
}

could generate this:

declare module feather.ui {
    import Widget = feather.core.Widget;
    import TypedMap = feather.types.TypedMap;
    /* @Construct({selector: 'localization', singleton: true, attributes: ['translations']}) */
    class Localization extends Widget {
        translations: TypedMap<any>;
        constructor(translations: TypedMap<any>);
        translate: (key: string) => any;
    }
}

Since I'm writing a IDE plugin, I could read that comment to help me with looking up methods that satisfy particular criteria in a published library.

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