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

Fix const enum exports #1505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix const enum exports #1505

wants to merge 1 commit into from

Conversation

copybara-service[bot]
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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant