Repository: rome/tools (Rust)

Issue:
🐛 noUnusedVariables incorrect in TS function with callback with same argument name
### Environment information

```bash
Rome Extension: v0.14.0
No Rome CLI installed globally or locally,

VSCode Env Info:
Version: 1.71.0 (system setup)
Commit: 784b0177c56c607789f9638da7b6bf3230d47a8c
Date: 2022-09-01T07:36:10.600Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19044
Sandboxed: No
```


### What happened?

1. Set up a function with 2 arguments, where the second argument is a function that takes an argument with the same name as the first argument in the original function. I.e. 1st: `arg`, 2nd: `cb: (arg) => any`
```ts
export function flattenIntoArray (
    arg,
	cb: (arg) => any
): any {
  return cb(arg);
};
```
2. See unexpected error saying `arg` is unused

[Playground link](https://play.rome.tools/?code=export+function+flattenIntoArray+%28%0A++++arg%2C%0A%09cb%3A+%28arg%29+%3D%3E+any%0A%29%3A+any+%7B%0A++return+cb%28arg%29%3B%0A%7D%3B&lineWidth=80&indentStyle=tab&quoteStyle=double&quoteProperties=as-needed&indentWidth=2&sourceType=module&typescript=true&jsx=false#ZQB4AHAAbwByAHQAIABmAHUAbgBjAHQAaQBvAG4AIABmAGwAYQB0AHQAZQBuAEkAbgB0AG8AQQByAHIAYQB5ACAAKAAKACAAIAAgACAAYQByAGcALAAKAAkAYwBiADoAIAAoAGEAcgBnACkAIAA9AD4AIABhAG4AeQAKACkAOgAgAGEAbgB5ACAAewAKACAAIAByAGUAdAB1AHIAbgAgAGMAYgAoAGEAcgBnACkAOwAKAH0AOwA=)

### Expected result

`arg` in this case shouldn't be unused, since it is passed into the callback function.

### Code of Conduct

- [X] I agree to follow Rome's Code of Conduct


Discussion:
@xunilrj would you mind taking a look at this
This issue is stale because it has been open 14 days with no activity.



Patch:
diff --git a/crates/rome_js_semantic/src/events.rs b/crates/rome_js_semantic/src/events.rs
index 2c6ef4bd54b..8ba65491f96 100644
--- a/crates/rome_js_semantic/src/events.rs
+++ b/crates/rome_js_semantic/src/events.rs
@@ -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,
@@ -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


Test patch:
diff --git a/crates/rome_js_semantic/src/tests/references.rs b/crates/rome_js_semantic/src/tests/references.rs
index c841a4f7362..de3a45c09f8 100644
--- a/crates/rome_js_semantic/src/tests/references.rs
+++ b/crates/rome_js_semantic/src/tests/references.rs
@@ -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*/); };",
+}