Skip to content

[transpileDeclaration API][5.5] Type containing enum values is incorrectly emittedΒ #58423

Closed
@MichaelMitchell-at

Description

@MichaelMitchell-at

πŸ”Ž Search Terms

transpile declaration api emit enum missing

πŸ•— Version & Regression Information

⏯ Playground Link

https://github.com/MichaelMitchell-at/transpile_declaration_bug_repro

πŸ’» Code

// @strict: true
// @declaration: true
// @showEmit
// @showEmittedFile: a.d.ts
// @showEmittedFile: b.d.ts

// @filename: a.ts
export enum Foo {
  A = 'a',
  B = 'b',
}

// @filename: b.ts
import {Foo} from './a';

export type Bar = {
  [Foo.A]: 1;
  [Foo.B]: 2;
}

Workbench Repro

πŸ™ Actual behavior

Refer to this program which invokes the ts.transpileDeclaration API:
https://github.com/MichaelMitchell-at/transpile_declaration_bug_repro/blob/main/transpile.mjs

Basic instructions to invoke it can be found in
https://github.com/MichaelMitchell-at/transpile_declaration_bug_repro/blob/main/README.md

When using the API, b.d.ts is emitted as

export type Bar = {};

while when using tsc it gets emitted as

import { Foo } from './a';
export type Bar = {
    [Foo.A]: 1;
    [Foo.B]: 2;
};

πŸ™‚ Expected behavior

Using the API should emit

import { Foo } from './a';
export type Bar = {
    [Foo.A]: 1;
    [Foo.B]: 2;
};

Additional information about the issue

It's entirely possible that usage of the API is incorrect, though it doesn't seem to deviate from the patterns demonstrated in https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API

Metadata

Metadata

Assignees

Labels

Domain: ts.transpileDeclarationIssues regarding the transpileDeclaration API, which do not reproduce without itFix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions