mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 22:22:34 +03:00
fix(es/parsing): Fix parsing of type satisfies = 0;
(#8305)
**Related issue:** - Closes #8121
This commit is contained in:
parent
a8bd170634
commit
51042e090d
@ -336,6 +336,19 @@ impl<'a, I: Tokens> Parser<I> {
|
||||
}
|
||||
}
|
||||
|
||||
tok!("type") => {
|
||||
if is_typescript
|
||||
&& peeked_is!(self, IdentName)
|
||||
&& !self.input.has_linebreak_between_cur_and_peeked()
|
||||
{
|
||||
let start = self.input.cur_pos();
|
||||
bump!(self);
|
||||
return Ok(Stmt::Decl(Decl::TsTypeAlias(
|
||||
self.parse_ts_type_alias_decl(start)?,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
tok!("enum") => {
|
||||
if is_typescript
|
||||
&& peeked_is!(self, IdentName)
|
||||
|
@ -1113,7 +1113,10 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
/// `tsParseTypeAliasDeclaration`
|
||||
fn parse_ts_type_alias_decl(&mut self, start: BytePos) -> PResult<Box<TsTypeAliasDecl>> {
|
||||
pub(super) fn parse_ts_type_alias_decl(
|
||||
&mut self,
|
||||
start: BytePos,
|
||||
) -> PResult<Box<TsTypeAliasDecl>> {
|
||||
debug_assert!(self.input.syntax().typescript());
|
||||
|
||||
let id = self.parse_ident_name()?;
|
||||
|
@ -0,0 +1 @@
|
||||
type satisfies = 0;
|
@ -0,0 +1,49 @@
|
||||
{
|
||||
"type": "Script",
|
||||
"span": {
|
||||
"start": 1,
|
||||
"end": 20,
|
||||
"ctxt": 0
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "TsTypeAliasDeclaration",
|
||||
"span": {
|
||||
"start": 1,
|
||||
"end": 20,
|
||||
"ctxt": 0
|
||||
},
|
||||
"declare": false,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"span": {
|
||||
"start": 6,
|
||||
"end": 15,
|
||||
"ctxt": 0
|
||||
},
|
||||
"value": "satisfies",
|
||||
"optional": false
|
||||
},
|
||||
"typeParams": null,
|
||||
"typeAnnotation": {
|
||||
"type": "TsLiteralType",
|
||||
"span": {
|
||||
"start": 18,
|
||||
"end": 19,
|
||||
"ctxt": 0
|
||||
},
|
||||
"literal": {
|
||||
"type": "NumericLiteral",
|
||||
"span": {
|
||||
"start": 18,
|
||||
"end": 19,
|
||||
"ctxt": 0
|
||||
},
|
||||
"value": 0.0,
|
||||
"raw": "0"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"interpreter": null
|
||||
}
|
Loading…
Reference in New Issue
Block a user