Skip to content

Commit 39fed57

Browse files
committed
Better support for shorthand property assignment in the treeshaker
1 parent 48c0d3a commit 39fed57

3 files changed

Lines changed: 36 additions & 29 deletions

File tree

build/lib/treeshaking.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ function getRealNodeSymbol(checker, node) {
589589
// (2) when the aliased symbol is originating from an import.
590590
//
591591
function shouldSkipAlias(node, declaration) {
592-
if (node.kind !== ts.SyntaxKind.Identifier) {
592+
if (!ts.isShorthandPropertyAssignment(node) && node.kind !== ts.SyntaxKind.Identifier) {
593593
return false;
594594
}
595595
if (node.parent === declaration) {
@@ -611,7 +611,9 @@ function getRealNodeSymbol(checker, node) {
611611
}
612612
}
613613
const { parent } = node;
614-
let symbol = checker.getSymbolAtLocation(node);
614+
let symbol = (ts.isShorthandPropertyAssignment(node)
615+
? checker.getShorthandAssignmentValueSymbol(node)
616+
: checker.getSymbolAtLocation(node));
615617
let importNode = null;
616618
// If this is an alias, and the request came at the declaration location
617619
// get the aliased symbol instead. This allows for goto def on an import e.g.

build/lib/treeshaking.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ function getRealNodeSymbol(checker: ts.TypeChecker, node: ts.Node): [ts.Symbol |
729729
// (2) when the aliased symbol is originating from an import.
730730
//
731731
function shouldSkipAlias(node: ts.Node, declaration: ts.Node): boolean {
732-
if (node.kind !== ts.SyntaxKind.Identifier) {
732+
if (!ts.isShorthandPropertyAssignment(node) && node.kind !== ts.SyntaxKind.Identifier) {
733733
return false;
734734
}
735735
if (node.parent === declaration) {
@@ -754,7 +754,12 @@ function getRealNodeSymbol(checker: ts.TypeChecker, node: ts.Node): [ts.Symbol |
754754

755755
const { parent } = node;
756756

757-
let symbol = checker.getSymbolAtLocation(node);
757+
let symbol = (
758+
ts.isShorthandPropertyAssignment(node)
759+
? checker.getShorthandAssignmentValueSymbol(node)
760+
: checker.getSymbolAtLocation(node)
761+
);
762+
758763
let importNode: ts.Declaration | null = null;
759764
// If this is an alias, and the request came at the declaration location
760765
// get the aliased symbol instead. This allows for goto def on an import e.g.

src/vs/platform/quickinput/browser/quickInput.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -168,40 +168,40 @@ export class QuickInputService extends Themable implements IQuickInputService {
168168
return {
169169
widget: {
170170
...computeStyles(this.theme, {
171-
quickInputBackground: quickInputBackground,
172-
quickInputForeground: quickInputForeground,
173-
quickInputTitleBackground: quickInputTitleBackground,
174-
contrastBorder: contrastBorder,
175-
widgetShadow: widgetShadow
171+
quickInputBackground,
172+
quickInputForeground,
173+
quickInputTitleBackground,
174+
contrastBorder,
175+
widgetShadow
176176
}),
177177
},
178178
inputBox: computeStyles(this.theme, {
179-
inputForeground: inputForeground,
180-
inputBackground: inputBackground,
181-
inputBorder: inputBorder,
182-
inputValidationInfoBackground: inputValidationInfoBackground,
183-
inputValidationInfoForeground: inputValidationInfoForeground,
184-
inputValidationInfoBorder: inputValidationInfoBorder,
185-
inputValidationWarningBackground: inputValidationWarningBackground,
186-
inputValidationWarningForeground: inputValidationWarningForeground,
187-
inputValidationWarningBorder: inputValidationWarningBorder,
188-
inputValidationErrorBackground: inputValidationErrorBackground,
189-
inputValidationErrorForeground: inputValidationErrorForeground,
190-
inputValidationErrorBorder: inputValidationErrorBorder
179+
inputForeground,
180+
inputBackground,
181+
inputBorder,
182+
inputValidationInfoBackground,
183+
inputValidationInfoForeground,
184+
inputValidationInfoBorder,
185+
inputValidationWarningBackground,
186+
inputValidationWarningForeground,
187+
inputValidationWarningBorder,
188+
inputValidationErrorBackground,
189+
inputValidationErrorForeground,
190+
inputValidationErrorBorder
191191
}),
192192
countBadge: computeStyles(this.theme, {
193-
badgeBackground: badgeBackground,
194-
badgeForeground: badgeForeground,
193+
badgeBackground,
194+
badgeForeground,
195195
badgeBorder: contrastBorder
196196
}),
197197
button: computeStyles(this.theme, {
198-
buttonForeground: buttonForeground,
199-
buttonBackground: buttonBackground,
200-
buttonHoverBackground: buttonHoverBackground,
198+
buttonForeground,
199+
buttonBackground,
200+
buttonHoverBackground,
201201
buttonBorder: contrastBorder
202202
}),
203203
progressBar: computeStyles(this.theme, {
204-
progressBarBackground: progressBarBackground
204+
progressBarBackground
205205
}),
206206
list: computeStyles(this.theme, {
207207
listBackground: quickInputBackground,
@@ -210,8 +210,8 @@ export class QuickInputService extends Themable implements IQuickInputService {
210210
listInactiveFocusBackground: listFocusBackground,
211211
listFocusOutline: activeContrastBorder,
212212
listInactiveFocusOutline: activeContrastBorder,
213-
pickerGroupBorder: pickerGroupBorder,
214-
pickerGroupForeground: pickerGroupForeground
213+
pickerGroupBorder,
214+
pickerGroupForeground
215215
})
216216
};
217217
}

0 commit comments

Comments
 (0)