Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Conversation

@copybara-service
Copy link

Fix const enum exports

Align const enum exports with TypeScript. That is:

  • preserveConstEnums is disabled
    --> only export the type, runtime values are elided

  • preserveConstEnums is enabled
    --> export the value if the const enum is declared in a .ts file from the same compilation unit; otherwise export type only

    When is preserveConstEnums enabled, isolatedModules is likely enabled, too. isolatedModules prevents const enum usage when the enum comes from .d.ts files. Star re-exports are allowed, though. It's possible the enum is then imported from a compilation unit that does not use isolatedModules. That unit needs the type info, so it's important to always export the type. But that unit won't access the value because const enums are inlined.

Align const enum exports with TypeScript. That is:

- preserveConstEnums is disabled
  --> only export the type, runtime values are elided

- preserveConstEnums is enabled
  --> export the value if the const enum is declared in a .ts file from the same compilation unit; otherwise export type only

  When is preserveConstEnums enabled, isolatedModules is likely enabled, too. isolatedModules prevents const enum usage when the enum comes from .d.ts files. Star re-exports are allowed, though. It's possible the enum is then imported from a compilation unit that does not use isolatedModules. That unit needs the type info, so it's important to always export the type. But that unit won't access the value because const enums are inlined.

PiperOrigin-RevId: 601770954
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant