mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 05:32:09 +03:00
TypeScript 4.1: intrinsic
keyword (#1193)
Co-authored-by: 강동윤 <kdy1997.dev@gmail.com>
This commit is contained in:
parent
5ef993d9b2
commit
11dbc1406c
@ -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"
|
||||
|
@ -620,6 +620,7 @@ in
|
||||
infer
|
||||
instanceof
|
||||
interface
|
||||
intrinsic
|
||||
is
|
||||
iterator
|
||||
key
|
||||
|
@ -382,6 +382,9 @@ pub enum TsKeywordTypeKind {
|
||||
|
||||
#[serde(rename = "never")]
|
||||
TsNeverKeyword,
|
||||
|
||||
#[serde(rename = "intrinsic")]
|
||||
TsIntrinsicKeyword,
|
||||
}
|
||||
|
||||
#[ast_node("TsThisType")]
|
||||
|
@ -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"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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")))
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
_ => {}
|
||||
@ -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
|
||||
};
|
||||
|
@ -10,3 +10,4 @@ let sy: symbol;
|
||||
let u: undefined;
|
||||
let v: void;
|
||||
let n: bigint;
|
||||
let i: intrinsic;
|
||||
|
@ -2,7 +2,7 @@
|
||||
"type": "Script",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 184,
|
||||
"end": 202,
|
||||
"ctxt": 0
|
||||
},
|
||||
"body": [
|
||||
@ -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
|
||||
|
@ -1394,6 +1394,7 @@ define!({
|
||||
TsUndefinedKeyword,
|
||||
TsNullKeyword,
|
||||
TsNeverKeyword,
|
||||
TsIntrinsicKeyword,
|
||||
}
|
||||
pub struct TsThisType {
|
||||
pub span: Span,
|
||||
|
Loading…
Reference in New Issue
Block a user