Skip to content

Commit 4b08c05

Browse files
authored
Fix regression in name resolution in parameter (#38351)
1 parent ec93a7c commit 4b08c05

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,9 @@ namespace ts {
18891889
lastLocation === (location as BindingElement).name && isBindingPattern(lastLocation))) {
18901890
const root = getRootDeclaration(location);
18911891
if (root.kind === SyntaxKind.Parameter) {
1892-
associatedDeclarationForContainingInitializerOrBindingName = location as BindingElement;
1892+
if (!associatedDeclarationForContainingInitializerOrBindingName) {
1893+
associatedDeclarationForContainingInitializerOrBindingName = location as BindingElement;
1894+
}
18931895
}
18941896
}
18951897
break;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @target: es5, es2015, esnext
2+
// @noEmit: true
3+
// @noTypesAndSymbols: true
4+
5+
// https://github.com/microsoft/TypeScript/issues/38243
6+
7+
function test0({ a = 0, b = a } = {}) {
8+
return { a, b };
9+
}
10+
11+
function test1({ c: { a = 0, b = a } = {} } = {}) {
12+
return { a, b };
13+
}

0 commit comments

Comments
 (0)