Dunqing
f794870dd4
feat(transformer/nullish-coalescing-operator): generate the correct binding name ( #4974 )
...
match Babel's [implementation](440fe41333/packages/babel-plugin-transform-nullish-coalescing-operator/src/index.ts (L40) )
2024-08-20 01:06:36 +00:00
Boshen
64ace42566
feat(transform_conformance): show transform conformance errors ( #4976 )
2024-08-19 09:01:34 +00:00
Boshen
4fdf26dac8
refactor(transform_conformance): add driver ( #4969 )
2024-08-19 07:27:39 +00:00
Dunqing
f1fcdde593
feat(transformer): support react fast refresh ( #4587 )
...
close : #3943
## Further improvements
There is a double visit here. We need to collect all react hooks calling in `Function` and `ArrowFunctionExpression`. If we want to remove this implementation, we may wait for #4188 .
d797e595d2/crates/oxc_transformer/src/react/refresh.rs (L744-L947)
## Tests
All tests copy from https://github.com/facebook/react/blob/main/packages/react-refresh/src/__tests__/ReactFresh-test.js
There are still 4 tests that have not been passed
**1. refresh/can-handle-implicit-arrow-returns/input.jsx**
Related to #4767 . transform correct, just output doesn't match the expected output
**2. refresh/registers-identifiers-used-in-jsx-at-definition-site/input.jsx**
**3. refresh/registers-identifiers-used-in-react-create-element-at-definition-site/input.jsx**
Blocked by #4746
**4. refresh/supports-typescript-namespace-syntax/input.tsx**
oxc transforms ts to js first, so probably we can ignore this case. If we really want to pass this test, we also need to turn off `TypeScript` plugin.
## What's next?
### Options:
1. Support transform `refresh_reg` and `refresh_sig` options to `MemberExpression`. Currently `import.meta.xxxx` still is an `Identifier`
2. Support `emit_full_signatures` option
### Other
NAPI, testing in `monitor-oxc`, etc..
2024-08-15 16:41:30 +00:00
Dunqing
0d7912217a
feat(transformer): support logical-assignment-operators plugin ( #4890 )
...
part of #4754
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865 .
2024-08-15 10:10:36 +00:00
Dunqing
ab1d08ccfb
feat(transformer): support optional-catch-binding plugin ( #4885 )
...
part of #4754
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865 .
2024-08-15 10:10:34 +00:00
Dunqing
69da9fda3a
feat(transformer): support nullish-coalescing-operator plugin ( #4884 )
...
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865 .
2024-08-15 10:10:33 +00:00
Dunqing
3a66e5843d
feat(transformer): support exponentiation operator plugin ( #4876 )
...
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865 .
2024-08-15 10:10:32 +00:00
Dunqing
62f759c1f2
fix(transformer/typescript): generated assignment for constructor arguments with access modifiers should be injected to the top of the constructor ( #4808 )
...
fix : #4789
2024-08-10 11:21:45 +00:00
Dunqing
3987665490
fix(transformer/typescript): incorrect enum-related symbol_id/reference_id ( #4660 )
...
part of #4581
2024-08-06 02:57:19 +00:00
Dunqing
03c643a8af
fix(semantic): incorrect scope_id for catch parameter symbols ( #4659 )
...
When we move all the bindings in the CatchClause scope to its child scope (BlockStatement), we also need to replace the scope_id in the symbol with the scope_id of the new scope.
2024-08-06 02:57:18 +00:00
Dunqing
5327acdc1f
fix(transformer/react): the require IdentifierReference does not have a reference_id ( #4658 )
...
part of #4581 . Looks we had to pass `TraverseCtx` to the `ModuleImports`
2024-08-05 22:55:07 +00:00
Dunqing
48031ada93
fix(transformer/typescript) shadowed imports have not been removed ( #4550 )
...
close : #4423
2024-08-05 03:15:14 +00:00
Dunqing
4efd54b84d
fix(transformer/typescript): incorrect SymbolFlags for jsx imports ( #4549 )
...
All `SymbolFlags` for imports should be `SymbolFlags::Import`
2024-08-05 03:15:13 +00:00
Dunqing
3a6e4d91cf
feat(transformer_conformance): test ScopeTree and SymbolTable for correctness after transformation ( #4581 )
...
part of #4549
This test verifies that the correct symbols and scopes were added/changed during the transformation. From the snapshots, most of them are incorrect currently
2024-08-04 11:45:10 +00:00
Dunqing
ecdee88cfb
fix(transformer/typescript): incorrect eliminate exports when the referenced symbol is both value and type ( #4507 )
2024-07-27 12:11:29 -04:00
Dunqing
f8565ae3cd
fix(transformer/typescript): unexpectedly removed class binding from ExportNamedDeclaration ( #4351 )
...
The original `SymbolFlags` methods were a bit confusing I renamed and re-implemented them.
2024-07-18 16:44:38 +00:00
Dunqing
a88d588a07
feat(semantic): add ReferenceFlags::TSTypeQuery to indicate referenced by TSTypeQuery ( #4317 )
...
`ReferenceFlags::TSTypeQuery` can be used to help us insist on whether the reference is referenced by the type or not.
2024-07-17 09:52:57 +00:00
Dunqing
c362bf7edf
fix(semantic): incorrect resolve references for TSInterfaceHeritage ( #4311 )
...
related issue: https://github.com/oxc-project/oxc/issues/3963
fixes: https://github.com/oxc-project/monitor-oxc/actions/runs/9960183591/job/27518854841
2024-07-17 03:33:02 +00:00
Dunqing
351ecf2707
fix(semantic): incorrect resolve references for TSTypeQuery ( #4310 )
...
```ts
type A = typeof Foo
^^^ Only allow reference to value symbol
```
I have verified the changed snapshot. That's correct
2024-07-17 03:33:00 +00:00
Boshen
83bd40db4e
chore: turn off doctest for all [[bin]]
2024-07-14 16:55:19 +08:00
Boshen
e167ef79c6
fix(codegen): print parenthesis properly ( #4245 )
...
`TSParenthesizedType` handles parenthesis in ts types.
It should be considered a bug if parenthesis is not printed correctly after this PR.
2024-07-14 04:13:10 +00:00
Don Isaac
4413e2d298
fix(transformer): missing initializer for readonly consructor properties ( #4103 )
2024-07-08 12:45:50 +08:00
Boshen
aaac2d8775
fix(codegen): preserve parentheses from AST instead calculating from operator precedence ( #4055 )
...
…operator precedence
Calculating from operator precedence is currently unsafe and will result
incorrect semantics.
2024-07-05 14:01:17 +08:00
Dunqing
bdee156c5d
fix(transformer/typescript): declare class incorrectly preserved as runtime class ( #3997 )
...
fix : #3993
2024-07-01 16:04:40 +00:00
Dunqing
a50ce3d299
fix(transformer/typescript): missing initializer for class constructor arguments with private and protected modifier ( #3996 )
...
close : #3992
2024-07-01 15:10:32 +00:00
Boshen
5845057bff
refactor(transformer): pass in symbols and scopes ( #3978 )
...
This PR adds a new method `build_with_symbols_and_scopes` to make semantic building optional, there may be prior steps that has the semantic data already built.
2024-06-30 06:33:48 +00:00
DonIsaac
63f36daae0
feat(parser): parse modifiers with parse_modifiers (take 2) ( #3977 )
...
Same as #3948 , with fixes for bugs found by @Boshen.
2024-06-30 03:46:34 +00:00
Boshen
14bc31ee74
Revert "feat(parser): parse modifiers with parse_modifiers ( #3948 )"
...
This reverts commit 7b38bde073 .
2024-06-29 14:16:26 +08:00
DonIsaac
7b38bde073
feat(parser): parse modifiers with parse_modifiers ( #3948 )
...
Closes #3929
2024-06-29 05:29:47 +00:00
Dunqing
5501d5ce33
feat(transformer/typescript): transform import {} from "mod" to import "mod" ( #3866 )
...
close : #3736
2024-06-24 03:27:39 +00:00
Boshen
445603444f
feat(ast)!: add IdentifierReference to ExportSpecifier ( #3820 )
...
closes #3795
closes #3796
2024-06-22 11:43:41 +00:00
Boshen
2a16ce0624
feat(traverse): disable syntax check and disable build module record ( #3794 )
...
These can be skipped because :
* semantic errors are not passed to the caller
* module record is not used
2024-06-20 13:05:35 +00:00
Dunqing
497769cb60
feat(ast): add some visitor functions ( #3785 )
2024-06-20 05:23:04 +00:00
Boshen
4e9d8a5585
chore: fix some nightly clippy warnings
2024-06-19 00:53:58 +08:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt
2024-06-19 00:48:30 +08:00
Boshen
5c38a0fd69
feat(codegen)!: new code gen API ( #3740 )
...
This PR introduces two type alias to avoid the confusing const generic `pub struct Codegen<'a, const MINIFY: bool>`
* CodeGenerator - Code generator without whitespace removal.
* WhitespaceRemover - Code generator with whitespace removal.
Usage is changed to a builder pattern:
```rust
CodeGenerator::new()
.enable_comment(...)
.enable_sourcemap(...)
.build(&program);
```
2024-06-18 15:50:12 +00:00
Boshen
5a99d30eba
feat(codegen): improve codegen formatting ( #3735 )
2024-06-18 11:10:36 +00:00
Boshen
982e6f08df
chore: make println and eprintln opt-in ( #3712 )
...
I noticed accidental `println` can be merged, which isn't really nice.
2024-06-17 10:40:34 +00:00
Boshen
534242a729
feat(codegen)!: remove CodegenOptions::enable_typescript ( #3674 )
...
The typescript transform pass is now required to strip typescript syntax
for codegen to print things properly.
Codegen will now print whatever is in the AST.
2024-06-14 21:56:00 +08:00
Dunqing
59666e0127
fix(transformer): do not rename accessible identifier references ( #3623 )
...
close : #3620
In `Babel`, the expected output is:
```ts
var x = 10;
var Foo = function(Foo) {
Foo[Foo['a'] = 10] = 'a';
Foo[Foo['b'] = 10] = 'b';
Foo[Foo['c'] = 30] = 'c';
return Foo;
}(Foo || {});
```
IMO, `Foo.b + x` is enough, because `x` is not a const variable. The
output same as with `typescript`
2024-06-13 15:26:38 +08:00
Boshen
c041e9d1a9
chore: bump test262, babel and TypeScript submodules ( #3644 )
2024-06-12 18:42:32 +08:00
Boshen
b58d8eb88f
fix!(codegen): remove the unecessary 4th argument from Codegen::new ( #3640 )
2024-06-12 07:58:54 +00:00
Boshen
d77ec9f95a
chore: remove trailing whitespaces for all files; add .editorconfig ( #3639 )
2024-06-12 15:47:26 +08:00
Boshen
f6752b482f
feat!(ast): make Trivias clonable by adding Arc ( #3638 )
...
This makes `Trivias` cloneable and stops us from using `Rc::new` and
`Rc::clone` everywhere.
`Trivias` is rarely cloned so an `Arc` should suffice.
2024-06-12 13:16:10 +08:00
Dunqing
5793ff1986
refactor(transformer): replace &’a Trivias with Rc<Trivias> ( #3580 )
...
`Transformer` needs to borrow `Trivias`.
8be1cc8052 (r1630711060)
2024-06-11 13:23:41 +08:00
Dunqing
e8a20f8d50
feat(transformer/typescript): remove typescript ast nodes ( #3559 )
...
According to Babel tests feedback, remove some known ts AST nodes.
There are still many TS AST nodes that need to be deleted
2024-06-07 05:04:22 +00:00
Dunqing
0007ee47be
chore(coverage, transformer_conformance): print all AST whether or not they are Typecript AST ( #3556 )
...
We have a conclusion that codegen will print whatever is in the AST,
instead of having an option to enable printing TypeScript syntax. I plan
to remove codegen's `enable_typescript` option after we strip out all
typescript AST in the transformer typescript plugin.
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-06 15:45:20 +08:00
overlookmotel
837776e1ab
fix(transformer): TS namespace transform do not track var decl names ( #3501 )
...
Don't track variable declaration or import binding names in TS namespace transform.
Babel does, but it appears to be wrong. It's illegal to have a `var`/`let`/`const` declaration or import in same scope as a TS namespace declaration with same binding.
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAQTgMyhEcDkUCmBDAYxkwG4AoAOzxBwGcxCdE4BvAXzLIIgtvgCE4AXjgBGclRr1GcQSzJxFcADY54AD3Icyq+AGFhYidToMCTA-KUq1cTWW0A3PFDgARQ+Monp596wUlXTstMiA
2024-06-03 12:35:57 +00:00
overlookmotel
8e4f33557d
fix(transformer): output empty file for TS definition files ( #3500 )
...
As discussed in
https://github.com/oxc-project/oxc/pull/3489#issuecomment-2143482458 ,
transformer should output an empty file for TS definition files.
2024-06-03 20:25:02 +08:00