Skip to content
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
2 changes: 1 addition & 1 deletion atoms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_atoms"
repository = "https://github.com/swc-project/swc.git"
version = "0.2.4"
version = "0.2.5"

[dependencies]
string_cache = "0.8"
Expand Down
1 change: 1 addition & 0 deletions atoms/words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ in
infer
instanceof
interface
intrinsic
is
iterator
key
Expand Down
3 changes: 3 additions & 0 deletions ecmascript/ast/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ pub enum TsKeywordTypeKind {

#[serde(rename = "never")]
TsNeverKeyword,

#[serde(rename = "intrinsic")]
TsIntrinsicKeyword,
}

#[ast_node("TsThisType")]
Expand Down
1 change: 1 addition & 0 deletions ecmascript/codegen/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ impl<'a> Emitter<'a> {
TsKeywordTypeKind::TsUndefinedKeyword => keyword!(n.span, "undefined"),
TsKeywordTypeKind::TsNullKeyword => keyword!(n.span, "null"),
TsKeywordTypeKind::TsNeverKeyword => keyword!(n.span, "never"),
TsKeywordTypeKind::TsIntrinsicKeyword => keyword!(n.span, "intrinsic"),
}
}

Expand Down
3 changes: 3 additions & 0 deletions ecmascript/parser/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ macro_rules! tok {
("bigint") => {
crate::token::Token::Word(crate::token::Word::Ident(swc_atoms::js_word!("bigint")))
};
("intrinsic") => {
crate::token::Token::Word(crate::token::Word::Ident(swc_atoms::js_word!("intrinsic")))
};
("never") => {
crate::token::Token::Word(crate::token::Word::Ident(swc_atoms::js_word!("never")))
};
Expand Down
5 changes: 4 additions & 1 deletion ecmascript/parser/src/parser/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,8 @@ impl<I: Tokens> Parser<I> {
| js_word!("bigint")
| js_word!("symbol")
| js_word!("void")
| js_word!("never") => {
| js_word!("never")
| js_word!("intrinsic") => {
self.emit_err(id.span, SyntaxError::TS2427);
}
_ => {}
Expand Down Expand Up @@ -1773,6 +1774,8 @@ impl<I: Tokens> Parser<I> {
Some(TsKeywordTypeKind::TsUnknownKeyword)
} else if is!("undefined") {
Some(TsKeywordTypeKind::TsUndefinedKeyword)
} else if is!("intrinsic") {
Some(TsKeywordTypeKind::TsIntrinsicKeyword)
} else {
None
};
Expand Down
1 change: 1 addition & 0 deletions ecmascript/parser/tests/typescript/types/keywords/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ let sy: symbol;
let u: undefined;
let v: void;
let n: bigint;
let i: intrinsic;
51 changes: 50 additions & 1 deletion ecmascript/parser/tests/typescript/types/keywords/input.ts.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "Script",
"span": {
"start": 0,
"end": 184,
"end": 202,
"ctxt": 0
},
"body": [
Expand Down Expand Up @@ -593,6 +593,55 @@
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 185,
"end": 202,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 189,
"end": 201,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 189,
"end": 190,
"ctxt": 0
},
"value": "i",
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 190,
"end": 201,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 192,
"end": 201,
"ctxt": 0
},
"kind": "intrinsic"
}
},
"optional": false
},
"init": null,
"definite": false
}
]
}
],
"interpreter": null
Expand Down
1 change: 1 addition & 0 deletions ecmascript/visit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,7 @@ define!({
TsUndefinedKeyword,
TsNullKeyword,
TsNeverKeyword,
TsIntrinsicKeyword,
}
pub struct TsThisType {
pub span: Span,
Expand Down