Commit graph

2878 commits

Author SHA1 Message Date
Boshen
9e14c75e2a
chore: oxc_cfg.publish = true 2024-06-19 01:09:47 +08:00
rzvxa
7ec44f84a5 refactor(semantic): rename cfg macro to control_flow. (#3742)
As requested here https://github.com/oxc-project/oxc/pull/3737#discussion_r1644713121
2024-06-18 17:01:49 +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
Dunqing
f1b793fbba fix(isolated-declarations): function overloads reaching unreachable (#3739) 2024-06-18 16:14:14 +00:00
rzvxa
256acc949b
chore(semantic)!: no longer generate CFG by default. (#3738)
related but won't close #3641
2024-06-19 00:13:29 +08:00
rzvxa
d8ad321687 refactor(semantic): make control flow generation optional. (#3737)
For maximum backward compatibility, we generate CFG by default.

Note: It can't be done with a simple method since lifetimes make it impossible(at least without unsafe trickery) I've tried to do it without a macro but it was just unintuitive.
2024-06-18 15:59:38 +00:00
rzvxa
0537d298db refactor(cfg)!: move control flow to its own crate. (#3728) 2024-06-18 15:59:29 +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
Boshen
5a99d30eba feat(codegen): improve codegen formatting (#3735) 2024-06-18 11:10:36 +00:00
Wang Wenzhe
4d462636cb
feat(playground): support modify compressor's options (#3734)
![CleanShot 2024-06-18 at
16.18.02@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/nUl2MXIwjUWxxQRgpP2H/37eda403-b5af-44ad-8858-4693e60abbd1.png)
2024-06-18 18:49:16 +08:00
Boshen
bf9b38a197 feat(codegen): improve codegen formatting (#3731) 2024-06-18 04:14:10 +00:00
Dunqing
ee627c355c feat(isolated-declarations): create unique name for _default (#3730) 2024-06-18 03:40:45 +00:00
Boshen
38a75e559b feat(coverage): improve codegen (#3729) 2024-06-18 02:53:09 +00:00
Dunqing
0fbecdcd81 fix(isolated-declarations): should be added to references, not bindings (#3726) 2024-06-17 16:47:02 +00:00
mysteryven
8f64d9992f fix(minifier): respect join_vars: false option (#3724)
fix: #3705
2024-06-17 15:52:21 +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
rzvxa
4bce59df68 refactor(semantic/cfg)!: re-export petgraph as control_flow::graph. (#3722)
So we can replace or extend it easily.
2024-06-17 14:16:55 +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
rzvxa
080ecbd88d feat(linter): add no-fallthrough. (#3673)
[no-fallthrough](https://eslint.org/docs/latest/rules/no-fallthrough)

[oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9546510803)

related to #633 and closes #597
also related to #3662
2024-06-17 11:50:24 +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
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
da1e2d0e9b fix(codegen): improve typescript codegen (#3708)
Remaining issues are tracked in https://github.com/oxc-project/oxc/issues/3692
2024-06-17 09:34:54 +00:00
Dunqing
910193e0aa feat(transformer-dts): report error for super class (#3711) 2024-06-17 08:49:12 +00:00
Dunqing
413d7beb77 feat(transformer-dts): transform enum support (#3710) 2024-06-17 08:49:08 +00:00
mysteryven
9493fbef2c feat(linter): add oxc/no-optional-chaining rule (#3700)
To support: https://github.com/vuejs/core/pull/10919
2024-06-17 08:28:49 +00:00
mysteryven
139adfe7cb feat(linter): add @typescript-eslint/no-import-type-side_effects (#3699) 2024-06-17 08:25:20 +00:00
overlookmotel
90743e2a07
fix(traverse): change visit order for Function (#3685)
Alter `Traverse`'s visitation order for fields of `Function`, to match
the change made to `Visit` in #3681.
2024-06-17 10:45:36 +08:00
Dunqing
af5009a591
feat(transformer-dts): report error for invalid signature property key (#3698) 2024-06-16 16:10:14 +08:00
Boshen
d65c652700
feat(parser): display jsx mismatch error, e.g. <Foo></Bar> (#3696)
relates #3548 

I'll remove the closing name in a follow up PR.

The snapshot is incorrect, so I created a follow up issue:
https://github.com/oxc-project/oxc/issues/3697
2024-06-16 01:05:28 +08:00
Dunqing
4a004e2140 feat(codegen): print TSImport remaining fields (#3695)
```ts
type A = import("./a", { with: { "type": "json"}}).Name<T>
```
2024-06-15 16:25:27 +00:00
Boshen
a94a72dc68
refactor(semantic): expose 1 checker function instead of 2 (#3694) 2024-06-16 00:24:32 +08:00
Boshen
de0690f2e5
fix(linter): do not run getter-return in typescript (#3693) 2024-06-15 23:44:37 +08:00
Boshen
750a534455 feat(coverage): transformer idempotency test (#3691) 2024-06-15 13:59:53 +00:00
Dunqing
a56cb1b482 feat(codegen): print accessibility for MethodDefinition (#3690) 2024-06-15 13:34:29 +00:00
Dunqing
35c382ef24 feat(transformer-dts): remove type annotation from private field (#3689) 2024-06-15 13:34:27 +00:00
Dunqing
0e6d3ceee5 feat(transformer-dts): report error for async function and generator (#3688)
feat(transformer-dts): report error for async function and generator

fix(transformer-dts): correct span for type containing private name error

fix(transformer-dts): should add reference for export specifiers
2024-06-15 13:34:25 +00:00
Boshen
fa7a6babce refactor(codegen): add gen method to ast nodes (#3687) 2024-06-15 13:23:15 +00:00
Dunqing
b22b59ae12 feat(transformer-dts): transform namespace support (#3683)
This PR implements namespace transform:

Look at this example

```ts
let internal = 0;
export namespace ns {
    namespace internal {
        export class Foo {}
    }
    export namespace nested {
        export import inner = internal;
    }
}

// to

export declare namespace ns {
    namespace internal {
        class Foo {
        }
    }
    export namespace nested {
        export import inner = internal;
    }
    export {};
}

```

The `let internal = 0` is unexported, and is unreferenced in other types. So we need to remove it.

I refactored `scope` because the previous implementation could not correctly remove unexported and unreferenced declarations.

For example, in this case
```ts
type T = string;
export function foo<T>(): T {
}
// to
type T = string;
export declare function foo<T>(): T;
```
The `type T = string` should be deleted, Because the `T` is not used in the function return type.
2024-06-15 09:45:58 +00:00
Dunqing
215826874d fix(ast): incorrect visit order in function (#3681)
```ts
function hello<T>(a: T): T {
  return 0 as T
}
```

The `T` is a type parameter. It can be used in `FormalParameters`, `ReturnType`, and `FunctionBody`. Therefore we need to visit `type_parameters` before visiting `FormalParameters`, `ReturnType`, and `FunctionBody`
2024-06-15 09:45:57 +00:00
Boshen
09b92b6086 refactor(codegen): move gen_ts into gen to make searching things easier (#3680) 2024-06-15 06:44:14 +00:00
Boshen
4f166642a0 refactor(transformer_dts): create a Program for codegen (#3679) 2024-06-15 05:44:25 +00:00
rzvxa
2717a1a5b7 perf(semantic/cfg): lower the visits in neighbors_filtered_by_edge_weight. (#3676)
related to #3407
2024-06-14 16:48:01 +00:00
rzvxa
bd8d1152f1 refactor(semantic/cfg): remove unused types. (#3677) 2024-06-14 16:42:58 +00:00
rzvxa
7a58fec6b5 fix(semantic/cfg): issue in unlabeled Ctxs. (#3678)
[oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9519079285)
2024-06-14 16:38:49 +00:00
Boshen
eff9cff048 feat(coverage): add dts transform coverage test (#3675) 2024-06-14 14:29:27 +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