Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

Imports for types of ctor arguments are elided although they are lowered into a static property #635

@tbosch

Description

@tbosch

Reproduction

aclass.ts:

export class AClass {}

main.ts:

import {AClass} from './aclass';
class MyService {
  constructor(aclass: AClass) {}
}

Tsickle options: transformDecorators: true

Output:
main.js

// no import for AClass here!
...
MyService.ctorParameters = function () { return [
  // although AClass is now in a value position
  { type: AClass, },
]; };

Root cause
TypeScript right now has now way of allowing a transformer to tell it to not elide a symbol that is only used in a type position (see microsoft/TypeScript#17516).

Workaround
Set emitDecoratorMetadata: true. This way, TypeScript won't elide the import as its own transformer would have moved it into a value position.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions