8000 fix(estree): Adjust span for `TSTypePredicate`.`typeAnnotation` by leaysgur · Pull Request #10711 · oxc-project/oxc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(estree): Adjust span for TSTypePredicate.typeAnnotation #10711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions crates/oxc_parser/src/ts/types.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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_predicat 8000 e_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,
Expand Down
14 changes: 1 addition & 13 deletions tasks/coverage/snapshots/estree_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,11 @@ 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

Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx

Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxReactEmitNesting.tsx

Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags02.ts

Loading
0