Skip to content

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Apr 20, 2025

Input:

// SymbolFlags: NameSpaceModule
export namespace Foo {
	 export type T = 0;
}
// SymbolFlags: ValueModule
export namespace Foo {
	 export const Bar = 1;
}

Before output:

expot {}

After Output:

// SymbolFlags: ValueModule
export let Foo;
(function(_Foo) {
  const Bar = _Foo.Bar = 1;
})(Foo || (Foo = {}));

When both NameSpaceModule and ValueModule are present, we need to check the current
declaration flags. If the current declaration is NameSpaceModule, we can return early
because it's a type-only namespace and doesn't emit any JS code, otherwise we need to
continue transforming it.

Copy link
Member Author

Dunqing commented Apr 20, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Apr 20, 2025

CodSpeed Instrumentation Performance Report

Merging #10511 will create unknown performance changes

Comparing 04-20-fix_transformer_typescript_namespaces_disappeared_and_do_not_transform_when_a_type-only_namespace_followed_by_a_value_module_namespace (33a2625) with 04-20-fix_transformer_typescript_variable_declaration_disappears_when_declaring_type-alias_interface_first_and_then_declaring_namespace (710a35c)

Summary

🆕 36 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 codegen[checker.ts] N/A 22.2 ms N/A
🆕 codegen_sourcemap[checker.ts] N/A 65.1 ms N/A
🆕 formatter[antd.js] N/A 708.5 ms N/A
🆕 formatter[react.development.js] N/A 8 ms N/A
🆕 formatter[typescript.js] N/A 1.1 s N/A
🆕 isolated-declarations[vue-id.ts] N/A 58.4 ms N/A
🆕 lexer[RadixUIAdoptionSection.jsx] N/A 21.3 µs N/A
🆕 lexer[antd.js] N/A 24.8 ms N/A
🆕 lexer[cal.com.tsx] N/A 5.9 ms N/A
🆕 lexer[checker.ts] N/A 14.9 ms N/A
🆕 lexer[pdf.mjs] N/A 3.9 ms N/A
🆕 linter[RadixUIAdoptionSection.jsx] N/A 2.7 ms N/A
🆕 linter[cal.com.tsx] N/A 1.2 s N/A
🆕 linter[checker.ts] N/A 3 s N/A
🆕 mangler[antd.js] N/A 15.9 ms N/A
🆕 mangler[react.development.js] N/A 293.2 µs N/A
🆕 mangler[typescript.js] N/A 39.4 ms N/A
🆕 minifier[antd.js] N/A 163.5 ms N/A
🆕 minifier[react.development.js] N/A 1.8 ms N/A
🆕 minifier[typescript.js] N/A 287.9 ms N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@Dunqing Dunqing marked this pull request as ready for review April 20, 2025 05:07
@Dunqing Dunqing requested a review from overlookmotel as a code owner April 20, 2025 05:07
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Apr 21, 2025
Copy link
Member

Boshen commented Apr 21, 2025

Merge activity

…orm when a type-only namespace followed by a value module namespace (#10511)

Input:
```ts
// SymbolFlags: NameSpaceModule
export namespace Foo {
	 export type T = 0;
}
// SymbolFlags: ValueModule
export namespace Foo {
	 export const Bar = 1;
}
```

Before output:
```js
expot {}
```

After Output:
```js
// SymbolFlags: ValueModule
export let Foo;
(function(_Foo) {
  const Bar = _Foo.Bar = 1;
})(Foo || (Foo = {}));
```

When both `NameSpaceModule` and `ValueModule` are present, we need to check the current
declaration flags. If the current declaration is `NameSpaceModule`, we can return early
because it's a type-only namespace and doesn't emit any JS code, otherwise we need to
continue transforming it.
@graphite-app graphite-app bot force-pushed the 04-20-fix_transformer_typescript_variable_declaration_disappears_when_declaring_type-alias_interface_first_and_then_declaring_namespace branch from df7d1de to 710a35c Compare April 21, 2025 09:20
@graphite-app graphite-app bot force-pushed the 04-20-fix_transformer_typescript_namespaces_disappeared_and_do_not_transform_when_a_type-only_namespace_followed_by_a_value_module_namespace branch from 4f101a1 to 33a2625 Compare April 21, 2025 09:20
Base automatically changed from 04-20-fix_transformer_typescript_variable_declaration_disappears_when_declaring_type-alias_interface_first_and_then_declaring_namespace to main April 21, 2025 09:28
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 21, 2025
@graphite-app graphite-app bot merged commit 33a2625 into main Apr 21, 2025
28 checks passed
@graphite-app graphite-app bot deleted the 04-20-fix_transformer_typescript_namespaces_disappeared_and_do_not_transform_when_a_type-only_namespace_followed_by_a_value_module_namespace branch April 21, 2025 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants