fix: Fix bugs (#1516)

swc_ecma_ast:
 - Support TypeScript 4.3. (#1517)

swc_ecma_parser:
 - Support new syntaxes from typescript 4.3. (#1517) 

swc_ecma_transforms_compat:
 - Fix '\\`' in template literals. (#1488)
 - `classes`: Fix super calls. (#1490)

swc_ecma_transforms_module:
 - Respect `esModuleInterop` for dynamic imports. (#1480)

swc_ecma_transforms_typescript:
 - `strip`: Remove `declare`-d namespaces. (#1508)
This commit is contained in:
강동윤 2021-03-30 16:47:12 +09:00 committed by GitHub
parent 8b1f8dde4b
commit 51d0cef287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 1394 additions and 200 deletions

View File

@ -11,7 +11,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc"
repository = "https://github.com/swc-project/swc.git"
version = "0.12.2"
version = "0.13.0"
[lib]
name = "swc"
@ -29,12 +29,12 @@ serde_json = "1"
sourcemap = "6"
swc_atoms = {version = "0.2", path = "./atoms"}
swc_common = {version = "0.10.10", path = "./common", features = ["sourcemap", "concurrent"]}
swc_ecma_ast = {version = "0.41.0", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.49.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.9.0", path = "./ecmascript/ext-transforms"}
swc_ecma_parser = {version = "0.51.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.12.1", path = "./ecmascript/preset_env"}
swc_ecma_transforms = {version = "0.42.1", path = "./ecmascript/transforms", features = [
swc_ecma_ast = {version = "0.42.0", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.50.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.10.0", path = "./ecmascript/ext-transforms"}
swc_ecma_parser = {version = "0.52.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.13.0", path = "./ecmascript/preset_env"}
swc_ecma_transforms = {version = "0.43.0", path = "./ecmascript/transforms", features = [
"compat",
"module",
"optimization",
@ -42,8 +42,8 @@ swc_ecma_transforms = {version = "0.42.1", path = "./ecmascript/transforms", fea
"react",
"typescript",
]}
swc_ecma_utils = {version = "0.32.0", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.27.0", path = "./ecmascript/visit"}
swc_ecma_utils = {version = "0.33.0", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.28.0", path = "./ecmascript/visit"}
swc_visit = {version = "0.2.3", path = "./visit"}
[dev-dependencies]

View File

@ -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.29.2"
version = "0.30.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
@ -32,19 +32,19 @@ relative-path = "1.2"
retain_mut = "0.1.2"
swc_atoms = {version = "0.2.4", path = "../atoms"}
swc_common = {version = "0.10.10", path = "../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.49.0", path = "../ecmascript/codegen"}
swc_ecma_parser = {version = "0.51.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.42.1", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.32.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.27.0", path = "../ecmascript/visit"}
swc_ecma_ast = {version = "0.42.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.50.0", path = "../ecmascript/codegen"}
swc_ecma_parser = {version = "0.52.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.43.0", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.33.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.28.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.42.1", path = "../ecmascript/transforms", features = ["react", "typescript"]}
swc_ecma_transforms = {version = "0.43.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
tempfile = "3.1.0"
testing = {version = "0.10.3", path = "../testing"}
url = "2.1.1"

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecmascript"
repository = "https://github.com/swc-project/swc.git"
version = "0.28.1"
version = "0.29.0"
[package.metadata.docs.rs]
all-features = true
@ -27,12 +27,12 @@ react = ["swc_ecma_transforms/react"]
typescript = ["swc_ecma_transforms/typescript"]
[dependencies]
swc_ecma_ast = {version = "0.41.0", path = "./ast"}
swc_ecma_codegen = {version = "0.49.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.19.0", path = "./dep-graph", optional = true}
swc_ecma_parser = {version = "0.51.0", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.42.1", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.32.0", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.27.0", path = "./visit", optional = true}
swc_ecma_ast = {version = "0.42.0", path = "./ast"}
swc_ecma_codegen = {version = "0.50.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.20.0", path = "./dep-graph", optional = true}
swc_ecma_parser = {version = "0.52.0", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.43.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.33.0", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.28.0", path = "./visit", optional = true}
[dev-dependencies]

View File

@ -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.41.0"
version = "0.42.0"
[features]
default = []

View File

@ -52,16 +52,17 @@ pub use self::{
TsConditionalType, TsConstAssertion, TsConstructSignatureDecl, TsConstructorType,
TsEntityName, TsEnumDecl, TsEnumMember, TsEnumMemberId, TsExportAssignment,
TsExprWithTypeArgs, TsExternalModuleRef, TsFnOrConstructorType, TsFnParam, TsFnType,
TsImportEqualsDecl, TsImportType, TsIndexSignature, TsIndexedAccessType, TsInferType,
TsInterfaceBody, TsInterfaceDecl, TsIntersectionType, TsKeywordType, TsKeywordTypeKind,
TsLit, TsLitType, TsMappedType, TsMethodSignature, TsModuleBlock, TsModuleDecl,
TsModuleName, TsModuleRef, TsNamespaceBody, TsNamespaceDecl, TsNamespaceExportDecl,
TsNonNullExpr, TsOptionalType, TsParamProp, TsParamPropParam, TsParenthesizedType,
TsPropertySignature, TsQualifiedName, TsRestType, TsSignatureDecl, TsThisType,
TsThisTypeOrIdent, TsTplLitType, TsTupleElement, TsTupleType, TsType, TsTypeAliasDecl,
TsTypeAnn, TsTypeAssertion, TsTypeElement, TsTypeLit, TsTypeOperator, TsTypeOperatorOp,
TsTypeParam, TsTypeParamDecl, TsTypeParamInstantiation, TsTypePredicate, TsTypeQuery,
TsTypeQueryExpr, TsTypeRef, TsUnionOrIntersectionType, TsUnionType,
TsGetterSignature, TsImportEqualsDecl, TsImportType, TsIndexSignature, TsIndexedAccessType,
TsInferType, TsInterfaceBody, TsInterfaceDecl, TsIntersectionType, TsKeywordType,
TsKeywordTypeKind, TsLit, TsLitType, TsMappedType, TsMethodSignature, TsModuleBlock,
TsModuleDecl, TsModuleName, TsModuleRef, TsNamespaceBody, TsNamespaceDecl,
TsNamespaceExportDecl, TsNonNullExpr, TsOptionalType, TsParamProp, TsParamPropParam,
TsParenthesizedType, TsPropertySignature, TsQualifiedName, TsRestType, TsSetterSignature,
TsSignatureDecl, TsThisType, TsThisTypeOrIdent, TsTplLitType, TsTupleElement, TsTupleType,
TsType, TsTypeAliasDecl, TsTypeAnn, TsTypeAssertion, TsTypeElement, TsTypeLit,
TsTypeOperator, TsTypeOperatorOp, TsTypeParam, TsTypeParamDecl, TsTypeParamInstantiation,
TsTypePredicate, TsTypeQuery, TsTypeQueryExpr, TsTypeRef, TsUnionOrIntersectionType,
TsUnionType,
},
};
use serde::Deserialize;

View File

@ -144,6 +144,12 @@ pub enum TsTypeElement {
#[tag("TsPropertySignature")]
TsPropertySignature(TsPropertySignature),
#[tag("TsGetterSignature")]
TsGetterSignature(TsGetterSignature),
#[tag("TsSetterSignature")]
TsSetterSignature(TsSetterSignature),
#[tag("TsMethodSignature")]
TsMethodSignature(TsMethodSignature),
@ -193,6 +199,31 @@ pub struct TsPropertySignature {
pub type_params: Option<TsTypeParamDecl>,
}
#[ast_node("TsGetterSignature")]
#[derive(Eq, Hash, EqIgnoreSpan)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct TsGetterSignature {
pub span: Span,
pub readonly: bool,
pub key: Box<Expr>,
pub computed: bool,
pub optional: bool,
#[serde(default, rename = "typeAnnotation")]
pub type_ann: Option<TsTypeAnn>,
}
#[ast_node("TsSetterSignature")]
#[derive(Eq, Hash, EqIgnoreSpan)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct TsSetterSignature {
pub span: Span,
pub readonly: bool,
pub key: Box<Expr>,
pub computed: bool,
pub optional: bool,
pub param: TsFnParam,
}
#[ast_node("TsMethodSignature")]
#[derive(Eq, Hash, EqIgnoreSpan)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]

View File

@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_codegen"
repository = "https://github.com/swc-project/swc.git"
version = "0.49.1"
version = "0.50.0"
[dependencies]
bitflags = "1"
@ -15,9 +15,9 @@ num-bigint = {version = "0.2", features = ["serde"]}
sourcemap = "6"
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.10", path = "../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_ecma_codegen_macros = {version = "0.5.2", path = "./macros"}
swc_ecma_parser = {version = "0.51.0", path = "../parser"}
swc_ecma_parser = {version = "0.52.0", path = "../parser"}
[dev-dependencies]
swc_common = {version = "0.10.10", path = "../../common", features = ["sourcemap"]}

View File

@ -874,10 +874,46 @@ impl<'a> Emitter<'a> {
TsTypeElement::TsPropertySignature(n) => emit!(n),
TsTypeElement::TsMethodSignature(n) => emit!(n),
TsTypeElement::TsIndexSignature(n) => emit!(n),
TsTypeElement::TsGetterSignature(n) => {
emit!(n)
}
TsTypeElement::TsSetterSignature(n) => {
emit!(n)
}
}
formatting_semi!();
}
#[emitter]
fn emit_ts_getter_signature(&mut self, n: &TsGetterSignature) -> Result {
keyword!("get");
space!();
emit!(n.key);
punct!("(");
punct!(")");
if let Some(ty) = &n.type_ann {
punct!(":");
formatting_space!();
emit!(ty.type_ann);
}
}
#[emitter]
fn emit_ts_setter_signature(&mut self, n: &TsSetterSignature) -> Result {
keyword!("set");
space!();
emit!(n.key);
punct!("(");
emit!(n.param);
punct!(")");
}
#[emitter]
fn emit_ts_type_lit(&mut self, n: &TsTypeLit) -> Result {
self.emit_leading_comments_of_pos(n.span().lo())?;

View File

@ -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.19.0"
version = "0.20.0"
[dependencies]
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.10", path = "../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_visit = {version = "0.27.0", path = "../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_ecma_visit = {version = "0.28.0", path = "../visit"}
[dev-dependencies]
swc_ecma_parser = {version = "0.51.0", path = "../parser"}
swc_ecma_parser = {version = "0.52.0", path = "../parser"}
testing = {version = "0.10.3", path = "../../testing"}

View File

@ -5,7 +5,7 @@ documentation = "https://swc.rs/rustdoc/swc_ecma_ext_transforms/"
edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_ext_transforms"
version = "0.9.0"
version = "0.10.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -13,7 +13,7 @@ version = "0.9.0"
phf = {version = "0.8.0", features = ["macros"]}
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.10", path = "../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_parser = {version = "0.51.0", path = "../parser"}
swc_ecma_utils = {version = "0.32.0", path = "../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_ecma_parser = {version = "0.52.0", path = "../parser"}
swc_ecma_utils = {version = "0.33.0", path = "../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../visit"}

View File

@ -5,7 +5,7 @@ documentation = "https://swc.rs/rustdoc/jsdoc/"
edition = "2018"
license = "Apache-2.0/MIT"
name = "jsdoc"
version = "0.19.0"
version = "0.20.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -18,7 +18,7 @@ swc_common = {version = "0.10.10", path = "../../common"}
[dev-dependencies]
anyhow = "1"
dashmap = "3"
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_parser = {version = "0.51.0", path = "../parser"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_ecma_parser = {version = "0.52.0", path = "../parser"}
testing = {version = "0.10.3", path = "../../testing"}
walkdir = "2"

View File

@ -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.2.0"
version = "0.3.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.10", path = "../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_visit = {version = "0.27.0", path = "../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_ecma_visit = {version = "0.28.0", path = "../visit"}
[dev-dependencies]
testing = {version = "0.10.3", path = "../../testing"}

View File

@ -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.51.2"
version = "0.52.0"
[features]
default = []
@ -22,8 +22,8 @@ serde = {version = "1", features = ["derive"]}
smallvec = "1"
swc_atoms = {version = "0.2.3", path = "../../atoms"}
swc_common = {version = "0.10.10", path = "../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_visit = {version = "0.27.0", path = "../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_ecma_visit = {version = "0.28.0", path = "../visit"}
unicode-xid = "0.2"
[dev-dependencies]

View File

@ -53,6 +53,7 @@ pub enum SyntaxError {
ExpectedDigit {
radix: u8,
},
SetterParamRequired,
RestPatInSetter,
UnterminatedBlockComment,
@ -526,6 +527,7 @@ impl SyntaxError {
SyntaxError::TSTypeAnnotationAfterAssign => {
"Type annotations must come before default assignments".into()
}
SyntaxError::SetterParamRequired => "Setter should have exactly one parameter".into(),
}
}
}

View File

@ -362,6 +362,12 @@ macro_rules! tok {
("assert") => {
crate::token::Token::Word(crate::token::Word::Ident(swc_atoms::js_word!("assert")))
};
("get") => {
crate::token::Token::Word(crate::token::Word::Ident(swc_atoms::js_word!("get")))
};
("set") => {
crate::token::Token::Word(crate::token::Word::Ident(swc_atoms::js_word!("set")))
};
}
macro_rules! token_including_semi {

View File

@ -1,5 +1,6 @@
//! 13.3.3 Destructuring Binding Patterns
use super::{util::ExprExt, *};
use crate::parser::class_and_fn::is_not_this;
use crate::{parser::expr::PatOrExprOrSpread, token::AssignOpToken};
use std::iter;
use swc_atoms::js_word;
@ -346,6 +347,27 @@ impl<'a, I: Tokens> Parser<I> {
}
}
pub(super) fn parse_setter_param(&mut self, key_span: Span) -> PResult<Param> {
let params = self.parse_formal_params()?;
let cnt = params.iter().filter(|p| is_not_this(p)).count();
if cnt != 1 {
self.emit_err(key_span, SyntaxError::TS1094);
}
if !params.is_empty() {
if let Pat::Rest(..) = params[0].pat {
self.emit_err(params[0].pat.span(), SyntaxError::RestPatInSetter);
}
}
if params.is_empty() {
syntax_error!(self, SyntaxError::SetterParamRequired);
}
Ok(params.into_iter().next().unwrap())
}
pub(super) fn parse_formal_params(&mut self) -> PResult<Vec<Param>> {
let mut first = true;
let mut params = vec![];

View File

@ -1223,15 +1223,10 @@ impl<I: Tokens> Parser<I> {
}))
}
/// `tsParsePropertyOrMethodSignature`
fn parse_ts_property_or_method_signature(
&mut self,
start: BytePos,
readonly: bool,
) -> PResult<Either<TsPropertySignature, TsMethodSignature>> {
debug_assert!(self.input.syntax().typescript());
// ----- inlined self.parsePropertyName(node);
/// `parsePropertyName` in babel.
///
/// Returns `(computed, key)`.
fn parse_ts_property_name(&mut self) -> PResult<(bool, Box<Expr>)> {
let (computed, key) = if eat!(self, '[') {
let key = self.parse_assignment_expr()?;
expect!(self, ']');
@ -1258,7 +1253,19 @@ impl<I: Tokens> Parser<I> {
key.map(|key| (false, key))
})?
};
// -----
Ok((computed, key))
}
/// `tsParsePropertyOrMethodSignature`
fn parse_ts_property_or_method_signature(
&mut self,
start: BytePos,
readonly: bool,
) -> PResult<Either<TsPropertySignature, TsMethodSignature>> {
debug_assert!(self.input.syntax().typescript());
let (computed, key) = self.parse_ts_property_name()?;
let optional = eat!(self, '?');
@ -1334,6 +1341,61 @@ impl<I: Tokens> Parser<I> {
return Ok(idx.into());
}
if let Some(v) = self.try_parse_ts(|p| {
let start = p.input.cur_pos();
let reaodnly = p.parse_ts_modifier(&["readonly"])?.is_some();
let is_get = if eat!(p, "get") {
true
} else {
expect!(p, "set");
false
};
let (computed, key) = p.parse_ts_property_name()?;
let key_span = key.span();
let optional = eat!(p, '?');
if is_get {
expect!(p, '(');
expect!(p, ')');
let type_ann = p.try_parse_ts_type_ann()?;
p.parse_ts_type_member_semicolon()?;
Ok(Some(TsTypeElement::TsGetterSignature(TsGetterSignature {
span: span!(p, start),
readonly,
key,
computed,
optional,
type_ann,
})))
} else {
expect!(p, '(');
let params = p.parse_ts_binding_list_for_signature()?;
if params.is_empty() {
syntax_error!(p, SyntaxError::SetterParamRequired)
}
let param = params.into_iter().next().unwrap();
p.parse_ts_type_member_semicolon()?;
Ok(Some(TsTypeElement::TsSetterSignature(TsSetterSignature {
span: span!(p, start),
readonly,
key,
computed,
optional,
param,
})))
}
}) {
return Ok(v);
}
self.parse_ts_property_or_method_signature(start, readonly)
.map(|e| match e {
Either::Left(e) => e.into(),
@ -1707,6 +1769,8 @@ impl<I: Tokens> Parser<I> {
}
/// `tsParseBindingListForSignature`
///
/// Eats ')` at the end but does not eat `(` at start.
fn parse_ts_binding_list_for_signature(&mut self) -> PResult<Vec<TsFnParam>> {
debug_assert!(self.input.syntax().typescript());

View File

@ -0,0 +1,4 @@
interface X {
get foo(): string;
set foo(v: string | number);
}

View File

@ -0,0 +1,4 @@
type Y = {
get bar(): string;
set bar(v: string | number);
}

View File

@ -0,0 +1,2 @@
export abstract class AbstractProviderDeliveryService {
}

View File

@ -0,0 +1,45 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 57,
"ctxt": 0
},
"body": [
{
"type": "ExportDeclaration",
"span": {
"start": 0,
"end": 57,
"ctxt": 0
},
"declaration": {
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 22,
"end": 53,
"ctxt": 0
},
"value": "AbstractProviderDeliveryService",
"optional": false
},
"declare": false,
"span": {
"start": 7,
"end": 57,
"ctxt": 0
},
"decorators": [],
"body": [],
"superClass": null,
"isAbstract": true,
"typeParams": null,
"superTypeParams": null,
"implements": []
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,4 @@
interface X {
get foo(): string;
set foo(v: string | number);
}

View File

@ -0,0 +1,147 @@
{
"type": "Script",
"span": {
"start": 0,
"end": 67,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 0,
"end": 67,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 10,
"end": 11,
"ctxt": 0
},
"value": "X",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 12,
"end": 67,
"ctxt": 0
},
"body": [
{
"type": "TsGetterSignature",
"span": {
"start": 18,
"end": 36,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 22,
"end": 25,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 27,
"end": 35,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 29,
"end": 35,
"ctxt": 0
},
"kind": "string"
}
}
},
{
"type": "TsSetterSignature",
"span": {
"start": 37,
"end": 65,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 41,
"end": 44,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"param": {
"type": "Identifier",
"span": {
"start": 45,
"end": 63,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 46,
"end": 63,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 48,
"end": 63,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 48,
"end": 54,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 57,
"end": 63,
"ctxt": 0
},
"kind": "number"
}
]
}
}
}
}
]
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,4 @@
type Y = {
get bar(): string;
set bar(v: string | number);
}

View File

@ -0,0 +1,146 @@
{
"type": "Script",
"span": {
"start": 0,
"end": 64,
"ctxt": 0
},
"body": [
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 0,
"end": 64,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 5,
"end": 6,
"ctxt": 0
},
"value": "Y",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 9,
"end": 64,
"ctxt": 0
},
"members": [
{
"type": "TsGetterSignature",
"span": {
"start": 15,
"end": 33,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 19,
"end": 22,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"computed": false,
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 24,
"end": 32,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 26,
"end": 32,
"ctxt": 0
},
"kind": "string"
}
}
},
{
"type": "TsSetterSignature",
"span": {
"start": 34,
"end": 62,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 38,
"end": 41,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"computed": false,
"optional": false,
"param": {
"type": "Identifier",
"span": {
"start": 42,
"end": 60,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 43,
"end": 60,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 45,
"end": 60,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 45,
"end": 51,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 54,
"end": 60,
"ctxt": 0
},
"kind": "number"
}
]
}
}
}
}
]
}
}
],
"interpreter": null
}

View File

@ -5,7 +5,7 @@ documentation = "https://swc.rs/rustdoc/swc_ecma_preset_env/"
edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_preset_env"
version = "0.12.1"
version = "0.13.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -20,14 +20,14 @@ st-map = "0.1.2"
string_enum = {version = "0.3.1", path = "../../macros/string_enum"}
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.10", path = "../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_transforms = {version = "0.42.1", path = "../transforms", features = ["compat", "proposal"]}
swc_ecma_utils = {version = "0.32.0", path = "../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_ecma_transforms = {version = "0.43.0", path = "../transforms", features = ["compat", "proposal"]}
swc_ecma_utils = {version = "0.33.0", path = "../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../visit"}
walkdir = "2"
[dev-dependencies]
pretty_assertions = "0.6"
swc_ecma_codegen = {version = "0.49.0", path = "../codegen"}
swc_ecma_parser = {version = "0.51.0", path = "../parser"}
swc_ecma_codegen = {version = "0.50.0", path = "../codegen"}
swc_ecma_parser = {version = "0.52.0", path = "../parser"}
testing = {version = "0.10.3", path = "../../testing"}

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms"
repository = "https://github.com/swc-project/swc.git"
version = "0.42.1"
version = "0.43.0"
[package.metadata.docs.rs]
all-features = true
@ -23,24 +23,24 @@ typescript = ["swc_ecma_transforms_typescript"]
[dependencies]
swc_atoms = {version = "0.2.0", path = "../../atoms"}
swc_common = {version = "0.10.10", path = "../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_parser = {version = "0.51.0", path = "../parser"}
swc_ecma_transforms_base = {version = "0.9.0", path = "./base"}
swc_ecma_transforms_compat = {version = "0.10.1", path = "./compat", optional = true}
swc_ecma_transforms_module = {version = "0.10.1", path = "./module", optional = true}
swc_ecma_transforms_optimization = {version = "0.12.1", path = "./optimization", optional = true}
swc_ecma_transforms_proposal = {version = "0.10.1", path = "./proposal", optional = true}
swc_ecma_transforms_react = {version = "0.11.1", path = "./react", optional = true}
swc_ecma_transforms_typescript = {version = "0.11.1", path = "./typescript", optional = true}
swc_ecma_utils = {version = "0.32.0", path = "../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_ecma_parser = {version = "0.52.0", path = "../parser"}
swc_ecma_transforms_base = {version = "0.10.0", path = "./base"}
swc_ecma_transforms_compat = {version = "0.11.0", path = "./compat", optional = true}
swc_ecma_transforms_module = {version = "0.11.0", path = "./module", optional = true}
swc_ecma_transforms_optimization = {version = "0.13.0", path = "./optimization", optional = true}
swc_ecma_transforms_proposal = {version = "0.11.0", path = "./proposal", optional = true}
swc_ecma_transforms_react = {version = "0.12.0", path = "./react", optional = true}
swc_ecma_transforms_typescript = {version = "0.12.0", path = "./typescript", optional = true}
swc_ecma_utils = {version = "0.33.0", path = "../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../visit"}
unicode-xid = "0.2"
[dev-dependencies]
pretty_assertions = "0.6"
sourcemap = "6"
swc_ecma_codegen = {version = "0.49.0", path = "../codegen"}
swc_ecma_transforms_testing = {version = "0.9.0", path = "./testing"}
swc_ecma_codegen = {version = "0.50.0", path = "../codegen"}
swc_ecma_transforms_testing = {version = "0.10.0", path = "./testing"}
tempfile = "3"
testing = {version = "0.10.3", path = "../../testing"}
walkdir = "2"

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_base"
repository = "https://github.com/swc-project/swc.git"
version = "0.9.1"
version = "0.10.0"
[dependencies]
fxhash = "0.2.1"
@ -16,11 +16,11 @@ scoped-tls = "1.0.0"
smallvec = "1.6.0"
swc_atoms = {version = "0.2", path = "../../../atoms"}
swc_common = {version = "0.10.10", path = "../../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../../ast"}
swc_ecma_parser = {version = "0.51.0", path = "../../parser"}
swc_ecma_utils = {version = "0.32.0", path = "../../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../../ast"}
swc_ecma_parser = {version = "0.52.0", path = "../../parser"}
swc_ecma_utils = {version = "0.33.0", path = "../../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../../visit"}
[dev-dependencies]
swc_ecma_codegen = {version = "0.49.0", path = "../../codegen"}
swc_ecma_codegen = {version = "0.50.0", path = "../../codegen"}
testing = {version = "0.10.3", path = "../../../testing"}

View File

@ -709,11 +709,6 @@ impl<'a> VisitMut for Resolver<'a> {
f.return_type.visit_mut_with(self);
}
// TODO: How should I handle this?
typed!(visit_mut_ts_namespace_export_decl, TsNamespaceExportDecl);
track_ident_mut!();
fn visit_mut_ident(&mut self, i: &mut Ident) {
let ident_type = self.ident_type;
let in_type = self.in_type;
@ -790,6 +785,11 @@ impl<'a> VisitMut for Resolver<'a> {
self.ident_type = old;
}
// TODO: How should I handle this?
typed!(visit_mut_ts_namespace_export_decl, TsNamespaceExportDecl);
track_ident_mut!();
/// Leftmost one of a member expression should be resolved.
fn visit_mut_member_expr(&mut self, e: &mut MemberExpr) {
e.obj.visit_mut_with(self);
@ -997,6 +997,14 @@ impl<'a> VisitMut for Resolver<'a> {
ty.type_ann.visit_mut_with(&mut child);
}
fn visit_mut_ts_getter_signature(&mut self, n: &mut TsGetterSignature) {
if n.computed {
n.key.visit_mut_with(self);
}
n.type_ann.visit_mut_with(self);
}
fn visit_mut_ts_import_equals_decl(&mut self, n: &mut TsImportEqualsDecl) {
if !self.handle_types {
return;
@ -1132,6 +1140,14 @@ impl<'a> VisitMut for Resolver<'a> {
n.left.visit_mut_with(self)
}
fn visit_mut_ts_setter_signature(&mut self, n: &mut TsSetterSignature) {
if n.computed {
n.key.visit_mut_with(self);
}
n.param.visit_mut_with(self);
}
fn visit_mut_ts_tuple_element(&mut self, e: &mut TsTupleElement) {
if !self.handle_types {
return;

View File

@ -2345,3 +2345,35 @@ to_ts!(
}
"
);
to_ts!(
issue_1517_1,
"
interface X {
get foo(): string;
set foo(v: string | number);
}
",
"
interface X {
get foo__0(): string;
set foo__0(v: string | number);
}
"
);
to_ts!(
issue_1517_2,
"
type Y = {
get bar(): string;
set bar(v: string | number);
}
",
"
type Y = {
get bar__0(): string;
set bar__0(v: string | number);
}
"
);

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_compat"
repository = "https://github.com/swc-project/swc.git"
version = "0.10.1"
version = "0.11.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@ -20,13 +20,13 @@ serde = {version = "1.0.118", features = ["derive"]}
smallvec = "1.6.0"
swc_atoms = {version = "0.2.5", path = "../../../atoms"}
swc_common = {version = "0.10.10", path = "../../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../../ast"}
swc_ecma_transforms_base = {version = "0.9.0", path = "../base"}
swc_ecma_ast = {version = "0.42.0", path = "../../ast"}
swc_ecma_transforms_base = {version = "0.10.0", path = "../base"}
swc_ecma_transforms_macros = {version = "0.2.1", path = "../macros"}
swc_ecma_utils = {version = "0.32.0", path = "../../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../../visit"}
swc_ecma_utils = {version = "0.33.0", path = "../../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../../visit"}
[dev-dependencies]
swc_ecma_parser = {version = "0.51.0", path = "../../parser"}
swc_ecma_transforms_testing = {version = "0.9.0", path = "../testing"}
swc_ecma_parser = {version = "0.52.0", path = "../../parser"}
swc_ecma_transforms_testing = {version = "0.10.0", path = "../testing"}
testing = {version = "0.10.3", path = "../../../testing"}

View File

@ -186,7 +186,7 @@ impl<'a> Fold for SuperCalleeFolder<'a> {
span,
left: left.fold_children_with(self),
op,
right: right.fold_children_with(self),
right,
})
}
_ => n.fold_children_with(self),

View File

@ -39,7 +39,26 @@ impl Fold for TemplateLiteral {
// TODO: Optimize
// This makes result of addition string
let mut obj: Box<Expr> = Box::new(Lit::Str(quasis[0].raw.clone()).into());
let mut obj: Box<Expr> = Box::new(
Lit::Str({
let mut s = quasis[0]
.cooked
.clone()
.unwrap_or_else(|| quasis[0].raw.clone());
// See https://github.com/swc-project/swc/issues/1488
//
// This is hack to prevent '\\`'. Hack is used to avoid breaking
// change of ast crate.
if s.value.contains("`") {
s.kind = Default::default();
s.has_escape = false;
}
s
})
.into(),
);
let len = quasis.len() + exprs.len();
@ -59,7 +78,14 @@ impl Fold for TemplateLiteral {
match quasis.next() {
Some(TplElement { cooked, raw, .. }) => {
let s = cooked.unwrap_or_else(|| raw);
let mut s = cooked.unwrap_or_else(|| raw);
// See https://github.com/swc-project/swc/issues/1488
//
// This is hack to prevent '\\`'. Hack is used to avoid breaking
// change of ast crate.
if s.value.contains("`") {
s.kind = Default::default();
}
Box::new(Lit::Str(s).into())
}
_ => unreachable!(),

View File

@ -6062,3 +6062,71 @@ const obj = new OtherClass();
expect(obj.anotherMethod()).toBe(2);
"#
);
test!(
syntax(),
|_| classes(),
issue_1490_1,
"
class ColouredCanvasElement extends CanvasElement {
createFacets(hidden) {
hidden = super.createFacets(hidden);
}
}
",
"
let ColouredCanvasElement = function (CanvasElement) {
'use strict';
_inherits(ColouredCanvasElement, CanvasElement);
function ColouredCanvasElement() {
_classCallCheck(this, ColouredCanvasElement);
return _possibleConstructorReturn(this, \
_getPrototypeOf(ColouredCanvasElement).apply(this, arguments));
}
_createClass(ColouredCanvasElement, [
{
key: 'createFacets',
value: function createFacets(hidden) {
hidden = _get(_getPrototypeOf(ColouredCanvasElement.prototype), \
'createFacets', this).call(this, hidden);
}
}
]);
return ColouredCanvasElement;
}(CanvasElement);
"
);
test!(
syntax(),
|_| classes(),
issue_1490_2,
"
class ColouredCanvasElement extends CanvasElement {
createFacets(hidden) {
super.createFacets(hidden);
}
}
",
"
let ColouredCanvasElement = function (CanvasElement) {
'use strict';
_inherits(ColouredCanvasElement, CanvasElement);
function ColouredCanvasElement() {
_classCallCheck(this, ColouredCanvasElement);
return _possibleConstructorReturn(this, \
_getPrototypeOf(ColouredCanvasElement).apply(this, arguments));
}
_createClass(ColouredCanvasElement, [
{
key: 'createFacets',
value: function createFacets(hidden) {
_get(_getPrototypeOf(ColouredCanvasElement.prototype), 'createFacets', \
this).call(this, hidden);
}
}
]);
return ColouredCanvasElement;
}(CanvasElement);
"
);

View File

@ -928,3 +928,15 @@ test!(
",
ok_if_code_eq
);
test!(
syntax(),
|_| tr(Default::default()),
issue_1488_1,
"
`\\``
",
"
'`'
"
);

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_module"
repository = "https://github.com/swc-project/swc.git"
version = "0.10.1"
version = "0.11.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@ -16,13 +16,13 @@ indexmap = "1.6.1"
serde = {version = "1.0.118", features = ["derive"]}
swc_atoms = {version = "0.2", path = "../../../atoms"}
swc_common = {version = "0.10.10", path = "../../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../../ast"}
swc_ecma_parser = {version = "0.51.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.9.0", path = "../base"}
swc_ecma_utils = {version = "0.32.0", path = "../../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../../ast"}
swc_ecma_parser = {version = "0.52.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.10.0", path = "../base"}
swc_ecma_utils = {version = "0.33.0", path = "../../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../../visit"}
[dev-dependencies]
swc_ecma_transforms_compat = {version = "0.10.1", path = "../compat"}
swc_ecma_transforms_testing = {version = "0.9.0", path = "../testing/"}
swc_ecma_transforms_compat = {version = "0.11.0", path = "../compat"}
swc_ecma_transforms_testing = {version = "0.10.0", path = "../testing/"}
testing = {version = "0.10.3", path = "../../../testing/"}

View File

@ -694,14 +694,18 @@ impl ModulePass for CommonJs {
}
fn make_dynamic_import(&mut self, span: Span, args: Vec<ExprOrSpread>) -> Expr {
handle_dynamic_import(span, args)
handle_dynamic_import(span, args, !self.config.no_interop)
}
}
/// ```js
/// Promise.resolve().then(function () { return require('./foo'); })
/// ```
pub(super) fn handle_dynamic_import(span: Span, args: Vec<ExprOrSpread>) -> Expr {
pub(super) fn handle_dynamic_import(
span: Span,
args: Vec<ExprOrSpread>,
es_module_interop: bool,
) -> Expr {
let resolve_call = CallExpr {
span: DUMMY_SP,
callee: member_expr!(DUMMY_SP, Promise.resolve).as_callee(),
@ -730,12 +734,28 @@ pub(super) fn handle_dynamic_import(span: Span, args: Vec<ExprOrSpread>) -> Expr
span: DUMMY_SP,
stmts: vec![Stmt::Return(ReturnStmt {
span: DUMMY_SP,
arg: Some(Box::new(Expr::Call(CallExpr {
arg: Some({
let mut expr = Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: quote_ident!("require").as_callee(),
args,
type_args: Default::default(),
}))),
}));
if es_module_interop {
expr = Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: helper!(
interop_require_wildcard,
"interopRequireWildcard"
),
args: vec![expr.as_arg()],
type_args: Default::default(),
}));
}
expr
}),
})],
}),
},

View File

@ -775,7 +775,11 @@ impl ModulePass for Umd {
span,
test: Box::new(quote_ident!("exports").make_eq(quote_ident!("undefined"))),
cons: Box::new(super::amd::handle_dynamic_import(span, args.clone())),
alt: Box::new(super::common_js::handle_dynamic_import(span, args)),
alt: Box::new(super::common_js::handle_dynamic_import(
span,
args,
!self.config.config.no_interop,
)),
})
}
}

View File

@ -25,6 +25,7 @@ use swc_ecma_visit::Fold;
fn syntax() -> Syntax {
Syntax::Es(EsConfig {
dynamic_import: true,
top_level_await: true,
..Default::default()
})
}
@ -4131,7 +4132,7 @@ test!(
\"use strict\";
async function foo() {
await Promise.resolve().then(function() {
return require(\"foo\");
return _interopRequireWildcard(require('foo'));
});
}
"
@ -4580,3 +4581,41 @@ test!(
console.log(secondElement);
"
);
test!(
syntax(),
|_| tr(Config {
no_interop: false,
strict: true,
strict_mode: true,
lazy: Lazy::Bool(false)
}),
issue_1480_1,
"
const { default: ora } = await import('ora')
",
"
'use strict';
const { default: ora } = await Promise.resolve().then(function() {
return _interopRequireWildcard(require('ora'));
});
"
);
test!(
syntax(),
|_| tr(Config {
no_interop: false,
strict: true,
strict_mode: true,
lazy: Lazy::Bool(false)
}),
issue_1480_2,
"
import * as ora from 'ora'
",
"
'use strict';
var ora = _interopRequireWildcard(require('ora'));
"
);

View File

@ -1917,7 +1917,7 @@ test!(
reject(err);
});
}) : Promise.resolve().then(function() {
return require(\"foo\");
return _interopRequireWildcard(require(\"foo\"));
}));
}
});

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_optimization"
repository = "https://github.com/swc-project/swc.git"
version = "0.12.1"
version = "0.13.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@ -19,17 +19,17 @@ retain_mut = "0.1.2"
serde_json = "1.0.61"
swc_atoms = {version = "0.2", path = "../../../atoms"}
swc_common = {version = "0.10.10", path = "../../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../../ast"}
swc_ecma_parser = {version = "0.51.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.9.0", path = "../base"}
swc_ecma_utils = {version = "0.32.0", path = "../../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../../ast"}
swc_ecma_parser = {version = "0.52.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.10.0", path = "../base"}
swc_ecma_utils = {version = "0.33.0", path = "../../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../../visit"}
[dev-dependencies]
swc_ecma_transforms_compat = {version = "0.10.1", path = "../compat"}
swc_ecma_transforms_module = {version = "0.10.1", path = "../module"}
swc_ecma_transforms_proposal = {version = "0.10.1", path = "../proposal"}
swc_ecma_transforms_react = {version = "0.11.1", path = "../react"}
swc_ecma_transforms_testing = {version = "0.9.0", path = "../testing"}
swc_ecma_transforms_typescript = {version = "0.11.1", path = "../typescript"}
swc_ecma_transforms_compat = {version = "0.11.0", path = "../compat"}
swc_ecma_transforms_module = {version = "0.11.0", path = "../module"}
swc_ecma_transforms_proposal = {version = "0.11.0", path = "../proposal"}
swc_ecma_transforms_react = {version = "0.12.0", path = "../react"}
swc_ecma_transforms_testing = {version = "0.10.0", path = "../testing"}
swc_ecma_transforms_typescript = {version = "0.12.0", path = "../typescript"}
testing = {version = "0.10.0", path = "../../../testing"}

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_proposal"
repository = "https://github.com/swc-project/swc.git"
version = "0.10.1"
version = "0.11.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -21,14 +21,14 @@ serde = {version = "1.0.118", features = ["derive"]}
smallvec = "1.6.0"
swc_atoms = {version = "0.2", path = "../../../atoms"}
swc_common = {version = "0.10.10", path = "../../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../../ast"}
swc_ecma_loader = {version = "0.2.0", path = "../../loader", optional = true}
swc_ecma_parser = {version = "0.51.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.9.0", path = "../base"}
swc_ecma_utils = {version = "0.32.0", path = "../../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../../ast"}
swc_ecma_loader = {version = "0.3.0", path = "../../loader", optional = true}
swc_ecma_parser = {version = "0.52.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.10.0", path = "../base"}
swc_ecma_utils = {version = "0.33.0", path = "../../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../../visit"}
[dev-dependencies]
swc_ecma_transforms_compat = {version = "0.10.1", path = "../compat"}
swc_ecma_transforms_module = {version = "0.10.1", path = "../module"}
swc_ecma_transforms_testing = {version = "0.9.0", path = "../testing"}
swc_ecma_transforms_compat = {version = "0.11.0", path = "../compat"}
swc_ecma_transforms_module = {version = "0.11.0", path = "../module"}
swc_ecma_transforms_testing = {version = "0.10.0", path = "../testing"}

View File

@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_react"
repository = "https://github.com/swc-project/swc.git"
version = "0.11.2"
version = "0.12.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@ -18,14 +18,14 @@ serde = {version = "1.0.118", features = ["derive"]}
string_enum = {version = "0.3.1", path = "../../../macros/string_enum"}
swc_atoms = {version = "0.2", path = "../../../atoms"}
swc_common = {version = "0.10.10", path = "../../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../../ast"}
swc_ecma_parser = {version = "0.51.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.9.0", path = "../base"}
swc_ecma_utils = {version = "0.32.0", path = "../../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../../ast"}
swc_ecma_parser = {version = "0.52.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.10.0", path = "../base"}
swc_ecma_utils = {version = "0.33.0", path = "../../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../../visit"}
[dev-dependencies]
swc_ecma_transforms_compat = {version = "0.10.1", path = "../compat/"}
swc_ecma_transforms_module = {version = "0.10.1", path = "../module"}
swc_ecma_transforms_testing = {version = "0.9.0", path = "../testing/"}
swc_ecma_transforms_compat = {version = "0.11.0", path = "../compat/"}
swc_ecma_transforms_module = {version = "0.11.0", path = "../module"}
swc_ecma_transforms_testing = {version = "0.10.0", path = "../testing/"}
testing = {version = "0.10.3", path = "../../../testing"}

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_testing"
repository = "https://github.com/swc-project/swc.git"
version = "0.9.0"
version = "0.10.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -15,11 +15,11 @@ ansi_term = "0.12.1"
serde = "1"
serde_json = "1"
swc_common = {version = "0.10.10", path = "../../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../../ast"}
swc_ecma_codegen = {version = "0.49.0", path = "../../codegen"}
swc_ecma_parser = {version = "0.51.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.9.0", path = "../base"}
swc_ecma_utils = {version = "0.32.0", path = "../../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../../ast"}
swc_ecma_codegen = {version = "0.50.0", path = "../../codegen"}
swc_ecma_parser = {version = "0.52.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.10.0", path = "../base"}
swc_ecma_utils = {version = "0.33.0", path = "../../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../../visit"}
tempfile = "3.1.0"
testing = {version = "0.10.3", path = "../../../testing"}

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_typescript"
repository = "https://github.com/swc-project/swc.git"
version = "0.11.3"
version = "0.12.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@ -14,17 +14,17 @@ fxhash = "0.2.1"
serde = {version = "1.0.118", features = ["derive"]}
swc_atoms = {version = "0.2", path = "../../../atoms"}
swc_common = {version = "0.10.10", path = "../../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../../ast"}
swc_ecma_parser = {version = "0.51.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.9.0", path = "../base"}
swc_ecma_utils = {version = "0.32.0", path = "../../utils"}
swc_ecma_visit = {version = "0.27.0", path = "../../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../../ast"}
swc_ecma_parser = {version = "0.52.0", path = "../../parser"}
swc_ecma_transforms_base = {version = "0.10.0", path = "../base"}
swc_ecma_utils = {version = "0.33.0", path = "../../utils"}
swc_ecma_visit = {version = "0.28.0", path = "../../visit"}
[dev-dependencies]
swc_ecma_codegen = {version = "0.49.0", path = "../../codegen"}
swc_ecma_transforms_compat = {version = "0.10.1", path = "../compat"}
swc_ecma_transforms_module = {version = "0.10.1", path = "../module"}
swc_ecma_transforms_proposal = {version = "0.10.1", path = "../proposal/"}
swc_ecma_transforms_testing = {version = "0.9.0", path = "../testing"}
swc_ecma_codegen = {version = "0.50.0", path = "../../codegen"}
swc_ecma_transforms_compat = {version = "0.11.0", path = "../compat"}
swc_ecma_transforms_module = {version = "0.11.0", path = "../module"}
swc_ecma_transforms_proposal = {version = "0.11.0", path = "../proposal/"}
swc_ecma_transforms_testing = {version = "0.10.0", path = "../testing"}
testing = {version = "0.10.3", path = "../../../testing"}
walkdir = "2.3.1"

View File

@ -878,7 +878,7 @@ impl Strip {
/// Returns `(var_decl, init)`.
fn handle_ts_module(&mut self, module: TsModuleDecl) -> Option<(Option<Decl>, Stmt)> {
if module.global {
if module.global || module.declare {
return None;
}
let module_span = module.span;

View File

@ -3674,3 +3674,35 @@ to!(
_class);
"
);
to!(
issue_1508_1,
"
declare namespace twttr {
export const txt: typeof import('twitter-text')
}
",
""
);
to!(
issue_1517_1,
"
interface X {
get foo(): string;
set foo(v: string | number);
}
",
""
);
to!(
issue_1517_2,
"
type Y = {
get bar(): string;
set bar(v: string | number);
}
",
""
);

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_utils"
repository = "https://github.com/swc-project/swc.git"
version = "0.32.0"
version = "0.33.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -15,8 +15,8 @@ once_cell = "1"
scoped-tls = "1"
swc_atoms = {version = "0.2.0", path = "../../atoms"}
swc_common = {version = "0.10.10", path = "../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_visit = {version = "0.27.0", path = "../visit"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_ecma_visit = {version = "0.28.0", path = "../visit"}
unicode-xid = "0.2"
[dev-dependencies]

View File

@ -6,11 +6,11 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_visit"
repository = "https://github.com/swc-project/swc.git"
version = "0.27.0"
version = "0.28.0"
[dependencies]
num-bigint = {version = "0.2", features = ["serde"]}
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.10", path = "../../common"}
swc_ecma_ast = {version = "0.41.0", path = "../ast"}
swc_ecma_ast = {version = "0.42.0", path = "../ast"}
swc_visit = {version = "0.2.3", path = "../../visit"}

View File

@ -1309,6 +1309,8 @@ define!({
TsCallSignatureDecl(TsCallSignatureDecl),
TsConstructSignatureDecl(TsConstructSignatureDecl),
TsPropertySignature(TsPropertySignature),
TsGetterSignature(TsGetterSignature),
TsSetterSignature(TsSetterSignature),
TsMethodSignature(TsMethodSignature),
TsIndexSignature(TsIndexSignature),
}
@ -1335,6 +1337,24 @@ define!({
pub type_ann: Option<TsTypeAnn>,
pub type_params: Option<TsTypeParamDecl>,
}
pub struct TsGetterSignature {
pub span: Span,
pub readonly: bool,
pub key: Box<Expr>,
pub computed: bool,
pub optional: bool,
pub type_ann: Option<TsTypeAnn>,
}
pub struct TsSetterSignature {
pub span: Span,
pub readonly: bool,
pub key: Box<Expr>,
pub computed: bool,
pub optional: bool,
pub param: TsFnParam,
}
pub struct TsMethodSignature {
pub span: Span,
pub readonly: bool,

View File

@ -1,6 +1,6 @@
{
"name": "@swc/core",
"version": "1.2.51",
"version": "1.2.52",
"description": "Super-fast alternative for babel",
"homepage": "https://swc.rs",
"main": "./index.js",

View File

@ -0,0 +1,24 @@
{
"test": ".*.ts$",
"jsc": {
"loose": true,
"target": "es2018",
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": true,
"dynamicImport": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
}
},
"module": {
"type": "commonjs",
"strict": true,
"strictMode": false,
"lazy": false,
"noInterop": false
}
}

View File

@ -0,0 +1,2 @@
export abstract class AbstractProviderDeliveryService {
}

View File

@ -0,0 +1,3 @@
class AbstractProviderDeliveryService {
}
exports.AbstractProviderDeliveryService = AbstractProviderDeliveryService;

View File

@ -0,0 +1 @@
`\``

View File

@ -0,0 +1 @@
"`";

View File

@ -0,0 +1,11 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": true
}
},
"module": {
"type": "commonjs"
}
}

View File

@ -0,0 +1,6 @@
class ColouredCanvasElement extends CanvasElement {
createFacets(hidden) {
hidden = super.createFacets(hidden);
}
}

View File

@ -0,0 +1,101 @@
"use strict";
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for(var i = 0; i < props.length; i++){
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _possibleConstructorReturn(self, call) {
if (call && (_typeof(call) === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _superPropBase(object, property) {
while(!Object.prototype.hasOwnProperty.call(object, property)){
object = _getPrototypeOf(object);
if (object === null) break;
}
return object;
}
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
var ColouredCanvasElement = function(CanvasElement) {
"use strict";
_inherits(ColouredCanvasElement, CanvasElement);
function ColouredCanvasElement() {
_classCallCheck(this, ColouredCanvasElement);
return _possibleConstructorReturn(this, _getPrototypeOf(ColouredCanvasElement).apply(this, arguments));
}
_createClass(ColouredCanvasElement, [
{
key: "createFacets",
value: function createFacets(hidden) {
hidden = _get(_getPrototypeOf(ColouredCanvasElement.prototype), "createFacets", this).call(this, hidden);
}
}
]);
return ColouredCanvasElement;
}(CanvasElement);

View File

@ -0,0 +1,11 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": true
}
},
"module": {
"type": "commonjs"
}
}

View File

@ -0,0 +1,35 @@
"use strict";
class Element {
getChildElements() {
return this.childElements;
}
}
class CanvasElement extends Element {
createFacets(hidden) {
const childElements = this.getChildElements();
///
}
}
class ColouredCanvasElement extends CanvasElement {
createFacets(hidden) {
hidden = super.createFacets(hidden); ///
///
}
}
class ColouredSquare extends ColouredCanvasElement { }
const bugExample = () => {
const colouredSquare = new ColouredSquare(),
hidden = false;
colouredSquare.createFacets(hidden);
}
bugExample()

View File

@ -0,0 +1,201 @@
"use strict";
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [
null
];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _defineProperties(target, props) {
for(var i = 0; i < props.length; i++){
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _possibleConstructorReturn(self, call) {
if (call && (_typeof(call) === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _superPropBase(object, property) {
while(!Object.prototype.hasOwnProperty.call(object, property)){
object = _getPrototypeOf(object);
if (object === null) break;
}
return object;
}
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
_cache.set(Class, Wrapper);
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class);
};
return _wrapNativeSuper(Class);
}
var Element1 = function() {
function Element1() {
_classCallCheck(this, Element1);
}
_createClass(Element1, [
{
key: "getChildElements",
value: function getChildElements() {
return this.childElements;
}
}
]);
return Element1;
}();
var CanvasElement = function(Element1) {
_inherits(CanvasElement, Element1);
function CanvasElement() {
_classCallCheck(this, CanvasElement);
return _possibleConstructorReturn(this, _getPrototypeOf(CanvasElement).apply(this, arguments));
}
_createClass(CanvasElement, [
{
key: "createFacets",
value: function createFacets(hidden) {
var childElements = this.getChildElements();
}
}
]);
return CanvasElement;
}(_wrapNativeSuper(Element1));
var ColouredCanvasElement = function(CanvasElement) {
_inherits(ColouredCanvasElement, CanvasElement);
function ColouredCanvasElement() {
_classCallCheck(this, ColouredCanvasElement);
return _possibleConstructorReturn(this, _getPrototypeOf(ColouredCanvasElement).apply(this, arguments));
}
_createClass(ColouredCanvasElement, [
{
key: "createFacets",
value: function createFacets(hidden) {
hidden = _get(_getPrototypeOf(ColouredCanvasElement.prototype), "createFacets", this).call(this, hidden); ///
}
}
]);
return ColouredCanvasElement;
}(CanvasElement);
var ColouredSquare = function(ColouredCanvasElement) {
_inherits(ColouredSquare, ColouredCanvasElement);
function ColouredSquare() {
_classCallCheck(this, ColouredSquare);
return _possibleConstructorReturn(this, _getPrototypeOf(ColouredSquare).apply(this, arguments));
}
return ColouredSquare;
}(ColouredCanvasElement);
var bugExample = function() {
var colouredSquare = new ColouredSquare(), hidden = false;
colouredSquare.createFacets(hidden);
};
bugExample();

View File

@ -0,0 +1,8 @@
{
"jsc": {
"parser": {
"syntax": "typescript"
},
"target": "es2019"
}
}

View File

@ -0,0 +1,3 @@
declare namespace twttr {
export const txt: typeof import('twitter-text')
}

View File

@ -5,7 +5,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "wasm"
repository = "https://github.com/swc-project/swc.git"
version = "1.2.51"
version = "1.2.52"
[lib]
crate-type = ["cdylib"]