Skip to content

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

Closed

Description

🔎 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

Activity

  1. changed the title [-][transpileDeclaration API] Type containing enum values is Incorrectly emitted[/-] on May 3, 2024
  2. changed the title [-][transpileDeclaration API] Type containing enum values is incorrectly emitted[/-] on May 3, 2024
  3. jakebailey commented on May 3, 2024

    @jakebailey
    Member

    Did you check the returned errors from the transpile function?

  4. MichaelMitchell-at commented on May 3, 2024

    @MichaelMitchell-at
    ContributorAuthor

    Did you check the returned errors from the transpile function?

    Yeah, no errors

  5. added
    Needs Investigation
    on May 3, 2024
  6. added
    Fix Available
    on May 3, 2024
  7. jakebailey commented on May 3, 2024

    @jakebailey
    Member

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

  8. added
    Domain: API: ts.transpileDeclaration
    on May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Domain: API: ts.transpileDeclarationFix AvailableNeeds Investigation

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions