fix(parser): Handle JSDocUnknownType correctly#10363
Conversation
|
How should I handle diffs in parser coverage...? This is the same as #10346 (comment) , another one that "doesn't result in a parse error, but does result in a type check error". |
CodSpeed Instrumentation Performance ReportMerging #10363 will improve performances by 3.58%Comparing Summary
Benchmarks breakdown
|
|
Thank you. I think I got lazy with these AST nodes at the time of their writing :-) --
Add logic to https://github.com/oxc-project/oxc/blob/main/crates/oxc_semantic/src/checker/typescript.rs if you want to pass some typescript tests. In terms of the correct jargon to use, there is actually no parser error or type check error, they are all syntax errors. |
Maybe I've been using the wrong terms, but there seems to be a difference between the two. I don't understand this enum Foo {
[bar()],
}TS parser (and TS-ESLint parser) will both parse this without error - therefore I don't think it's a syntax error. But still it's not valid - you can't transform this to JS. That's what I was calling a "typecheck error" because it only gets flagged by TS when you enable type checking. Please correct me if I've got this wrong. We're probably going to encounter more of these cases as we continue with TS-ESTree compat work, so would be good to understand how we should be handling them. Taking off the merge label until we resolve this ambiguity. |
|
They parse (produce an AST) because tsc is a recoverable parser, it's a syntax error regardless where it's reported from. |
|
But doesn't TS usually report syntax error even when it recovers? Like in this case it reports an error during parsing: enum Foo {https://www.typescriptlang.org/play/?noCheck=true#code/KYOwrgtgBAYg9nKBvAUEA Whereas this is parsed without any error: enum Foo {
[bar()],
}Sorry if I'm labouring the point. I just want to make absolutely sure I understand, to avoid us making tons of changes, and later having to revert them. |
|
|
Current behavior:
TS parses this as
TypeReference > JSDocUnknownType.And also this PR fixes these:
to
This will result in the same behavior as TS and ESLint-TS.