fix(semantic): incorrect SymbolFlags of TSModuleDeclaration#10350
Merged
graphite-app[bot] merged 1 commit intomainfrom Apr 11, 2025
Merged
Conversation
Member
Author
CodSpeed Instrumentation Performance ReportMerging #10350 will degrade performances by 3.47%Comparing Summary
Benchmarks breakdown
|
b1d454d to
2625fff
Compare
8790921 to
e82bd5c
Compare
2625fff to
fc8acf4
Compare
fc8acf4 to
c67d431
Compare
e82bd5c to
0a2fed4
Compare
c67d431 to
5ef7f81
Compare
This was referenced Apr 11, 2025
Member
Author
This was referenced Apr 11, 2025
5ef7f81 to
ec0539d
Compare
0a2fed4 to
d4bcd57
Compare
Contributor
Merge activity
|
Based on TypeScript's [implementation](https://github.com/microsoft/TypeScript/blob/15392346d05045742e653eab5c87538ff2a3c863/src/compiler/binder.ts#L2384-L2393) to correct `SymbolFlags` of `TSModuleDeclaration`. The `SymbolFlags::NamespaceModule` and `SymbolFlags::ValueModule` have a significant difference, `NamespaceModule`: can only be referenced as a type. `ValueModule`: can only be referenced as a value. Let's take an example to see: ```ts namespace NamespaceModule { export type A = string } namespace ValueModule { export const A = 0; } ``` The following code is the JS output of the above example. ```js "use strict"; var ValueModule; (function (ValueModule) { ValueModule.A = 0; })(ValueModule || (ValueModule = {})); ``` Only `ValueModule` will be preserved and transformed. That means whether a `TSModuleDeclaration` needs to be transformed or removed directly, we can determine by its `SymbolFlags`. We can use it to simplify the current `TSModuleDeclaration` transformation later.
d4bcd57 to
c37f048
Compare
ec0539d to
dd2aef0
Compare
Base automatically changed from
04-10-refactor_semantic_simplify_bind_logic_for_tsmoduledeclaration
to
main
April 11, 2025 10:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Based on TypeScript's implementation to correct
SymbolFlagsofTSModuleDeclaration.The
SymbolFlags::NamespaceModuleandSymbolFlags::ValueModulehave a significant difference,NamespaceModule: can only be referenced as a type.ValueModule: can only be referenced as a value.Let's take an example to see:
The following code is the JS output of the above example.
Only
ValueModulewill be preserved and transformed.That means whether a
TSModuleDeclarationneeds to be transformed or removed directly, we can determine by itsSymbolFlags. We can use it to simplify the currentTSModuleDeclarationtransformation later.