fix(swc): Fix bugs (#1753)

swc_ecma_parser:
 - Allow class members to be declared. (#1751)

node-swc:
 - Fix typescript type definitions. (#1746)
This commit is contained in:
강동윤 2021-05-27 11:59:04 +09:00 committed by GitHub
parent 8726c9caf2
commit c79db252dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 21 additions and 22 deletions

View File

@ -13,6 +13,7 @@ on: [push, pull_request]
# - 'trying' # - 'trying'
env: env:
CI: 1
CARGO_INCREMENTAL: 0 CARGO_INCREMENTAL: 0
RUST_LOG: "debug" RUST_LOG: "debug"
@ -80,7 +81,7 @@ jobs:
~/.cargo/ ~/.cargo/
target target
Cargo.lock Cargo.lock
key: ${{ runner.os }}-cargo-v3 key: ${{ runner.os }}-cargo-v4
# Ensure that all components are compilable. # Ensure that all components are compilable.
- name: Run cargo check for all targets - name: Run cargo check for all targets
run: cargo check --color always --all --all-targets run: cargo check --color always --all --all-targets
@ -204,7 +205,7 @@ jobs:
~/.cargo/ ~/.cargo/
target target
Cargo.lock Cargo.lock
key: ${{ runner.os }}-cargo-v3 key: ${{ runner.os }}-cargo-v4
- name: Run cargo test - name: Run cargo test
run: | run: |

View File

@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"]
license = "Apache-2.0/MIT" license = "Apache-2.0/MIT"
name = "swc_ecma_parser" name = "swc_ecma_parser"
repository = "https://github.com/swc-project/swc.git" repository = "https://github.com/swc-project/swc.git"
version = "0.57.1" version = "0.57.2"
[features] [features]
default = [] default = []

View File

@ -360,8 +360,6 @@ impl<'a, I: Tokens> Parser<I> {
false, false,
false, false,
); );
} else if accessibility.is_none() {
self.emit_err(self.input.prev_span(), SyntaxError::TS1031);
} }
} }

View File

@ -0,0 +1,3 @@
class Foo {
declare a: string
}

View File

@ -4,9 +4,3 @@ error: 'declare' modifier cannot be used with a private identifier
2 | declare #name; 2 | declare #name;
| ^^^^^ | ^^^^^
error: `declare` modifier cannot appear on a class element
--> $DIR/tests/typescript-errors/class/declare-private-name/input.ts:2:5
|
2 | declare #name;
| ^^^^^^^

View File

@ -1,9 +1,3 @@
error: `declare` modifier cannot appear on a class element
--> $DIR/tests/typescript-errors/class/override-with-declare/input.ts:2:3
|
2 | declare override m1(): any
| ^^^^^^^
error: 'override' modifier cannot be used with 'declare' modifier. error: 'override' modifier cannot be used with 'declare' modifier.
--> $DIR/tests/typescript-errors/class/override-with-declare/input.ts:2:11 --> $DIR/tests/typescript-errors/class/override-with-declare/input.ts:2:11
| |

View File

@ -1,6 +1,7 @@
{ {
"devDependencies": { "devDependencies": {
"jest": "^23.6.0", "@types/jest": "^26.0.23",
"jest": "^27.0.1",
"regenerator-runtime": "^0.11.0" "regenerator-runtime": "^0.11.0"
} }
} }

View File

@ -391,6 +391,11 @@ where
Command::new(&jest_path) Command::new(&jest_path)
}; };
// I hate windows.
if cfg!(target_os = "windows") && env::var("CI").is_ok() {
base_cmd.arg("--passWithNoTests");
}
let status = base_cmd let status = base_cmd
.args(&["--testMatch", &format!("{}", path.display())]) .args(&["--testMatch", &format!("{}", path.display())])
.current_dir(root) .current_dir(root)

View File

@ -10,8 +10,6 @@ import {
export * from "./types"; export * from "./types";
import { BundleInput, compileBundleOptions } from "./spack"; import { BundleInput, compileBundleOptions } from "./spack";
import { loadBinding } from "@node-rs/helper"; import { loadBinding } from "@node-rs/helper";
import * as babel from '@babel/types';
import { BabelifyOptions } from './babel';
const bindings = loadBinding(__dirname, "swc", "@swc/core") const bindings = loadBinding(__dirname, "swc", "@swc/core")

View File

@ -270,6 +270,11 @@ export interface JscConfig {
* Defaults to `es3` (which enableds **all** pass). * Defaults to `es3` (which enableds **all** pass).
*/ */
target?: JscTarget; target?: JscTarget;
/**
* Keep class names.
*/
keepClassNames?: boolean
} }
export type JscTarget = export type JscTarget =

View File

@ -67,12 +67,12 @@
"@napi-rs/cli": "^1.0.4", "@napi-rs/cli": "^1.0.4",
"@swc/helpers": "^0.2.10", "@swc/helpers": "^0.2.10",
"@types/browserslist": "^4.15.0", "@types/browserslist": "^4.15.0",
"@types/jest": "^25.2.3", "@types/jest": "^26.0.23",
"@types/node": "^14.14.41", "@types/node": "^14.14.41",
"axios": "^0.21.1", "axios": "^0.21.1",
"babel-plugin-transform-node-env-inline": "^0.4.3", "babel-plugin-transform-node-env-inline": "^0.4.3",
"browserslist": "^4.16.5", "browserslist": "^4.16.5",
"jest": "^23.6.0", "jest": "^27.0.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"progress": "^2.0.3", "progress": "^2.0.3",
"source-map": "^0.7.3", "source-map": "^0.7.3",