Skip to content

Commit e6709a4

Browse files
rbucktontypescript-bot
authored andcommitted
Cherry-pick PR microsoft#38351 into release-3.9
Component commits: 39e6856 Fix regression in name resolution in parameter
1 parent 90570df commit e6709a4

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
@@ -1887,7 +1887,9 @@ namespace ts {
18871887
lastLocation === (location as BindingElement).name && isBindingPattern(lastLocation))) {
18881888
const root = getRootDeclaration(location);
18891889
if (root.kind === SyntaxKind.Parameter) {
1890-
associatedDeclarationForContainingInitializerOrBindingName = location as BindingElement;
1890+
if (!associatedDeclarationForContainingInitializerOrBindingName) {
1891+
associatedDeclarationForContainingInitializerOrBindingName = location as BindingElement;
1892+
}
18911893
}
18921894
}
18931895
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)