Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MichaelMitchell-at opened this issue May 3, 2024 · 3 comments Β· Fixed by #58428
Closed
Assignees
Labels
Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@MichaelMitchell-at
Copy link

MichaelMitchell-at commented May 3, 2024

πŸ”Ž 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

@MichaelMitchell-at MichaelMitchell-at changed the title [transpileDeclaration API] Type containing enum values is Incorrectly emitted [transpileDeclaration API] Type containing enum values is incorrectly emitted May 3, 2024
@MichaelMitchell-at MichaelMitchell-at changed the title [transpileDeclaration API] Type containing enum values is incorrectly emitted [transpileDeclaration API][5.5] Type containing enum values is incorrectly emitted May 3, 2024
@jakebailey
Copy link
Member

Did you check the returned errors from the transpile function?

@MichaelMitchell-at
Copy link
Author

MichaelMitchell-at commented May 3, 2024

Did you check the returned errors from the transpile function?

Yeah, no errors

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label May 3, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.5.1 milestone May 3, 2024
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label May 3, 2024
@jakebailey
Copy link
Member

@weswigham should this have errored through the API? (Or will it after your PR?)

@weswigham weswigham added the Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants