fix(parser): TSConditionalType span start (#2570)

Span start should be the checkType.start

(as all my PR, I try to make it work, don't hesitate to close and to it
in a better way)


[playground](https://oxc-project.github.io/oxc/playground/?code=3YCAAIDFgICAgICAgIC6nsrEgtelB%2FCnUFVHa8WBImPvKP4Ye3U5jBKASUfm8OtkXZASTLptdPlvM%2Fult4BgRbjIq3Yts9L2pZ%2FhVs8hMF%2Bwpqd%2FfdHggA%3D%3D)
This commit is contained in:
Arnaud Barré 2024-03-03 07:25:55 +01:00 committed by GitHub
parent 2263377e3f
commit 32028eb1c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@ use bitflags::bitflags;
use oxc_allocator::{Box, Vec};
use oxc_ast::ast::*;
use oxc_diagnostics::Result;
use oxc_span::Span;
use oxc_syntax::operator::UnaryOperator;
use super::list::{
@ -116,9 +117,10 @@ impl<'a> ParserImpl<'a> {
return self.parse_ts_function_type();
}
let left_span = self.start_span();
let left = self.parse_ts_union_type()?;
self.parse_ts_conditional_type(left)
self.parse_ts_conditional_type(left_span, left)
}
pub(crate) fn parse_ts_type_parameters(
@ -209,8 +211,11 @@ impl<'a> ParserImpl<'a> {
Ok(Some(self.parse_ts_type()?))
}
fn parse_ts_conditional_type(&mut self, left: TSType<'a>) -> Result<TSType<'a>> {
let span = self.start_span();
fn parse_ts_conditional_type(
&mut self,
left_span: Span,
left: TSType<'a>,
) -> Result<TSType<'a>> {
if !self.ctx.has_disallow_conditional_types()
&& !self.cur_token().is_on_new_line
&& self.eat(Kind::Extends)
@ -229,7 +234,7 @@ impl<'a> ParserImpl<'a> {
self.without_context(Context::DisallowConditionalTypes, Self::parse_ts_type)?;
return Ok(self.ast.ts_conditional_type(
self.end_span(span),
self.end_span(left_span),
left,
extends_type,
true_type,