diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e66a4563c5..fb1f1238d5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -275,7 +275,11 @@ if no error diagnostics are emitted. - Fix [noUndeclaredVariables](https://docs.rome.tools/lint/rules/noundeclaredvariables/)'s false positive diagnostics ([#4675](https://github.com/rome/tools/issues/4675)) - The semantic analyzer no longer handles `this` reference identifier in the semantic analyzer. + The semantic analyzer no longer handles `this` reference identifier. + +- Fix [noUnusedVariables](https://docs.rome.tools/lint/rules/nounusedvariables/)'s false positive diagnostics ([#4688](https://github.com/rome/tools/issues/4688)) + + The semantic analyzer handles ts export declaration clause correctly. ### Parser diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts b/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts index 74aa023eda2..7d66f276d57 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts +++ b/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts @@ -6,4 +6,6 @@ export { a }; export function b() { } export const { A } = { A: 1 }; -export const [B] = [1]; \ No newline at end of file +export const [B] = [1]; + +export declare const valid; diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts.snap b/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts.snap index bdf7b3f4fec..b35953a87df 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts.snap +++ b/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts.snap @@ -13,6 +13,9 @@ export function b() { } export const { A } = { A: 1 }; export const [B] = [1]; + +export declare const valid; + ``` diff --git a/crates/rome_js_semantic/src/events.rs b/crates/rome_js_semantic/src/events.rs index b410cdefe2c..f343e5023bf 100644 --- a/crates/rome_js_semantic/src/events.rs +++ b/crates/rome_js_semantic/src/events.rs @@ -942,7 +942,7 @@ impl SemanticEventExtractor { .and_then(|declaration| declaration.parent()) .and_then(|declaration_clause| declaration_clause.parent()) .map(|x| x.kind()), - Some(JS_EXPORT) + Some(JS_EXPORT) | Some(TS_EXPORT_DECLARE_CLAUSE) ); if is_exported {