Skip to content

TS 5.5 - Imports used by decorator output are removedΒ #59051

Closed
@RomainLanz

Description

@RomainLanz

πŸ”Ž Search Terms

remove import compilation decorator

πŸ•— Version & Regression Information

  • This changed between versions 5.4 and 5.5

⏯ Playground Link

https://github.com/RomainLanz/typescript-output-issue

npm install
npm run build

πŸ’» Code

import { DateTime } from "luxon";
import { column } from "@adonisjs/lucid/orm";

class User {
  @column.dateTime()
  declare createdAt: DateTime;
}

πŸ™ Actual behavior

When compiled the DateTime import is being removed (because it is only used as a type in our file), but the compilation of @column.dateTime() will use the import.

// ...

import { column } from "@adonisjs/lucid/orm";
class User {
}
__decorate([
    column.dateTime(),
    __metadata("design:type", typeof (_a = typeof DateTime !== "undefined" && DateTime) === "function" ? _a : Object)
], User.prototype, "createdAt", void 0);

πŸ™‚ Expected behavior

The import should be kept like in TypeScript 5.4.

import { DateTime } from "luxon";
import { column } from "@adonisjs/lucid/orm";
class User {
}
__decorate([
    column.dateTime(),
    __metadata("design:type", typeof (_a = typeof DateTime !== "undefined" && DateTime) === "function" ? _a : Object)
], User.prototype, "createdAt", void 0);

Additional information about the issue

No response

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesFix AvailableA PR has been opened for this issueRecent RegressionThis is a new regression just found in the last major/minor version of TypeScript.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions