Commit graph

57 commits

Author SHA1 Message Date
Boshen
3efbbb2e1f
feat(ast): add "abstract" type to MethodDefinition and PropertyDefinition (#2536)
closes #2532

```
pub enum PropertyDefinitionType {
    PropertyDefinition,
    TSAbstractPropertyDefinition,
}

pub enum MethodDefinitionType {
    MethodDefinition,
    TSAbstractMethodDefinition,
}
```
2024-02-28 17:33:11 +08:00
Boshen
be6b8b7ce6
[BREAKING CHANGE] Change Atom to Atom<'a> to make it safe (#2497)
Part of #2295

This PR splits the `Atom` type into `Atom<'a>` and `CompactString`.

All the AST node strings now use `Atom<'a>` instead of `Atom` to signify
it belongs to the arena.

It is now up to the user to select which form of the string to use.

This PR essentially removes the really unsafe code 


93742f89e9/crates/oxc_span/src/atom.rs (L98-L107)

which can lead to 

![image](https://github.com/oxc-project/oxc/assets/1430279/8c513c4f-19b0-4b63-b61c-e07c187c95b5)
2024-02-26 19:34:40 +08:00
Boshen
4fabe66621
Publish crates v0.8.0 2024-02-26 19:01:51 +08:00
Dunqing
432791679f
fix(codegen): remove redundant semicolon in PropertyDefinition (#2511) 2024-02-26 15:15:19 +08:00
Boshen
540f917f3a
refactor(ast): remove TSEnumBody (#2509) 2024-02-26 12:44:38 +08:00
Boshen
1634586934 refactor(ast): s/TSTypeOperatorType/TSTypeOperator to align with estree 2024-02-21 22:25:04 +08:00
Boshen
9087f71765 refactor(ast): s/TSThisKeyword/TSThisType to align with estree 2024-02-21 22:25:04 +08:00
Boshen
d08abc638e refactor(ast): s/NumberLiteral/NumericLiteral to align with estree 2024-02-21 21:41:08 +08:00
Boshen
e6b391a24f refactor(ast): s/ArrowExpression/ArrowFunctionExpression to align estree 2024-02-21 21:41:08 +08:00
Andrew McClenaghan
6b3b260dcc
feat(Codegen): Improve codegen (#2460)
This gets all the new TS types working to the same level TS output was
before and fixes a bunch of other codegen

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-21 14:41:57 +08:00
Boshen
a2c173de57
refactor: remove panic! from examples (#2454)
relates #2308
2024-02-20 16:18:39 +08:00
Andrew McClenaghan
e6d536cb9b
feat(codegen): configurable typescript codegen (#2443)
- Adds option to `CodegenOptions` - `enable_typescript` to enable output
of TS.
- Stops skipping output that is TS when `enable_typescript` is enabled
- Adds TS support to 
    - Function
    - FormalParameter
    - BindingPattern
 - Adds basic tests for TS generation

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-20 12:09:28 +08:00
Dunqing
b5deb9a708
fix(codegen): when async is on the left-hand side of a for-of, wrap it in parentheses (#2407)
Refer to
55e1127a49/internal/js_printer/js_printer.go (L3097-L3104)
2024-02-13 22:42:23 +08:00
Wenzhe Wang
384d5acd7a
fix(codegen): lower the level of precedence in TaggedTemplateExpression (#2391) 2024-02-11 22:56:32 +08:00
Boshen
d6d921ea1f
Publish crates v0.7.0 2024-02-09 23:01:12 +08:00
Dunqing
2eb489e996
fix(codegen): format new expession + import expression with the correct parentheses (#2346)
Similar to #2330
2024-02-09 20:51:50 +08:00
Dunqing
55011e2793
feat(codegen): avoid printing comma in ArrayAssignmentTarget if the elements is empty (#2331) 2024-02-06 22:45:19 +08:00
Boshen
721f6cb74e
fix(codegen): format new expression + call expression with the correct parentheses (#2330)
closes #2328
2024-02-06 22:06:12 +08:00
Boshen
1822cfe18d
refactor(ast): fix BigInt memory leak by removing it (#2293)
relates

We'll need to evaluate the value by other means.
2024-02-04 16:47:00 +08:00
Boshen
d2b304b1f8
Publish crates v0.6.0 2024-02-03 22:35:30 +08:00
Wenzhe Wang
0c225a49aa
fix(codegen): print space before with clause in import (#2278) 2024-02-02 14:52:32 +00:00
Dunqing
8ac0202c9a
feat(codegen): keep shorthand in ObjectPattern and ObjectProperty (#2265)
close: #2262

Do I need to add a test for this?
2024-02-02 08:32:51 +00:00
Wenzhe Wang
fa555ceed8
feat(codegen): change back to read raw (#2222) 2024-01-31 12:17:52 +08:00
Wenzhe Wang
9333264428
feat(codegen): print TemplateLiteral with print_str (#2207) 2024-01-29 23:09:29 +08:00
Yunfei He
d34650a1ac
fix(codegen): print necessary spaces for ExportAllDeclaration (#2190) 2024-01-29 01:05:09 +08:00
underfin
989ab88bc6
fix(codegen): print Directive original string (#2157)
> A Use Strict Directive may not contain an EscapeSequence or
LineContinuation.

It is `Use Strict Directive` spec, but the `expression` of `Directive`
isn't original string value, it has error if using it to codegen, so
here using `directive` of `Directive` to codegen and not to escape it.
Here is crashed test cases.

``` js
'use str\
ict';
```
The babel will print the original string, I follow it and avoid using
`print_str` because it will escape string.

I also changed some code using the `expression` of `Directive` to check
`Use Strict Directive` .
2024-01-25 15:24:05 +08:00
Wenzhe Wang
1ee6d8cea9
feat(codegen): move string test to codegen (#2150) 2024-01-23 23:49:36 +08:00
Dunqing
766ca63aa0
refactor(ast): rename RestElement to BindingRestElement (#2116)
close: #2115
2024-01-22 14:28:35 +08:00
Wenzhe Wang
29dc5e69ff
fix(codegen): add parenthesis in binary expression by precedence (#2067)
related ESBuild code:
f5f8ff895c/internal/js_printer/js_printer.go (L3348-L3371)
2024-01-17 23:01:42 +08:00
Boshen
61f37ea973
Publish crates v0.5.0 2024-01-12 23:33:47 +08:00
Boshen
a6717db423
refactor(formatter,linter,codegen): remove oxc_formatter (#1968)
closes #1941
2024-01-10 06:41:20 +00:00
Bradley Farias
ff9cf292dc
ensure numbers without a raw are allocated during codegen (#1950)
This was incorrectly using raw for dynamically generated numbers like in
the minifier (
6e0bd52af1/crates/oxc_minifier/src/compressor/fold.rs (L280)
).

This ensures they are dynamically generated during codegen.

This does not investigate why `just example minifier` does not take the
`if MINIFY` branch.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-01-09 11:13:25 +08:00
Boshen
8347e2225c
Release crates v0.4.0 2023-12-08 17:20:37 +08:00
Boshen
6670d94708
chore(rust): remove unnecessary clippy::non_upper_case_globals (#1557) 2023-11-27 14:31:38 +08:00
magic-akari
9ff0ffcc6f
feat(ast): implement new proposal-import-attributes (#1476)
- [Import Attributes](https://tc39.es/proposal-import-attributes)
2023-11-25 15:56:09 +08:00
Boshen
1a576f60a8
refactor(rust): move to workspace lint table (#1444) 2023-11-20 14:38:10 +08:00
Boshen
ba603cebb9
Release Oxc v0.3.0 2023-11-06 19:11:16 +08:00
Boshen
a455c81db6
fix(linter): revert changes to JSX attribute strings (#1101) 2023-10-30 15:26:04 +08:00
Boshen
6295f9ce18
fix(ast): jsx attribute value and text child should be jsx string (#1089) 2023-10-29 15:32:24 +08:00
Wenzhe Wang
cef78accf0
feat(codegen): indent inner class (#1085) 2023-10-29 15:03:30 +08:00
Boshen
e8a4e81298
feat(transformer): implement some of jsx decode entities (#1086) 2023-10-29 14:57:39 +08:00
Wenzhe Wang
094dfa5604
feat: support filter exec snap (#1084)
Co-authored-by: Boshen <boshenc@gmail.com>
2023-10-29 05:39:32 +00:00
Boshen
af1a76bafa
feat(transformer): implement some of needs_explicit_esm for typescript (#1047)
Co-authored-by: magic-akari <akari.ccino@gmail.com>
2023-10-24 17:30:01 +08:00
Boshen
854b55a3e6
feat(codegen): json strings proposal (#1039) 2023-10-23 18:29:30 +08:00
Boshen
dfee8539f0
feat(transformer): add utils to make logical_assignment_operators pass (#1017) 2023-10-20 16:27:23 +08:00
Boshen
678db1d955
feat(transformer): ES2020 Nullish Coalescing Operator (#1004)
The test runner needs an update for reading options.jon, which I'll work
on in the up coming PR.
2023-10-16 21:45:58 +08:00
Wenzhe Wang
0e9104477f
feat: adjust the order of print semicolon (#1003)
Add a number of semicolons to our minifier test cases.
2023-10-16 21:33:15 +08:00
Boshen
1f1eb6c497
chore: fix spelling 2023-10-16 15:33:47 +08:00
Boshen
4886d408eb
chore(clippy): enable undocumented_unsafe_blocks 2023-10-16 15:18:14 +08:00
Boshen
110059ffb7
refactor(rust): change RefCell.clone().into_inner() to RefCell.get() 2023-10-16 11:26:38 +08:00