Skip to content

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

Merged
Boshen merged 2 commits intomainfrom
fix/typepredicate_span2
Apr 30, 2025
Merged

fix(estree): Adjust span for TSTypePredicate.typeAnnotation#10711
Boshen merged 2 commits intomainfrom
fix/typepredicate_span2

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Apr 30, 2025

Part of #9705

Given code like this:

function f(v): v is (1|2) {}

Currently, TSTypePredicate.type_annotation.span contains positions for ( and ), but it should not when preserveParens: false for TS-ESTree.

https://playground.oxc.rs/#eNptj01vgzAMhv8KyqmVkAp03QfnqddN25VLCKaKFBxkJ2wV478vKR/bob7EVl4/ft9RKFGK1qNy2mLS7oZ9mQyJ5mSX/xT7ZJwqPByK48Pp8en5JcvvdFGQLZVvVWx1rLBCkQorylGQx/jwFZ38FqUjD6kwGp0oW2k4DKxsD+sPX7vamnVyJJFbS90inlLRS2KgiJTG2K8PcJ7wzTvWDZyXVOt6TxC0A7xLAuQ/Rjx/Y4R+OzFDnaQLBG8CuMjyU0ih2RrpoHkFZSTJyP+HUraBC9wiAsrawKf1pKCT/WwiSDqNutXrPWXRkTXn4D0uDUC15RB/Bk7TL/T+ijY=


BTW, TypePredicate.type_annotation should be just TSType instead of TSTypeAnnotation(And generate extra TSTypeAnnotation for TS-ESTree)?

pub struct TSTypePredicate<'a> {
pub span: Span,
/// The identifier the predicate operates on
pub parameter_name: TSTypePredicateName<'a>,
/// Does this predicate include an `asserts` modifier?
///
/// ## Example
/// ```ts
/// declare function isString(x: any): asserts x is string; // true
/// ```
pub asserts: bool,
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
}

@graphite-app
Copy link
Contributor

graphite-app bot commented Apr 30, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-parser Area - Parser C-bug Category - Bug labels Apr 30, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 30, 2025

CodSpeed Instrumentation Performance Report

Merging #10711 will not alter performance

Comparing fix/typepredicate_span2 (0b35b3e) with main (7d8efd8)

Summary

✅ 33 untouched benchmarks
🆕 3 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 linter[RadixUIAdoptionSection.jsx] N/A 2.7 ms N/A
🆕 linter[cal.com.tsx] N/A 1.2 s N/A
🆕 linter[checker.ts] N/A 3.1 s N/A

@leaysgur leaysgur marked this pull request as ready for review April 30, 2025 08:34
@Boshen
Copy link
Member

Boshen commented Apr 30, 2025

BTW, TypePredicate.type_annotation should be just TSType instead of TSTypeAnnotation(And generate extra TSTypeAnnotation for TS-ESTree)?

Probably.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Apr 30, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Apr 30, 2025

Merge activity

  • Apr 30, 10:08 AM UTC: @leaysgur we removed the merge queue label because we could not find a Graphite account associated with your GitHub profile.

You must have a Graphite account in order to use the merge queue. Create an account and try again using this link

@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 30, 2025
@Boshen Boshen merged commit 7234ba4 into main Apr 30, 2025
37 checks passed
@Boshen Boshen deleted the fix/typepredicate_span2 branch April 30, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants