diff --git a/crates/oxc_parser/src/ts/types.rs b/crates/oxc_parser/src/ts/types.rs index a01872707a5f6..19018b5f06210 100644 --- a/crates/oxc_parser/src/ts/types.rs +++ b/crates/oxc_parser/src/ts/types.rs @@ -1,5 +1,6 @@ use oxc_allocator::{Box, Vec}; use oxc_ast::{NONE, ast::*}; +use oxc_span::GetSpan; use oxc_syntax::operator::UnaryOperator; use crate::{ @@ -649,9 +650,8 @@ impl<'a> ParserImpl<'a> { self.bump_any(); // bump `is` // TODO: this should go through the ast builder. let parameter_name = TSTypePredicateName::This(this_ty); - let type_span = self.start_span(); let ty = self.parse_ts_type(); - let type_annotation = Some(self.ast.ts_type_annotation(self.end_span(type_span), ty)); + let type_annotation = Some(self.ast.ts_type_annotation(ty.span(), ty)); self.ast.ts_type_type_predicate(self.end_span(span), parameter_name, false, type_annotation) } @@ -1051,10 +1051,9 @@ impl<'a> ParserImpl<'a> { fn parse_type_or_type_predicate(&mut self) -> TSType<'a> { let span = self.start_span(); let type_predicate_variable = self.try_parse(Self::parse_type_predicate_prefix); - let type_span = self.start_span(); let ty = self.parse_ts_type(); if let Some(parameter_name) = type_predicate_variable { - let type_annotation = Some(self.ast.ts_type_annotation(self.end_span(type_span), ty)); + let type_annotation = Some(self.ast.ts_type_annotation(ty.span(), ty)); return self.ast.ts_type_type_predicate( self.end_span(span), parameter_name, diff --git a/tasks/coverage/snapshots/estree_typescript.snap b/tasks/coverage/snapshots/estree_typescript.snap index bc51d413d9d86..a8bfb45ce03de 100644 --- a/tasks/coverage/snapshots/estree_typescript.snap +++ b/tasks/coverage/snapshots/estree_typescript.snap @@ -2,17 +2,7 @@ commit: 15392346 estree_typescript Summary: AST Parsed : 6480/6481 (99.98%) -Positive Passed: 6472/6481 (99.86%) -Mismatch: tasks/coverage/typescript/tests/cases/compiler/controlFlowInstanceofWithSymbolHasInstance.ts - -Mismatch: tasks/coverage/typescript/tests/cases/compiler/narrowingUnionToUnion.ts - -Mismatch: tasks/coverage/typescript/tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithRHSHasSymbolHasInstance.ts - -Mismatch: tasks/coverage/typescript/tests/cases/conformance/expressions/typeGuards/typeGuardNarrowsPrimitiveIntersection.ts - -Mismatch: tasks/coverage/typescript/tests/cases/conformance/expressions/typeGuards/typeGuardNarrowsToLiteralTypeUnion.ts - +Positive Passed: 6478/6481 (99.95%) Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/jsx/jsxReactTestSuite.tsx JSX expressions may not use the comma operator @@ -20,5 +10,3 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxReactEmitEnti Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxReactEmitNesting.tsx -Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags02.ts -