mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
fix: ts parsing error (#940)
Fixed https://github.com/web-infra-dev/oxc/issues/932
This commit is contained in:
parent
ea90128b9f
commit
266253c142
6 changed files with 12 additions and 24 deletions
|
|
@ -726,7 +726,7 @@ pub struct TSMappedType<'a> {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub type_parameter: Box<'a, TSTypeParameter<'a>>,
|
pub type_parameter: Box<'a, TSTypeParameter<'a>>,
|
||||||
pub name_type: Option<TSType<'a>>,
|
pub name_type: Option<TSType<'a>>,
|
||||||
pub type_annotation: TSType<'a>,
|
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
||||||
pub optional: TSMappedTypeModifierOperator,
|
pub optional: TSMappedTypeModifierOperator,
|
||||||
pub readonly: TSMappedTypeModifierOperator,
|
pub readonly: TSMappedTypeModifierOperator,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1407,7 +1407,7 @@ impl<'a> AstBuilder<'a> {
|
||||||
span: Span,
|
span: Span,
|
||||||
type_parameter: Box<'a, TSTypeParameter<'a>>,
|
type_parameter: Box<'a, TSTypeParameter<'a>>,
|
||||||
name_type: Option<TSType<'a>>,
|
name_type: Option<TSType<'a>>,
|
||||||
type_annotation: TSType<'a>,
|
type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
||||||
optional: TSMappedTypeModifierOperator,
|
optional: TSMappedTypeModifierOperator,
|
||||||
readonly: TSMappedTypeModifierOperator,
|
readonly: TSMappedTypeModifierOperator,
|
||||||
) -> TSType<'a> {
|
) -> TSType<'a> {
|
||||||
|
|
|
||||||
|
|
@ -1447,7 +1447,9 @@ pub trait Visit<'a>: Sized {
|
||||||
if let Some(name) = &ty.name_type {
|
if let Some(name) = &ty.name_type {
|
||||||
self.visit_ts_type(name);
|
self.visit_ts_type(name);
|
||||||
}
|
}
|
||||||
self.visit_ts_type(&ty.type_annotation);
|
if let Some(type_annotation) = &ty.type_annotation {
|
||||||
|
self.visit_ts_type_annotation(type_annotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ts_function_type(&mut self, ty: &'a TSFunctionType<'a>) {
|
fn visit_ts_function_type(&mut self, ty: &'a TSFunctionType<'a>) {
|
||||||
|
|
|
||||||
|
|
@ -1107,7 +1107,9 @@ pub trait VisitMut<'a, 'b>: Sized {
|
||||||
if let Some(name) = &mut ty.name_type {
|
if let Some(name) = &mut ty.name_type {
|
||||||
self.visit_ts_type(name);
|
self.visit_ts_type(name);
|
||||||
}
|
}
|
||||||
self.visit_ts_type(&mut ty.type_annotation);
|
if let Some(type_annotation) = &mut ty.type_annotation {
|
||||||
|
self.visit_ts_type_annotation(type_annotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ts_function_type(&mut self, ty: &'b mut TSFunctionType<'a>) {
|
fn visit_ts_function_type(&mut self, ty: &'b mut TSFunctionType<'a>) {
|
||||||
|
|
|
||||||
|
|
@ -656,9 +656,7 @@ impl<'a> Parser<'a> {
|
||||||
_ => TSMappedTypeModifierOperator::None,
|
_ => TSMappedTypeModifierOperator::None,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.expect(Kind::Colon)?;
|
let type_annotation = self.parse_ts_type_annotation()?;
|
||||||
let type_annotation = self.parse_ts_type()?;
|
|
||||||
|
|
||||||
self.bump(Kind::Semicolon);
|
self.bump(Kind::Semicolon);
|
||||||
self.expect(Kind::RCurly)?;
|
self.expect(Kind::RCurly)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
parser_typescript Summary:
|
parser_typescript Summary:
|
||||||
AST Parsed : 5060/5063 (99.94%)
|
AST Parsed : 5060/5063 (99.94%)
|
||||||
Positive Passed: 5051/5063 (99.76%)
|
Positive Passed: 5051/5063 (99.76%)
|
||||||
Negative Passed: 996/4761 (20.92%)
|
Negative Passed: 994/4761 (20.88%)
|
||||||
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"
|
||||||
|
|
@ -71,6 +71,7 @@ Expect Syntax Error: "compiler/anonymousClassExpression2.ts"
|
||||||
Expect Syntax Error: "compiler/anyDeclare.ts"
|
Expect Syntax Error: "compiler/anyDeclare.ts"
|
||||||
Expect Syntax Error: "compiler/anyIdenticalToItself.ts"
|
Expect Syntax Error: "compiler/anyIdenticalToItself.ts"
|
||||||
Expect Syntax Error: "compiler/anyIndexedAccessArrayNoException.ts"
|
Expect Syntax Error: "compiler/anyIndexedAccessArrayNoException.ts"
|
||||||
|
Expect Syntax Error: "compiler/anyMappedTypesError.ts"
|
||||||
Expect Syntax Error: "compiler/arguments.ts"
|
Expect Syntax Error: "compiler/arguments.ts"
|
||||||
Expect Syntax Error: "compiler/argumentsBindsToFunctionScopeArgumentList.ts"
|
Expect Syntax Error: "compiler/argumentsBindsToFunctionScopeArgumentList.ts"
|
||||||
Expect Syntax Error: "compiler/argumentsObjectIterator01_ES5.ts"
|
Expect Syntax Error: "compiler/argumentsObjectIterator01_ES5.ts"
|
||||||
|
|
@ -1104,6 +1105,7 @@ Expect Syntax Error: "compiler/logicalNotExpression1.ts"
|
||||||
Expect Syntax Error: "compiler/mappedTypeAsStringTemplate.ts"
|
Expect Syntax Error: "compiler/mappedTypeAsStringTemplate.ts"
|
||||||
Expect Syntax Error: "compiler/mappedTypeGenericWithKnownKeys.ts"
|
Expect Syntax Error: "compiler/mappedTypeGenericWithKnownKeys.ts"
|
||||||
Expect Syntax Error: "compiler/mappedTypeIndexedAccess.ts"
|
Expect Syntax Error: "compiler/mappedTypeIndexedAccess.ts"
|
||||||
|
Expect Syntax Error: "compiler/mappedTypeNoTypeNoCrash.ts"
|
||||||
Expect Syntax Error: "compiler/mappedTypeNotMistakenlyHomomorphic.ts"
|
Expect Syntax Error: "compiler/mappedTypeNotMistakenlyHomomorphic.ts"
|
||||||
Expect Syntax Error: "compiler/mappedTypeRecursiveInference.ts"
|
Expect Syntax Error: "compiler/mappedTypeRecursiveInference.ts"
|
||||||
Expect Syntax Error: "compiler/mappedTypeUnionConstrainTupleTreatedAsArrayLike.ts"
|
Expect Syntax Error: "compiler/mappedTypeUnionConstrainTupleTreatedAsArrayLike.ts"
|
||||||
|
|
@ -4045,14 +4047,6 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts"
|
||||||
╰────
|
╰────
|
||||||
help: Try insert a semicolon here
|
help: Try insert a semicolon here
|
||||||
|
|
||||||
× Expected `:` but found `}`
|
|
||||||
╭─[compiler/anyMappedTypesError.ts:2:1]
|
|
||||||
2 │
|
|
||||||
3 │ type Foo = {[P in "bar"]};
|
|
||||||
· ┬
|
|
||||||
· ╰── `:` expected
|
|
||||||
╰────
|
|
||||||
|
|
||||||
× 'arguments' is not allowed in class field initializer
|
× 'arguments' is not allowed in class field initializer
|
||||||
╭─[compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts:2:1]
|
╭─[compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts:2:1]
|
||||||
2 │ return class T {
|
2 │ return class T {
|
||||||
|
|
@ -7290,14 +7284,6 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts"
|
||||||
10 │ a.length;
|
10 │ a.length;
|
||||||
╰────
|
╰────
|
||||||
|
|
||||||
× Expected `)` but found `}`
|
|
||||||
╭─[compiler/mappedTypeNoTypeNoCrash.ts:1:1]
|
|
||||||
1 │ // @declaration: true
|
|
||||||
2 │ type T0<T> = ({[K in keyof T]}) extends ({[key in K]: T[K]}) ? number : never;
|
|
||||||
· ┬
|
|
||||||
· ╰── `)` expected
|
|
||||||
╰────
|
|
||||||
|
|
||||||
× Identifier `baz` has already been declared
|
× Identifier `baz` has already been declared
|
||||||
╭─[compiler/mismatchedClassConstructorVariable.ts:1:1]
|
╭─[compiler/mismatchedClassConstructorVariable.ts:1:1]
|
||||||
1 │ var baz: foo;
|
1 │ var baz: foo;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue