Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

fix(rome_js_semantic): correctly push/pop scopes for ts function types #3317

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/rome_js_semantic/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ impl SemanticEventExtractor {
| JS_FUNCTION_BODY
| TS_INTERFACE_DECLARATION
| TS_ENUM_DECLARATION
| TS_TYPE_ALIAS_DECLARATION => {
| TS_TYPE_ALIAS_DECLARATION
| TS_FUNCTION_TYPE => {
self.push_scope(
node.text_range(),
ScopeHoisting::DontHoistDeclarationsToParent,
Expand Down Expand Up @@ -486,6 +487,7 @@ impl SemanticEventExtractor {
| TS_INTERFACE_DECLARATION
| TS_ENUM_DECLARATION
| TS_TYPE_ALIAS_DECLARATION
| TS_FUNCTION_TYPE
| JS_BLOCK_STATEMENT
| JS_FOR_STATEMENT
| JS_FOR_OF_STATEMENT
Expand Down
7 changes: 7 additions & 0 deletions crates/rome_js_semantic/src/tests/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,10 @@ assert_semantics! {
ok_class_reference,
"class A/*#A*/ {} new A/*READ A*/();",
}

// Typescript types

assert_semantics! {
ok_typescript_function_type,
"function f (a/*#A1*/, b: (a/*#A2*/) => any) { return b(a/*READ A1*/); };",
}