mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 12:51:57 +00:00
fix(parser): parse const extends in arrow functions correctly (#3450)
close: #3443
This commit is contained in:
parent
085f91761c
commit
cf41513d28
7 changed files with 18 additions and 20 deletions
|
|
@ -156,10 +156,13 @@ impl<'a> ParserImpl<'a> {
|
||||||
|
|
||||||
// JSX overrides
|
// JSX overrides
|
||||||
if self.source_type.is_jsx() {
|
if self.source_type.is_jsx() {
|
||||||
return match self.nth_kind(offset + 2) {
|
// <const Ident extends Ident>
|
||||||
|
// ^^^^^ Optional
|
||||||
|
offset += if second == Kind::Const { 3 } else { 2 };
|
||||||
|
return match self.nth_kind(offset) {
|
||||||
Kind::Extends => {
|
Kind::Extends => {
|
||||||
let third = self.nth_kind(offset + 3);
|
let third = self.nth_kind(offset + 1);
|
||||||
if matches!(third, Kind::Eq | Kind::RAngle) {
|
if matches!(third, Kind::Eq | Kind::RAngle | Kind::Slash) {
|
||||||
Tristate::False
|
Tristate::False
|
||||||
} else if third.is_binding_identifier() {
|
} else if third.is_binding_identifier() {
|
||||||
Tristate::Maybe
|
Tristate::Maybe
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
codegen_misc Summary:
|
codegen_misc Summary:
|
||||||
AST Parsed : 17/17 (100.00%)
|
AST Parsed : 18/18 (100.00%)
|
||||||
Positive Passed: 17/17 (100.00%)
|
Positive Passed: 18/18 (100.00%)
|
||||||
|
|
|
||||||
2
tasks/coverage/misc/pass/oxc-3443.tsx
Normal file
2
tasks/coverage/misc/pass/oxc-3443.tsx
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
const A = <const T extends F>() => {};
|
||||||
|
const B = <const T extends keyof F>() => {};
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
parser_misc Summary:
|
parser_misc Summary:
|
||||||
AST Parsed : 17/17 (100.00%)
|
AST Parsed : 18/18 (100.00%)
|
||||||
Positive Passed: 17/17 (100.00%)
|
Positive Passed: 18/18 (100.00%)
|
||||||
Negative Passed: 9/9 (100.00%)
|
Negative Passed: 9/9 (100.00%)
|
||||||
|
|
||||||
× Unexpected token
|
× Unexpected token
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ commit: 64d2eeea
|
||||||
parser_typescript Summary:
|
parser_typescript Summary:
|
||||||
AST Parsed : 5240/5243 (99.94%)
|
AST Parsed : 5240/5243 (99.94%)
|
||||||
Positive Passed: 5233/5243 (99.81%)
|
Positive Passed: 5233/5243 (99.81%)
|
||||||
Negative Passed: 1065/4879 (21.83%)
|
Negative Passed: 1064/4879 (21.81%)
|
||||||
Expect Syntax Error: "compiler/ClassDeclaration10.ts"
|
Expect Syntax Error: "compiler/ClassDeclaration10.ts"
|
||||||
Expect Syntax Error: "compiler/ClassDeclaration11.ts"
|
Expect Syntax Error: "compiler/ClassDeclaration11.ts"
|
||||||
Expect Syntax Error: "compiler/ClassDeclaration13.ts"
|
Expect Syntax Error: "compiler/ClassDeclaration13.ts"
|
||||||
|
|
@ -1388,6 +1388,7 @@ Expect Syntax Error: "compiler/paramterDestrcuturingDeclaration.ts"
|
||||||
Expect Syntax Error: "compiler/parenthesizedJSDocCastDoesNotNarrow.ts"
|
Expect Syntax Error: "compiler/parenthesizedJSDocCastDoesNotNarrow.ts"
|
||||||
Expect Syntax Error: "compiler/parseCommaSeparatedNewlineNumber.ts"
|
Expect Syntax Error: "compiler/parseCommaSeparatedNewlineNumber.ts"
|
||||||
Expect Syntax Error: "compiler/parseCommaSeparatedNewlineString.ts"
|
Expect Syntax Error: "compiler/parseCommaSeparatedNewlineString.ts"
|
||||||
|
Expect Syntax Error: "compiler/parseJsxExtends2.ts"
|
||||||
Expect Syntax Error: "compiler/parseTypes.ts"
|
Expect Syntax Error: "compiler/parseTypes.ts"
|
||||||
Expect Syntax Error: "compiler/parseUnaryExpressionNoTypeAssertionInJsx1.ts"
|
Expect Syntax Error: "compiler/parseUnaryExpressionNoTypeAssertionInJsx1.ts"
|
||||||
Expect Syntax Error: "compiler/parseUnaryExpressionNoTypeAssertionInJsx3.ts"
|
Expect Syntax Error: "compiler/parseUnaryExpressionNoTypeAssertionInJsx3.ts"
|
||||||
|
|
@ -8517,14 +8518,6 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts"
|
||||||
5 │
|
5 │
|
||||||
╰────
|
╰────
|
||||||
|
|
||||||
× Unexpected token
|
|
||||||
╭─[compiler/parseJsxExtends2.ts:8:22]
|
|
||||||
7 │ // Error: T is not declared.
|
|
||||||
8 │ return <T extends/>
|
|
||||||
· ─
|
|
||||||
9 │ }
|
|
||||||
╰────
|
|
||||||
|
|
||||||
× Unexpected token
|
× Unexpected token
|
||||||
╭─[compiler/parseUnaryExpressionNoTypeAssertionInJsx2.ts:7:14]
|
╭─[compiler/parseUnaryExpressionNoTypeAssertionInJsx2.ts:7:14]
|
||||||
6 │ const x = "oops";
|
6 │ const x = "oops";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
prettier_misc Summary:
|
prettier_misc Summary:
|
||||||
AST Parsed : 17/17 (100.00%)
|
AST Parsed : 18/18 (100.00%)
|
||||||
Positive Passed: 10/17 (58.82%)
|
Positive Passed: 11/18 (61.11%)
|
||||||
Expect to Parse: "pass/oxc-1740.tsx"
|
Expect to Parse: "pass/oxc-1740.tsx"
|
||||||
Expect to Parse: "pass/oxc-2087.ts"
|
Expect to Parse: "pass/oxc-2087.ts"
|
||||||
Expect to Parse: "pass/oxc-2394.ts"
|
Expect to Parse: "pass/oxc-2394.ts"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
transformer_misc Summary:
|
transformer_misc Summary:
|
||||||
AST Parsed : 17/17 (100.00%)
|
AST Parsed : 18/18 (100.00%)
|
||||||
Positive Passed: 17/17 (100.00%)
|
Positive Passed: 18/18 (100.00%)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue