Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(es/parser/typescript): allow override as parameter property #1667

Merged
merged 3 commits into from
May 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc"
repository = "https://github.com/swc-project/swc.git"
version = "0.18.0"
version = "0.19.0"

[lib]
name = "swc"
Expand All @@ -30,21 +30,21 @@ serde_json = "1"
sourcemap = "6"
swc_atoms = {version = "0.2", path = "./atoms"}
swc_common = {version = "0.10.16", path = "./common", features = ["sourcemap", "concurrent"]}
swc_ecma_ast = {version = "0.43.1", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.53.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.13.0", path = "./ecmascript/ext-transforms"}
swc_ecma_parser = {version = "0.55.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.18.0", path = "./ecmascript/preset_env"}
swc_ecma_transforms = {version = "0.48.0", path = "./ecmascript/transforms", features = [
swc_ecma_ast = {version = "0.44.0", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.54.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.14.0", path = "./ecmascript/ext-transforms"}
swc_ecma_parser = {version = "0.56.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.19.0", path = "./ecmascript/preset_env"}
swc_ecma_transforms = {version = "0.49.0", path = "./ecmascript/transforms", features = [
"compat",
"module",
"optimization",
"proposal",
"react",
"typescript",
]}
swc_ecma_utils = {version = "0.34.1", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.29.1", path = "./ecmascript/visit"}
swc_ecma_utils = {version = "0.35.0", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.30.0", path = "./ecmascript/visit"}
swc_node_base = {version = "0.1.0", path = "./node/base"}
swc_visit = {version = "0.2.3", path = "./visit"}

Expand Down
16 changes: 8 additions & 8 deletions bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"]
license = "Apache-2.0/MIT"
name = "swc_bundler"
repository = "https://github.com/swc-project/swc.git"
version = "0.35.0"
version = "0.36.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
Expand All @@ -33,19 +33,19 @@ relative-path = "1.2"
retain_mut = "0.1.2"
swc_atoms = {version = "0.2.4", path = "../atoms"}
swc_common = {version = "0.10.16", path = "../common"}
swc_ecma_ast = {version = "0.43.1", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.53.0", path = "../ecmascript/codegen"}
swc_ecma_parser = {version = "0.55.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.48.0", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.34.1", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.29.1", path = "../ecmascript/visit"}
swc_ecma_ast = {version = "0.44.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.54.0", path = "../ecmascript/codegen"}
swc_ecma_parser = {version = "0.56.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.49.0", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.35.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.30.0", path = "../ecmascript/visit"}

[dev-dependencies]
hex = "0.4"
ntest = "0.7.2"
reqwest = {version = "0.10.8", features = ["blocking"]}
sha-1 = "0.9"
swc_ecma_transforms = {version = "0.48.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
swc_ecma_transforms = {version = "0.49.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
tempfile = "3.1.0"
testing = {version = "0.10.5", path = "../testing"}
url = "2.1.1"
Expand Down
16 changes: 8 additions & 8 deletions ecmascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecmascript"
repository = "https://github.com/swc-project/swc.git"
version = "0.34.0"
version = "0.35.0"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -27,12 +27,12 @@ react = ["swc_ecma_transforms/react"]
typescript = ["swc_ecma_transforms/typescript"]

[dependencies]
swc_ecma_ast = {version = "0.43.1", path = "./ast"}
swc_ecma_codegen = {version = "0.53.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.23.0", path = "./dep-graph", optional = true}
swc_ecma_parser = {version = "0.55.0", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.48.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.34.1", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.29.1", path = "./visit", optional = true}
swc_ecma_ast = {version = "0.44.0", path = "./ast"}
swc_ecma_codegen = {version = "0.54.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.24.0", path = "./dep-graph", optional = true}
swc_ecma_parser = {version = "0.56.0", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.49.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.35.0", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.30.0", path = "./visit", optional = true}

[dev-dependencies]
2 changes: 1 addition & 1 deletion ecmascript/ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_ast"
repository = "https://github.com/swc-project/swc.git"
version = "0.43.1"
version = "0.44.0"

[features]
default = []
Expand Down
2 changes: 2 additions & 0 deletions ecmascript/ast/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pub struct TsParamProp {
/// At least one of `accessibility` or `readonly` must be set.
#[serde(default)]
pub accessibility: Option<Accessibility>,
#[serde(rename = "override")]
pub is_override: bool,
pub readonly: bool,
pub param: TsParamPropParam,
}
Expand Down
6 changes: 3 additions & 3 deletions ecmascript/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_codegen"
repository = "https://github.com/swc-project/swc.git"
version = "0.53.0"
version = "0.54.0"

[dependencies]
bitflags = "1"
num-bigint = {version = "0.2", features = ["serde"]}
sourcemap = "6"
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.43.1", path = "../ast"}
swc_ecma_ast = {version = "0.44.0", path = "../ast"}
swc_ecma_codegen_macros = {version = "0.5.2", path = "./macros"}
swc_ecma_parser = {version = "0.55.0", path = "../parser"}
swc_ecma_parser = {version = "0.56.0", path = "../parser"}

[dev-dependencies]
swc_common = {version = "0.10.16", path = "../../common", features = ["sourcemap"]}
Expand Down
5 changes: 5 additions & 0 deletions ecmascript/codegen/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,11 @@ impl<'a> Emitter<'a> {

self.emit_accesibility(n.accessibility)?;

if n.is_override {
keyword!("override");
space!();
}

if n.readonly {
keyword!("readonly");
space!();
Expand Down
8 changes: 4 additions & 4 deletions ecmascript/dep-graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_dep_graph"
repository = "https://github.com/swc-project/swc.git"
version = "0.23.0"
version = "0.24.0"

[dependencies]
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.43.1", path = "../ast"}
swc_ecma_visit = {version = "0.29.1", path = "../visit"}
swc_ecma_ast = {version = "0.44.0", path = "../ast"}
swc_ecma_visit = {version = "0.30.0", path = "../visit"}

[dev-dependencies]
swc_ecma_parser = {version = "0.55.0", path = "../parser"}
swc_ecma_parser = {version = "0.56.0", path = "../parser"}
testing = {version = "0.10.5", path = "../../testing"}
10 changes: 5 additions & 5 deletions ecmascript/ext-transforms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ documentation = "https://rustdoc.swc.rs/swc_ecma_ext_transforms/"
edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_ext_transforms"
version = "0.13.0"
version = "0.14.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
phf = {version = "0.8.0", features = ["macros"]}
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.43.1", path = "../ast"}
swc_ecma_parser = {version = "0.55.0", path = "../parser"}
swc_ecma_utils = {version = "0.34.1", path = "../utils"}
swc_ecma_visit = {version = "0.29.1", path = "../visit"}
swc_ecma_ast = {version = "0.44.0", path = "../ast"}
swc_ecma_parser = {version = "0.56.0", path = "../parser"}
swc_ecma_utils = {version = "0.35.0", path = "../utils"}
swc_ecma_visit = {version = "0.30.0", path = "../visit"}
6 changes: 3 additions & 3 deletions ecmascript/jsdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/jsdoc/"
edition = "2018"
license = "Apache-2.0/MIT"
name = "jsdoc"
version = "0.23.0"
version = "0.24.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -18,7 +18,7 @@ swc_common = {version = "0.10.16", path = "../../common"}
[dev-dependencies]
anyhow = "1"
dashmap = "4.0.2"
swc_ecma_ast = {version = "0.43.1", path = "../ast"}
swc_ecma_parser = {version = "0.55.0", path = "../parser"}
swc_ecma_ast = {version = "0.44.0", path = "../ast"}
swc_ecma_parser = {version = "0.56.0", path = "../parser"}
testing = {version = "0.10.5", path = "../../testing"}
walkdir = "2"
6 changes: 3 additions & 3 deletions ecmascript/loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_loader"
repository = "https://github.com/swc-project/swc.git"
version = "0.4.1"
version = "0.5.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
swc_atoms = {version = "0.2.3", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.43.1", path = "../ast"}
swc_ecma_visit = {version = "0.29.1", path = "../visit"}
swc_ecma_ast = {version = "0.44.0", path = "../ast"}
swc_ecma_visit = {version = "0.30.0", path = "../visit"}

[dev-dependencies]
testing = {version = "0.10.5", path = "../../testing"}
6 changes: 3 additions & 3 deletions ecmascript/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_parser"
repository = "https://github.com/swc-project/swc.git"
version = "0.55.0"
version = "0.56.0"

[features]
default = []
Expand All @@ -22,8 +22,8 @@ serde = {version = "1", features = ["derive"]}
smallvec = "1"
swc_atoms = {version = "0.2.3", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.43.1", path = "../ast"}
swc_ecma_visit = {version = "0.29.1", path = "../visit"}
swc_ecma_ast = {version = "0.44.0", path = "../ast"}
swc_ecma_visit = {version = "0.30.0", path = "../visit"}
unicode-xid = "0.2"

[dev-dependencies]
Expand Down
8 changes: 5 additions & 3 deletions ecmascript/parser/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,17 @@ impl<'a, I: Tokens> Parser<I> {
param_start: BytePos,
decorators: Vec<Decorator>,
) -> PResult<ParamOrTsParamProp> {
let (accessibility, readonly) = if self.input.syntax().typescript() {
let (accessibility, is_override, readonly) = if self.input.syntax().typescript() {
let accessibility = self.parse_access_modifier()?;
(
accessibility,
self.parse_ts_modifier(&["override"])?.is_some(),
self.parse_ts_modifier(&["readonly"])?.is_some(),
)
} else {
(None, false)
(None, false, false)
};
if accessibility == None && !readonly {
if accessibility == None && !is_override && !readonly {
let pat = self.parse_formal_param_pat()?;
Ok(ParamOrTsParamProp::Param(Param {
span: span!(self, param_start),
Expand All @@ -340,6 +341,7 @@ impl<'a, I: Tokens> Parser<I> {
Ok(ParamOrTsParamProp::TsParamProp(TsParamProp {
span: span!(self, param_start),
accessibility,
is_override,
readonly,
decorators,
param,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class C extends B {
constructor(override public v: string)
constructor(readonly override v: boolean)
constructor(arg: any) {
super()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error: Expected ,, got v
--> $DIR/tests/typescript-errors/class/override-parameter-property/input.ts:3:33
|
3 | constructor(readonly override v: boolean)
| ^

error: A parameter property is only allowed in a constructor implementation
--> $DIR/tests/typescript-errors/class/override-parameter-property/input.ts:2:24
|
2 | constructor(override public v: string)
| ^^^^^^^^^^^^^^^^

Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
}
],
"accessibility": "public",
"override": false,
"readonly": false,
"param": {
"type": "Identifier",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class C extends B {
constructor(override: Date)
constructor(override v: number)
constructor(public override v: string)
constructor(override readonly v: boolean)
constructor(arg: any) {
super()
}
}
Loading