mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 12:51:57 +00:00
fix(parser): fix crash on TSTemplateLiteralType in function return position (#2089)
```
interface Helpers {
inspect(): `~~~~\n${string}\n~~~~`;
}
```
This commit is contained in:
parent
721a869b6e
commit
2f5afff9bd
5 changed files with 13 additions and 17 deletions
|
|
@ -197,17 +197,6 @@ pub enum TSTypeOperator {
|
||||||
Readonly,
|
Readonly,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TSTypeOperator {
|
|
||||||
pub fn from_src(src: &str) -> Option<Self> {
|
|
||||||
match src {
|
|
||||||
"keyof" => Some(Self::Keyof),
|
|
||||||
"unique" => Some(Self::Unique),
|
|
||||||
"readonly" => Some(Self::Readonly),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `let myArray: string[] = ["hello", "world"];`
|
/// `let myArray: string[] = ["hello", "world"];`
|
||||||
///
|
///
|
||||||
/// <https://www.typescriptlang.org/docs/handbook/2/objects.html#the-array-type>
|
/// <https://www.typescriptlang.org/docs/handbook/2/objects.html#the-array-type>
|
||||||
|
|
|
||||||
|
|
@ -302,8 +302,12 @@ impl<'a> Parser<'a> {
|
||||||
return self.parse_ts_infer_type();
|
return self.parse_ts_infer_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
let operator =
|
let operator = match self.cur_kind() {
|
||||||
if self.at(Kind::Str) { None } else { TSTypeOperator::from_src(self.cur_string()) };
|
Kind::KeyOf => Some(TSTypeOperator::Keyof),
|
||||||
|
Kind::Unique => Some(TSTypeOperator::Unique),
|
||||||
|
Kind::Readonly => Some(TSTypeOperator::Readonly),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
// test ts ts_type_operator
|
// test ts ts_type_operator
|
||||||
// type B = keyof A;
|
// type B = keyof A;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
codegen_misc Summary:
|
codegen_misc Summary:
|
||||||
AST Parsed : 9/9 (100.00%)
|
AST Parsed : 10/10 (100.00%)
|
||||||
Positive Passed: 9/9 (100.00%)
|
Positive Passed: 10/10 (100.00%)
|
||||||
|
|
|
||||||
3
tasks/coverage/misc/pass/oxc-2087.ts
Normal file
3
tasks/coverage/misc/pass/oxc-2087.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
interface Helpers {
|
||||||
|
inspect(): `~~~~\n${string}\n~~~~`;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
parser_misc Summary:
|
parser_misc Summary:
|
||||||
AST Parsed : 9/9 (100.00%)
|
AST Parsed : 10/10 (100.00%)
|
||||||
Positive Passed: 9/9 (100.00%)
|
Positive Passed: 10/10 (100.00%)
|
||||||
Negative Passed: 5/5 (100.00%)
|
Negative Passed: 5/5 (100.00%)
|
||||||
× Unexpected token
|
× Unexpected token
|
||||||
╭─[fail/oxc-169.js:1:1]
|
╭─[fail/oxc-169.js:1:1]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue