Commit graph

18 commits

Author SHA1 Message Date
overlookmotel
2179b93729 fix(estree): make type of BigIntLiteral::raw prop in ESTree AST optional (#7663)
`BigIntLiteral`'s `raw` field is not an `Option` on Rust side, but this is an internal implementation detail - we may parse bigints to a `BigInt` in future (as we did in the past before we hit a memory leak problem), and make `raw` an `Option`.

So at present, the `raw` field is always non-null in JS-side AST. But update the TS type def to reflect that it should be an optional property. This aligns with ESTree.
2024-12-05 04:00:57 +00:00
overlookmotel
cbba26c237 fix(estree): raw: null in ESTree AST for generated NullLiterals (#7662)
In JS-side AST, leave `raw` field as `null` for `NullLiteral`s, if they are generated and have no raw representation in source text.
2024-12-05 04:00:56 +00:00
overlookmotel
1d59fc8353 fix(estree): raw: null in ESTree AST for generated BooleanLiterals (#7661)
In JS-side AST, leave `raw` field as `null` for `BooleanLiteral`s, if they are generated and have no raw representation in source text.
2024-12-05 04:00:55 +00:00
Song Gao
ebc80f6749
refactor(ast)!: change 'raw' from &str to Option<Atom> (#7547)
Fix #7254 

Changed all "raw" properties of literal types (if they have this property) to `Option<Atom>`.

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2024-12-05 00:34:45 +00:00
Boshen
b0e1c03284
feat(ast)!: add StringLiteral::raw field (#7393)
part of #7254
2024-11-26 23:33:56 +08:00
Boshen
f059b0e655 fix(ast)!: add missing ChainExpression from TSNonNullExpression (#7377)
closes #7375

* `foo?.bar!`
* `foo?.[bar]!`

`TSNonNullExpression` was not wrapped inside `ChainExpression`.
2024-11-20 15:54:28 +00:00
overlookmotel
c335f92ada perf(syntax): reorder operator enum variants (#7351)
Re-order enum variants of `AssignmentOperator`, `BinaryOperator` and `UnaryOperator`.

* `Exponential` moved to after `Remainder` (so with the rest of the arithmetic operators).
* `Shift*` operators follow arithmetic operators.
* `AssignmentOperator::Bitwise*` ops moved to before `Logical*` ops (so all ops which correspond to `BinaryOperator`s are together).
* `*Or` always before `*And`.
* Plus/Addition always before Minus/Subtraction.

The purpose is to make the various methods on these types maximally efficient:

1. Group together variants so that `AssignmentOperator::is_*` methods can be executed with the minimum number of operations (essentially `variant - min <= max`).
2. Align the variants of `AssignmentOperator` and `BinaryOperator` so that conversion methods added in #7350 become very cheap too (essentially `if variant - min <= max { Some(variant + offset) } else { None }`).
2024-11-19 01:23:28 +00:00
ottomated
897d3b1567 feat(ast): serialize StringLiterals to ESTree without raw (#7263)
#7211 alternative. Makes the `raw` field on estree literals optional.
2024-11-13 15:37:30 +00:00
overlookmotel
de472ca7c0 refactor(ast): move StringLiteral definition higher up (#7270)
Pure refactor. `StringLiteral` definition was sandwiched in the middle of RegExp-related code. Move it higher up in `literal.rs`.

All the rest of the diff is just re-ordering generated code.
2024-11-13 13:37:37 +00:00
Boshen
b11ed2cf7b refactor(ast)!: remove useless ObjectProperty::init field (#7220)
closes https://github.com/oxc-project/backlog/issues/143
2024-11-09 09:00:29 +00:00
Boshen
0e4adc15dd feat(ast)!: remove invalid expressions from TSEnumMemberName (#7219) 2024-11-09 08:48:14 +00:00
ottomated
092de67c47 fix(types)!: append rest field into elements for objects and arrays to align with estree (#7212)
Fixes https://github.com/oxc-project/oxc/pull/7149#discussion_r1831677446 and removes the need for some manual typescript.
2024-11-09 05:23:53 +00:00
ottomated
9d6cc9d3af feat(estree): ESTree compatibility for all literals (#7152)
Adds some new estree macro directives:
- `#[estree(via = foo::Foo)`: Uses From to convert this struct to foo::Foo before serialization
- `#[estree(add_ts = "foo: string")]`: Adds additional fields to the typescript definitions

Used these to make all different literals estree-compatible.
2024-11-06 21:25:41 +00:00
ottomated
dc0215c906 feat(ast_tools): Add #[estree(append_to)], remove some custom serialization code (#7149)
Removed custom logic for ObjectPattern, ArrayPattern, etc. in favor of a custom attribute macro `#[estree(append_to = "foo")]` as part of #6347
2024-11-06 21:09:45 +00:00
Boshen
caaf00e081 fix(parser): fix incorrect parsed TSIndexSignature (#7016)
closes #6985
2024-10-30 07:34:22 +00:00
ottomated
9725e3c2ec feat(ast_tools): Add #[estree(always_flatten)] to Span (#6935)
Part of #6347

Other changes:
- added #[estree(skip)] to thisSpan in TSThisParameter
- Flattened the span in BoundaryAssertion (regex)
2024-10-28 02:13:24 +00:00
overlookmotel
992699012f refactor(napi): move custom types to bottom of file (#6930)
Pure refactor. Doesn't matter much but I think it's preferable for the file not to start with the most random weird types.
2024-10-26 17:10:33 +00:00
overlookmotel
23157bde6f refactor(napi): types file in root of types package (#6929)
Move `types.d.ts` file to root of `@oxc-project/types` package. I think this is cleaner.
2024-10-26 17:10:31 +00:00
Renamed from npm/oxc-types/src/generated/types.d.ts (Browse further)