Skip to content

Commit

Permalink
fix(semantic): do not resolve references after FormalParameters in …
Browse files Browse the repository at this point in the history
…TS type (#4241)

Semantic resolves references when exiting `FormalParameters` to ensure references in param initializers don't get bound to bindings inside the function body.

However, it shouldn't do this for `FormalParameters` in TS types e.g. `TSTypeAnnotation` because they don't have their own scopes.
  • Loading branch information
overlookmotel committed Jul 13, 2024
1 parent 7eb960d commit 22d56bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ impl<'a> SemanticBuilder<'a> {
self.function_stack.pop();
}
AstKind::FormalParameters(parameters) => {
if parameters.has_parameter() {
if parameters.kind != FormalParameterKind::Signature && parameters.has_parameter() {
// `function foo({bar: identifier_reference}) {}`
// ^^^^^^^^^^^^^^^^^^^^ Parameter initializer must be resolved
// after all parameters have been declared
Expand Down

0 comments on commit 22d56bd

Please sign in to comment.