Closed
Description
π Search Terms
transpile declaration api emit enum missing
π Version & Regression Information
- This changed in commit or PR Add
transpileDeclaration
API methodΒ #58261 @weswigham
β― 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;
}
π 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