Skip to content
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

fix(js_parser): fix "expected a declaration as guaranteed by is_at_ts_declare_statement" error for declare interface #4438

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

denbezrukov
Copy link
Contributor

Summary

Another problem from #342

Biome failed to parse

declare interface

Because the is_nth_at_declaration_clause function, which was a guarantee of valid parsing, has deviated from is_nth_at_ts_interface_declaration.

pub(crate) fn parse_ts_declare_statement(p: &mut JsParser) -> ParsedSyntax {
if !is_at_ts_declare_statement(p) {
return Absent;
}
let stmt_start_pos = p.cur_range().start();
let m = p.start();
p.expect(T![declare]);
p.with_state(EnterAmbientContext, |p| {
// test_err ts ts_declare_const_initializer
// declare @decorator class D {}
// declare @decorator abstract class D {}
parse_declaration_clause(p, stmt_start_pos)
.expect("Expected a declaration as guaranteed by is_at_ts_declare_statement")
});
Present(m.complete(p, TS_DECLARE_STATEMENT))
}

Test Plan

Added a new error test case
cargo test -p biome_js_parser

…_declare_statement" error for declare interface
@github-actions github-actions bot added A-Parser Area: parser L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Oct 31, 2024
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 48515 48515 0
Passed 47315 47315 0
Failed 1200 1200 0
Panics 0 0 0
Coverage 97.53% 97.53% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6580 6580 0
Passed 2205 2205 0
Failed 4375 4375 0
Panics 0 0 0
Coverage 33.51% 33.51% 0.00%

ts/babel

Test result main count This PR count Difference
Total 680 680 0
Passed 607 607 0
Failed 73 73 0
Panics 0 0 0
Coverage 89.26% 89.26% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18518 18518 0
Passed 14178 14178 0
Failed 4340 4340 0
Panics 0 0 0
Coverage 76.56% 76.56% 0.00%

Copy link

codspeed-hq bot commented Oct 31, 2024

CodSpeed Performance Report

Merging #4438 will improve performances by 8.57%

Comparing fix/declare-interface-err (41baf64) with main (3401663)

Summary

⚡ 1 improvements
✅ 98 untouched benchmarks

Benchmarks breakdown

Benchmark main fix/declare-interface-err Change
react.production.min_3378072959512366797.js[cached] 2 ms 1.8 ms +8.57%

@denbezrukov denbezrukov merged commit 185f491 into main Oct 31, 2024
13 checks passed
@denbezrukov denbezrukov deleted the fix/declare-interface-err branch October 31, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Parser Area: parser L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants