Commit graph

737 commits

Author SHA1 Message Date
Boshen
265b2fb640
feat: miette v7 (#2465) 2024-03-08 15:50:00 +08:00
magic-akari
8e3e4043bc
feat(prettier): print with_clause in reexport declaration (#2635) 2024-03-07 14:24:16 +08:00
magic-akari
17bc711bf0
fix(prettier): print bare import (#2633) 2024-03-07 14:03:20 +08:00
magic-akari
61afa70bb8
feat(prettier): print with_clause (#2632) 2024-03-07 12:22:30 +08:00
Boshen
240ff19675
refactor(parser): improve parsing of BindingPattern in TypeScript (#2624)
closes #2622
2024-03-06 16:16:03 +08:00
Boshen
1f14d946aa
chore: update Cargo.toml and deny.yaml 2024-03-05 16:31:05 +08:00
Arnaud Barré
97aa9cfd54
fix(parser): fix span end for TSEmptyBodyFunctionExpression (#2606)
https://oxc-project.github.io/oxc/playground/?code=3YCAAICXgICAgICAgICxG4jI43W9aqTWr3WzyAs1pNu4fnf%2FXXEB3Yt%2FfiBIgA%3D%3D

The conformance test are going back to initial state. I think the `.asi`
should be smarter, i can rethink that later

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-03-05 12:45:11 +08:00
Dunqing
7a12514151
fix(transformer/decorators): missing check private function (#2607) 2024-03-05 11:37:00 +08:00
Boshen
e2d2ce3369
feat(parser): parse decorators properly (#2603)
closes #2562
2024-03-04 19:30:41 +08:00
Boshen
ef932a3c27
refactor(codegen): clean up API around building sourcemaps (#2602)
closes #2564
2024-03-04 16:03:33 +08:00
Boshen
9cc960e591
fix(parser): fix duplicated comments during parser rewind (#2600)
closes #2592
2024-03-04 14:07:33 +08:00
Arnaud Barré
d9cc429d4a
fix(parser): parse empty method declaration as TSEmptyBodyFunctionExpression (#2574)
That a tricky one, because it's time to decide what does ESTree
compliant means in the TS world (re #2463)

This code:

```ts
export declare class ByteBuffer {
  clear(): void;
     // ^^
}
```

- Is parsed by
[Babel](d38530204e)
as `FunctionExpression` with an empty body
- By
[TS-ESLint](4ea4e2feb5)
as
[TSEmptyBodyFunctionExpression](https://github.com/typescript-eslint/typescript-eslint/pull/1289)
- By
[OXC](https://oxc-project.github.io/oxc/playground/?code=3YCAAIC1gICAgICAgICyHorESipoTXPdvBaE9wxzlOraoWs19SUxDvdcwSVU0kbBO2b7ppX3x2P5IhQlpGHOYEHNCEfLf38HUICA)
as `TSDeclareFunction`

I'm going the easy way to fix this to the Babel way, but I think
following TS-ESLint would make sense. There is an [open babel
issue](https://github.com/babel/babel/issues/13878) about that.

Edit: Ok that not so easy and require updating some logic.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-03-03 13:59:17 +00:00
Boshen
8bb1084863
feat(codegen): add sourcemap (#2565)
Co-authored-by: underfin <2218301630@qq.com>
2024-03-03 14:44:49 +08:00
Dunqing
6d43e851e8
feat(transformer/typescript): support transform constructor method (#2551) 2024-03-01 21:12:30 +08:00
Dunqing
25e03cb0ef
feat(tasks/transformer): enable typescript when the typescript plugin is provided (#2548)
Babel has many test cases that are js files, but in ts syntax.
2024-03-01 21:04:55 +08:00
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
Dunqing
f760108094
feat(transformer): call build module record (#2529) 2024-02-28 14:35:35 +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
Dunqing
cd75c1ca59
feat(transformer/decorators): insert only one private in expression (#2486) 2024-02-26 15:48:47 +08:00
Yuji Sugiura
f66fb886b3
fix(tasks/rulegen): Parse 'export default' test file for plugin-jsdoc (#2510) 2024-02-26 14:31:51 +08:00
renovate[bot]
29b213eac7
chore(deps): update rust crates (#2503) 2024-02-26 10:38:11 +08:00
Boshen
5212f7b51e
fix(parser): fix missing end span from TSTypeAliasDeclaration (#2485)
closes #2483
2024-02-24 16:51:00 +08:00
Dunqing
3d008abacb
feat(transformer/decorators): insert instanceBrand function (#2480) 2024-02-23 23:04:27 +08:00
Dunqing
2628c97eda
feat(transformer/decorators): transform getter function (#2473) 2024-02-23 10:11:45 +08:00
Boshen
d08abc638e refactor(ast): s/NumberLiteral/NumericLiteral to align with 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
Dunqing
197fa16613
feat(semantic): add check for duplicate class elements in checker (#2455)
1. Remove the check implementation of the parser
2. Implement it to semantic checker
3. Support typescript's check for duplicate class elements

Support checking for duplicate class elements in semantic checker is
easier to support typescript checking rules.
2024-02-21 14:10:19 +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
27b2c212c4
refactor(transformer/decorators): if it is a private method definition, transform it (#2427) 2024-02-19 19:17:11 +08:00
Dunqing
60db720fa6
feat(parser): parse import attributes in TSImportType (#2436)
close: #2394 

64d2eeea7b/src/compiler/types.ts (L2177-L2185)

The corresponding test cases were skipped, so I manually added some
cases to misc

f5db48237f/tasks/coverage/src/typescript.rs (L118-L121)
2024-02-19 12:26:42 +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
Boshen
83cb78fbb0
feat(coverage): add prettier idempotency test (#2403)
feat(coverage): add prettier idempotency test

closes #1329

feat(prettier_conformance): enable TypeScript
2024-02-12 16:20:09 +08:00
Boshen
1cbd7539fb
feat(coverage): add prettier idempotency test (#2402)
closes #1329
2024-02-12 15:30:16 +08:00
Boshen
70a0076eed
refactor: remove global allocator from non-user facing apps (#2401)
The runtime performance gains does not out weight the compilation speed from
building the custom allocators, which takes about a minute to build on
slower machines.
2024-02-12 14:09:05 +08:00
Dunqing
73e116e8a1
fix(parser): incorrect parsing of class accessor property name (#2386) 2024-02-11 22:57:13 +08:00
Boshen
9ff7986610
feat(prettier): handle binaryish expression in return statement (#2388) 2024-02-11 20:01:25 +08:00
Boshen
871a73afdd
fix(prettier): semi colon after class property (#2387) 2024-02-11 19:25:38 +08:00
Dunqing
0df7e296f9
feat(tasks/codegen): check node version >= 20 (#2385)
This syntax only works on node >= 20
`import value from './json-value-array_FIXTURE.json' with { type: 'json'
};`
2024-02-11 19:23:11 +08:00
Boshen
15a8857927
refactor(prettier): improve print_statement_sequence (#2383) 2024-02-11 00:16:26 +08:00
Boshen
82a6dc17d3
feat(pretter): implement print_binaryish_expressions (#2382) 2024-02-10 23:18:56 +08:00
Boshen
2dfe5210bb
fix(prettier): print strings as raw strings (#2380) 2024-02-10 17:52:17 +08:00
Boshen
642484e2cb
feat(prettier): print newlines between array expression elements (#2379) 2024-02-10 17:31:09 +08:00
Boshen
ef336cb66b
feat(parser): recover from async x [newline] => x (#2375)
```javascript
async x
=> x
```

Babel recovers and displays "No line break is allowed before '=>'
2024-02-10 11:19:08 +08:00
Boshen
70c983d4bb
feat(prettier): print rest parameters (#2370) 2024-02-09 22:59:28 +08:00
Boshen
9b6c313ebf
fix(prettier): flatten all binary expressions for now (#2367) 2024-02-09 21:48:27 +08:00
Boshen
90a834f87b
chore: update snapshot 2024-02-09 21:08:39 +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
e4754873ee
fix(prettier): printing value instead of key in BindingProperty (#2334)
fix: #2314
2024-02-08 21:49:10 +08:00
Boshen
5d9b0f3312
ci: speed up benchmark build (#2343)
closes #2299

Managed to figure out what `cargo codspeed build` is doing :-)
2024-02-08 19:47:50 +08:00
overlookmotel
aef593fb50
parser(refactor): promise only one Source on a thread at a time (#2340)
Introduce invariant that only a single `lexer::Source` can exist on a thread at one time.

This is a preparatory step for #2341.

2 notes:

Restriction is only 1 x `ParserImpl` / `Lexer` / `Source` on 1 *thread* at a time, not globally. So this does not prevent parsing multiple files simultaneously on different threads.

Restriction does not apply to public type `Parser`, only `ParserImpl`. `ParserImpl`s are not created in created in `Parser::new`, but instead in `Parser::parse`, where they're created and then immediately consumed. So the end user is also free to create multiple `Parser` instances (if they want to for some reason) on the same thread.
2024-02-08 14:51:17 +08:00