close
Skip to content

fix(1632): erase const enums after inlining#1639

Merged
weswigham merged 23 commits into
microsoft:mainfrom
a-tarasyuk:fix/1632
Sep 16, 2025
Merged

fix(1632): erase const enums after inlining#1639
weswigham merged 23 commits into
microsoft:mainfrom
a-tarasyuk:fix/1632

Conversation

@a-tarasyuk

Copy link
Copy Markdown
Contributor

Fixes #1632

Comment thread internal/transformers/tstransforms/runtimesyntax.go Outdated
@a-tarasyuk a-tarasyuk force-pushed the fix/1632 branch 2 times, most recently from 798d12b to c5a62a9 Compare August 27, 2025 13:15
@a-tarasyuk a-tarasyuk marked this pull request as draft August 27, 2025 13:15
@a-tarasyuk a-tarasyuk force-pushed the fix/1632 branch 2 times, most recently from 441cca9 to ded3fa0 Compare August 27, 2025 18:42
Comment thread internal/core/compileroptions.go Outdated
@a-tarasyuk a-tarasyuk marked this pull request as ready for review August 27, 2025 19:59
@a-tarasyuk a-tarasyuk requested a review from jakebailey August 27, 2025 21:10
Comment thread testdata/baselines/reference/submodule/compiler/constEnumErrors.js.diff Outdated
Comment thread testdata/baselines/reference/submodule/conformance/constEnum4.js.diff Outdated
Comment thread testdata/baselines/reference/submodule/conformance/constEnum4.js
Comment thread internal/printer/emitcontext.go Outdated
@a-tarasyuk a-tarasyuk requested a review from jakebailey August 29, 2025 12:16

@jakebailey jakebailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this seems probably right but will defer to @weswigham 😄

@jakebailey jakebailey requested a review from weswigham September 3, 2025 03:17
@a-tarasyuk

Copy link
Copy Markdown
Contributor Author

@jakebailey ok, thanks

@weswigham weswigham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unsure if we wanted this behavior back and didn't just wanna make const enums always preserved, since that's what we were doing before we re-added inlining, but I suppose since vscode reported it, they'd like the runtime source elision behavior back, too. Tbh, preserveConstEnums should at least be the default nowadays, but that's a change for another PR.

We also need to elide namespace declarations containing exclusively const enums and/or types (preserveConstEnums dependent) for the same reasons you'd want the const enums elided. See the missing shouldEmitModuleDeclaration call from the original ts.ts source. ast.GetModuleInstanceState is already ported, so it shouldn't be too bad.

@a-tarasyuk a-tarasyuk requested a review from weswigham September 3, 2025 22:31

@weswigham weswigham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty good - some last comments on comment preservation, since we're working with NotEmittedStatements which explicitly exist to copy those.

Comment thread internal/transformers/tstransforms/runtimesyntax.go Outdated
Comment thread internal/printer/emitcontext.go Outdated
@a-tarasyuk a-tarasyuk requested a review from weswigham September 4, 2025 20:47
@weswigham weswigham added this pull request to the merge queue Sep 16, 2025
Merged via the queue into microsoft:main with commit ea6d53c Sep 16, 2025
22 checks passed
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.

Const enums shouldn't be emitted after inlining

4 participants