Skip to content

Commit ba4a466

Browse files
committed
Partially revert #41044
1 parent d75b631 commit ba4a466

24 files changed

+126
-165
lines changed

src/compiler/checker.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6116,29 +6116,19 @@ namespace ts {
61166116
return parameterNode;
61176117

61186118
function cloneBindingName(node: BindingName): BindingName {
6119-
return elideInitializerAndPropertyRenamingAndSetEmitFlags(node) as BindingName;
6120-
function elideInitializerAndPropertyRenamingAndSetEmitFlags(node: Node): Node {
6119+
return elideInitializerAndSetEmitFlags(node) as BindingName;
6120+
function elideInitializerAndSetEmitFlags(node: Node): Node {
61216121
if (context.tracker.trackSymbol && isComputedPropertyName(node) && isLateBindableName(node)) {
61226122
trackComputedName(node.expression, context.enclosingDeclaration, context);
61236123
}
6124-
let visited = visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags)!;
6124+
let visited = visitEachChild(node, elideInitializerAndSetEmitFlags, nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags)!;
61256125
if (isBindingElement(visited)) {
6126-
if (visited.propertyName && isIdentifier(visited.propertyName) && isIdentifier(visited.name) && !isStringAKeyword(idText(visited.propertyName))) {
6127-
visited = factory.updateBindingElement(
6128-
visited,
6129-
visited.dotDotDotToken,
6130-
/* propertyName*/ undefined,
6131-
visited.propertyName,
6132-
/*initializer*/ undefined);
6133-
}
6134-
else {
6135-
visited = factory.updateBindingElement(
6136-
visited,
6137-
visited.dotDotDotToken,
6138-
visited.propertyName,
6139-
visited.name,
6140-
/*initializer*/ undefined);
6141-
}
6126+
visited = factory.updateBindingElement(
6127+
visited,
6128+
visited.dotDotDotToken,
6129+
visited.propertyName,
6130+
visited.name,
6131+
/*initializer*/ undefined);
61426132
}
61436133
if (!nodeIsSynthesized(visited)) {
61446134
visited = factory.cloneNode(visited);

tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface Show {
55
>x : number
66
}
77
function f({ show: showRename = v => v }: Show) {}
8-
>f : ({ show }: Show) => void
8+
>f : ({ show: showRename }: Show) => void
99
>show : any
1010
>showRename : (x: number) => string
1111
>v => v : (v: number) => number
@@ -32,7 +32,7 @@ interface Nested {
3232
>nested : Show
3333
}
3434
function ff({ nested: nestedRename = { show: v => v } }: Nested) {}
35-
>ff : ({ nested }: Nested) => void
35+
>ff : ({ nested: nestedRename }: Nested) => void
3636
>nested : any
3737
>nestedRename : Show
3838
>{ show: v => v } : { show: (v: number) => number; }

tests/baselines/reference/declarationEmitBindingPatternWithReservedWord.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ export interface GetLocalesOptions<T extends LocaleData> {
4444
config?: LocaleConfig<T> | undefined;
4545
name?: string;
4646
}
47-
export declare const getLocales: <T extends LocaleData>({ app, name, default: defaultLocalesConfig, config, }: GetLocalesOptions<T>) => ConvertLocaleConfig<T>;
47+
export declare const getLocales: <T extends LocaleData>({ app, name, default: defaultLocalesConfig, config: userLocalesConfig, }: GetLocalesOptions<T>) => ConvertLocaleConfig<T>;
4848
export {};

tests/baselines/reference/declarationEmitBindingPatternWithReservedWord.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export interface GetLocalesOptions<T extends LocaleData> {
2626
}
2727

2828
export const getLocales = <T extends LocaleData>({
29-
>getLocales : <T extends LocaleData>({ app, name, default: defaultLocalesConfig, config, }: GetLocalesOptions<T>) => ConvertLocaleConfig<T>
30-
><T extends LocaleData>({ app, name, default: defaultLocalesConfig, config: userLocalesConfig = {},}: GetLocalesOptions<T>): ConvertLocaleConfig<T> => { return defaultLocalesConfig;} : <T extends LocaleData>({ app, name, default: defaultLocalesConfig, config, }: GetLocalesOptions<T>) => ConvertLocaleConfig<T>
29+
>getLocales : <T extends LocaleData>({ app, name, default: defaultLocalesConfig, config: userLocalesConfig, }: GetLocalesOptions<T>) => ConvertLocaleConfig<T>
30+
><T extends LocaleData>({ app, name, default: defaultLocalesConfig, config: userLocalesConfig = {},}: GetLocalesOptions<T>): ConvertLocaleConfig<T> => { return defaultLocalesConfig;} : <T extends LocaleData>({ app, name, default: defaultLocalesConfig, config: userLocalesConfig, }: GetLocalesOptions<T>) => ConvertLocaleConfig<T>
3131

3232
app,
3333
>app : unknown

tests/baselines/reference/declarationEmitBindingPatterns.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function f(_a, _b, _c) {
1818

1919

2020
//// [declarationEmitBindingPatterns.d.ts]
21-
declare const k: ({ x }: {
21+
declare const k: ({ x: z }: {
2222
x?: string;
2323
}) => void;
2424
declare var a: any;

tests/baselines/reference/declarationEmitBindingPatterns.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=== tests/cases/compiler/declarationEmitBindingPatterns.ts ===
22
const k = ({x: z = 'y'}) => { }
3-
>k : ({ x }: { x?: string; }) => void
4-
>({x: z = 'y'}) => { } : ({ x }: { x?: string; }) => void
3+
>k : ({ x: z }: { x?: string; }) => void
4+
>({x: z = 'y'}) => { } : ({ x: z }: { x?: string; }) => void
55
>x : any
66
>z : string
77
>'y' : "y"

tests/baselines/reference/declarationEmitDuplicateParameterDestructuring.js

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,11 @@ export const fn2 = ({ prop: a }: { prop: number }, { prop: b }: { prop: number }
77

88

99
//// [declarationEmitDuplicateParameterDestructuring.d.ts]
10-
export declare const fn1: ({ prop, prop }: {
10+
export declare const fn1: ({ prop: a, prop: b }: {
1111
prop: number;
1212
}) => number;
13-
export declare const fn2: ({ prop }: {
13+
export declare const fn2: ({ prop: a }: {
1414
prop: number;
15-
}, { prop }: {
15+
}, { prop: b }: {
1616
prop: number;
1717
}) => number;
18-
19-
20-
//// [DtsFileErrors]
21-
22-
23-
tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts(1,30): error TS2300: Duplicate identifier 'prop'.
24-
tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts(1,36): error TS2300: Duplicate identifier 'prop'.
25-
tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts(4,30): error TS2300: Duplicate identifier 'prop'.
26-
tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts(6,6): error TS2300: Duplicate identifier 'prop'.
27-
28-
29-
==== tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts (4 errors) ====
30-
export declare const fn1: ({ prop, prop }: {
31-
~~~~
32-
!!! error TS2300: Duplicate identifier 'prop'.
33-
~~~~
34-
!!! error TS2300: Duplicate identifier 'prop'.
35-
prop: number;
36-
}) => number;
37-
export declare const fn2: ({ prop }: {
38-
~~~~
39-
!!! error TS2300: Duplicate identifier 'prop'.
40-
prop: number;
41-
}, { prop }: {
42-
~~~~
43-
!!! error TS2300: Duplicate identifier 'prop'.
44-
prop: number;
45-
}) => number;
46-

tests/baselines/reference/declarationEmitDuplicateParameterDestructuring.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=== tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.ts ===
22
export const fn1 = ({ prop: a, prop: b }: { prop: number }) => a + b;
3-
>fn1 : ({ prop, prop }: { prop: number;}) => number
4-
>({ prop: a, prop: b }: { prop: number }) => a + b : ({ prop, prop }: { prop: number;}) => number
3+
>fn1 : ({ prop: a, prop: b }: { prop: number;}) => number
4+
>({ prop: a, prop: b }: { prop: number }) => a + b : ({ prop: a, prop: b }: { prop: number;}) => number
55
>prop : any
66
>a : number
77
>prop : any
@@ -12,8 +12,8 @@ export const fn1 = ({ prop: a, prop: b }: { prop: number }) => a + b;
1212
>b : number
1313

1414
export const fn2 = ({ prop: a }: { prop: number }, { prop: b }: { prop: number }) => a + b;
15-
>fn2 : ({ prop }: { prop: number;}, { prop }: { prop: number;}) => number
16-
>({ prop: a }: { prop: number }, { prop: b }: { prop: number }) => a + b : ({ prop }: { prop: number;}, { prop }: { prop: number;}) => number
15+
>fn2 : ({ prop: a }: { prop: number;}, { prop: b }: { prop: number;}) => number
16+
>({ prop: a }: { prop: number }, { prop: b }: { prop: number }) => a + b : ({ prop: a }: { prop: number;}, { prop: b }: { prop: number;}) => number
1717
>prop : any
1818
>a : number
1919
>prop : number

tests/baselines/reference/declarationsAndAssignments.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ function f13() {
417417
}
418418

419419
function f14([a = 1, [b = "hello", { x, y: c = false }]]) {
420-
>f14 : ([a, [b, { x, y }]]: [number, [string, { x: any; y?: boolean; }]]) => void
420+
>f14 : ([a, [b, { x, y: c }]]: [number, [string, { x: any; y?: boolean; }]]) => void
421421
>a : number
422422
>1 : 1
423423
>b : string
@@ -438,7 +438,7 @@ function f14([a = 1, [b = "hello", { x, y: c = false }]]) {
438438
}
439439
f14([2, ["abc", { x: 0, y: true }]]);
440440
>f14([2, ["abc", { x: 0, y: true }]]) : void
441-
>f14 : ([a, [b, { x, y }]]: [number, [string, { x: any; y?: boolean; }]]) => void
441+
>f14 : ([a, [b, { x, y: c }]]: [number, [string, { x: any; y?: boolean; }]]) => void
442442
>[2, ["abc", { x: 0, y: true }]] : [number, [string, { x: number; y: true; }]]
443443
>2 : 2
444444
>["abc", { x: 0, y: true }] : [string, { x: number; y: true; }]
@@ -451,7 +451,7 @@ f14([2, ["abc", { x: 0, y: true }]]);
451451

452452
f14([2, ["abc", { x: 0 }]]);
453453
>f14([2, ["abc", { x: 0 }]]) : void
454-
>f14 : ([a, [b, { x, y }]]: [number, [string, { x: any; y?: boolean; }]]) => void
454+
>f14 : ([a, [b, { x, y: c }]]: [number, [string, { x: any; y?: boolean; }]]) => void
455455
>[2, ["abc", { x: 0 }]] : [number, [string, { x: number; }]]
456456
>2 : 2
457457
>["abc", { x: 0 }] : [string, { x: number; }]
@@ -462,7 +462,7 @@ f14([2, ["abc", { x: 0 }]]);
462462

463463
f14([2, ["abc", { y: false }]]); // Error, no x
464464
>f14([2, ["abc", { y: false }]]) : void
465-
>f14 : ([a, [b, { x, y }]]: [number, [string, { x: any; y?: boolean; }]]) => void
465+
>f14 : ([a, [b, { x, y: c }]]: [number, [string, { x: any; y?: boolean; }]]) => void
466466
>[2, ["abc", { y: false }]] : [number, [string, { y: false; }]]
467467
>2 : 2
468468
>["abc", { y: false }] : [string, { y: false; }]

tests/baselines/reference/destructuringInFunctionType.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type T3 = ([{ a: b }, { b: a }]);
3131
>b : a
3232

3333
type F3 = ([{ a: b }, { b: a }]) => void;
34-
>F3 : ([{ a }, { b }]: [{ a: any; }, { b: any; }]) => void
34+
>F3 : ([{ a: b }, { b: a }]: [{ a: any; }, { b: any; }]) => void
3535
>a : any
3636
>b : any
3737
>b : any

0 commit comments

Comments
 (0)