Commit graph

33 commits

Author SHA1 Message Date
Dunqing
cb8a272392 fix(isolated-declarations): cannot infer nested as const (#3807) 2024-06-21 10:20:17 +00:00
Dunqing
d8ecce5b3c fix(isolated-declarations): infer BigInt number as bigint type (#3806) 2024-06-21 10:20:13 +00:00
Dunqing
4e241fcda8 fix(isolated-declarations): missing const after transformed const enum (#3805) 2024-06-21 10:20:10 +00:00
Dunqing
683c7b0dd1 fix(isolated-declarations): shouldn’t add declare in declaration with export default (#3804)
Added tests in #3808
2024-06-21 10:20:06 +00:00
Dunqing
a37138f1ec feat(isolated-declarations): improve the inference template literal (#3797) 2024-06-20 15:02:45 +00:00
Dunqing
b0d7355c98 feat(isolated-declarations): transform const expression correctly (#3793) 2024-06-20 15:02:41 +00:00
Dunqing
2821e0e307 feat(codegen): print readonly keyword for TSIndexSignature (#3791) 2024-06-20 10:13:51 +00:00
Dunqing
7d47fc3fcc fix(isolated-declarations): should stripe async and generator keyword after transformed (#3790) 2024-06-20 10:13:44 +00:00
Dunqing
97575d8cab feat(codegen): print TSClassImplements and TSThisParameter (#3786)
close: https://github.com/oxc-project/oxc/issues/3692#issuecomment-2178994839
2024-06-20 06:15:23 +00:00
Dunqing
497769cb60 feat(ast): add some visitor functions (#3785) 2024-06-20 05:23:04 +00:00
Dunqing
b38c34dfce feat(isolated-declarations): support inferring ParenthesizedExpression (#3769) 2024-06-19 15:43:21 +00:00
Dunqing
8ce794d740 fix(isolated-declarations): inferring an incorrect return type when there is an arrow function inside a function (#3768) 2024-06-19 15:43:15 +00:00
Dunqing
4134de8dcf feat(isolated-declarations): add ts error code to the error message (#3755) 2024-06-19 14:33:29 +00:00
Dunqing
94202de250 feat(isolated-declarations): add export {} when needed (#3754)
https://github.com/microsoft/TypeScript/pull/58912
2024-06-19 14:33:27 +00:00
Dunqing
d29316a5ff fix(isolated-declarations): transform incorrectly when there are multiple functions with the same name (#3753) 2024-06-19 14:33:25 +00:00
Dunqing
e95d8e3990 feat(isolated-declarations): shrink span for arrow function that needs an explicit return type (#3752)
Current `span` we can't be consistent with typescript.

We report the following
```ts
(a, b) =>
^^^^^^^^^
{ }
^
```

TypeScript reports the following
```ts
(a, b) =>
^^^^^^^^^
{}
```

The TypeScript only reports the first line, if we want it to be exactly the same we need to find the first newline position
2024-06-19 14:33:24 +00:00
Dunqing
bf1c250d56 fix(isolated-declarations): false positives for non-exported binding elements (#3751) 2024-06-19 14:06:08 +00:00
Dunqing
df9971da4c feat(isolated-declarations): improve inferring the return type from function (#3750) 2024-06-19 14:06:05 +00:00
Dunqing
4aea2b158c feat(isolated-declarations): improve inferring the type of accessor (#3749) 2024-06-19 14:06:02 +00:00
Dunqing
9ea30c41ff feat(isolated-declarations): treat AssignmentPattern as optional (#3748) 2024-06-19 14:05:59 +00:00
Boshen
8c02c1dac3 chore(isolated-declarations): add snapshot testing (#3756) 2024-06-19 09:20:17 +00:00
github-actions[bot]
1b3cd6c24d
Release crates v0.15.0 (#3743)
## [0.15.0] - 2024-06-18

- 0537d29 cfg: [**BREAKING**] Move control flow to its own crate.
(#3728) (rzvxa)

- 5c38a0f codegen: [**BREAKING**] New code gen API (#3740) (Boshen)

- 4bce59d semantic/cfg: [**BREAKING**] Re-export `petgraph` as
`control_flow::graph`. (#3722) (rzvxa)

- 534242a codegen: [**BREAKING**] Remove
`CodegenOptions::enable_typescript` (#3674) (Boshen)

- 0578ece ast: [**BREAKING**] Remove
`ExportDefaultDeclarationKind::TSEnumDeclaration` (#3666) (Dunqing)

### Features

- 5a99d30 codegen: Improve codegen formatting (#3735) (Boshen)
- bf9b38a codegen: Improve codegen formatting (#3731) (Boshen)
- 4a004e2 codegen: Print TSImport remaining fields (#3695) (Dunqing)
- a56cb1b codegen: Print accessibility for MethodDefinition (#3690)
(Dunqing)
- 38a75e5 coverage: Improve codegen (#3729) (Boshen)
- 750a534 coverage: Transformer idempotency test (#3691) (Boshen)
- ee627c3 isolated-declarations: Create unique name for `_default`
(#3730) (Dunqing)
- 81e9526 isolated-declarations: Inferring set accessor parameter type
from get accessor return type (#3725) (Dunqing)
- 77d5533 isolated-declarations: Report errors that are consistent with
typescript. (#3720) (Dunqing)
- 8f5655d linter: Add eslint/no-useless-constructor (#3594) (Don Isaac)
- 046ff3f linter/eslint: Add `no_unreachable` rule. (#3238) (rzvxa)
- 0b8098a napi: Isolated-declaration (#3718) (Boshen)
- 527bfc8 npm/oxc-transform: Setup npm/oxc-transform and publish
(Boshen)
- d65c652 parser: Display jsx mismatch error, e.g. `<Foo></Bar>` (#3696)
(Boshen)
- 9c31ed9 semantic/cfg: Propagate unreachable edges through subgraphs.
(#3648) (rzvxa)
- d9c5b33 semantic/cfg: Add `Condition` instruction. (#3567) (Ali
Rezvani)
- f2dfd66 semantic/cfg: Add iteration instructions. (#3566) (rzvxa)
- 910193e transformer-dts: Report error for super class (#3711)
(Dunqing)
- 413d7be transformer-dts: Transform enum support (#3710) (Dunqing)
- 35c382e transformer-dts: Remove type annotation from private field
(#3689) (Dunqing)
- 0e6d3ce transformer-dts: Report error for async function and generator
(#3688) (Dunqing)
- b22b59a transformer-dts: Transform namespace support (#3683) (Dunqing)
- 4f2db46 transformer-dts: `--isolatedDeclarations` dts transform
(#3664) (Dunqing)

### Bug Fixes

- 2158268 ast: Incorrect visit order in function (#3681) (Dunqing)
- da1e2d0 codegen: Improve typescript codegen (#3708) (Boshen)
- f1b793f isolated-declarations: Function overloads reaching unreachable
(#3739) (Dunqing)
- 0fbecdc isolated-declarations: Should be added to references, not
bindings (#3726) (Dunqing)
- 8f64d99 minifier: Respect `join_vars: false` option (#3724)
(mysteryven)
- 70fc69b semantic: Add Eq to CtxFlags (#3651) (Yuji Sugiura)
- 7a58fec semantic/cfg: Issue in unlabeled `Ctx`s. (#3678) (rzvxa)
- abd6ac8 semantic/cfg: Discrete finalization path after `NewFunction`s.
(#3671) (rzvxa)
- e148a32 semantic/cfg: Correct unreachability propagation in
try-finally. (#3667) (Ali Rezvani)
- 59666e0 transformer: Do not rename accessible identifier references
(#3623) (Dunqing)
- 90743e2 traverse: Change visit order for `Function` (#3685)
(overlookmotel)

### Performance

- 2717a1a semantic/cfg: Lower the visits in
`neighbors_filtered_by_edge_weight`. (#3676) (rzvxa)

### Refactor

- fa7a6ba codegen: Add `gen` method to ast nodes (#3687) (Boshen)
- 09b92b6 codegen: Move `gen_ts` into `gen` to make searching things
easier (#3680) (Boshen)
- 3c59735 isolated-declarations: Remove `TransformDtsCtx` (#3719)
(Boshen)
- 815260e isolated-declarations: Decouple codegen (#3715) (Boshen)
- 7ec44f8 semantic: Rename `cfg` macro to `control_flow`. (#3742)
(rzvxa)
- d8ad321 semantic: Make control flow generation optional. (#3737)
(rzvxa)
- a94a72d semantic: Expose 1 checker function instead of 2 (#3694)
(Boshen)
- bd8d115 semantic/cfg: Remove unused types. (#3677) (rzvxa)
- f702fb9 semantic/cfg: Cleanup control flow and it's builder. (#3650)
(rzvxa)
- 4f16664 transformer_dts: Create a `Program` for codegen (#3679)
(Boshen)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-19 01:15:55 +08:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt 2024-06-19 00:48:30 +08:00
Dunqing
f1b793fbba fix(isolated-declarations): function overloads reaching unreachable (#3739) 2024-06-18 16:14:14 +00: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
Dunqing
ee627c355c feat(isolated-declarations): create unique name for _default (#3730) 2024-06-18 03:40:45 +00:00
Dunqing
0fbecdcd81 fix(isolated-declarations): should be added to references, not bindings (#3726) 2024-06-17 16:47:02 +00:00
Dunqing
81e952632d feat(isolated-declarations): inferring set accessor parameter type from get accessor return type (#3725) 2024-06-17 15:47:23 +00:00
Dunqing
77d553364d feat(isolated-declarations): report errors that are consistent with typescript. (#3720) 2024-06-17 13:53:19 +00:00
Boshen
3c597356e4 refactor(isolated-declarations): remove TransformDtsCtx (#3719) 2024-06-17 13:16:25 +00:00
Boshen
0b8098a442 feat(napi): isolated-declaration (#3718) 2024-06-17 13:06:00 +00:00
Boshen
815260ed2f refactor(isolated-declarations): decouple codegen (#3715) 2024-06-17 11:45:29 +00:00
Boshen
87c3282deb chore(transformer-dts): change crate to oxc_isolated_declarations (#3713) 2024-06-17 11:14:13 +00:00