GeezerVison is showing github.com — Fixed a symbol display crash on expando members write locations (#55478) · microsoft/TypeScript@89c572c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/services/symbolDisplay.ts +9-3Lines changed: 9 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { | | 2 | + AccessorDeclaration, | 2 | 3 | addRange, | 3 | 4 | arrayFrom, | 4 | 5 | BinaryExpression, | @@ -16,7 +17,6 @@ import { | 16 | 17 | first, | 17 | 18 | firstDefined, | 18 | 19 | forEach, | 19 | | - GetAccessorDeclaration, | 20 | 20 | getCombinedLocalAndExportSymbolFlags, | 21 | 21 | getDeclarationOfKind, | 22 | 22 | getExternalModuleImportEqualsDeclarationExpression, | @@ -83,7 +83,6 @@ import { | 83 | 83 | ScriptElementKind, | 84 | 84 | ScriptElementKindModifier, | 85 | 85 | SemanticMeaning, | 86 | | - SetAccessorDeclaration, | 87 | 86 | Signature, | 88 | 87 | SignatureDeclaration, | 89 | 88 | SignatureFlags, | @@ -276,7 +275,14 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type | 276 | 275 | if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Class || symbolFlags & SymbolFlags.Alias) { | 277 | 276 | // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor | 278 | 277 | if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { | 279 | | - const declaration = find(symbol.declarations as ((GetAccessorDeclaration | SetAccessorDeclaration | PropertyDeclaration)[]), declaration => declaration.name === location); | | 278 | + const declaration = find( | | 279 | + symbol.declarations as (AccessorDeclaration | PropertyDeclaration | PropertyAccessExpression)[], | | 280 | + (declaration): declaration is AccessorDeclaration | PropertyDeclaration => | | 281 | + declaration.name === location | | 282 | + // an expando member could have been added to an object with a set accessor | | 283 | + // we need to ignore such write location as it shouldn't be displayed as `(setter)` anyway | | 284 | + && declaration.kind !== SyntaxKind.PropertyAccessExpression, | | 285 | + ); | 280 | 286 | if (declaration) { | 281 | 287 | switch (declaration.kind) { | 282 | 288 | case SyntaxKind.GetAccessor: | |
Collapse file Copy file name to clipboard +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/// <reference path="fourslash.ts" /> | | 2 | + | | 3 | +// @strict: true | | 4 | +// @checkJs: true | | 5 | +// @filename: index.js | | 6 | + | | 7 | +//// const x = {}; | | 8 | +//// | | 9 | +//// Object.defineProperty(x, "foo", { | | 10 | +//// /** @param {number} v */ | | 11 | +//// set(v) {}, | | 12 | +//// }); | | 13 | +//// | | 14 | +//// x.foo/**/ = 1; | | 15 | + | | 16 | +verify.quickInfoAt("", "(property) x.foo: number"); |
Collapse file Copy file name to clipboard +19Lines changed: 19 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/// <reference path="fourslash.ts" /> | | 2 | + | | 3 | +// @strict: true | | 4 | +// @checkJs: true | | 5 | +// @filename: index.js | | 6 | + | | 7 | +//// const obj = {}; | | 8 | +//// let val = 10; | | 9 | +//// Object.defineProperty(obj, "a", { | | 10 | +//// configurable: true, | | 11 | +//// enumerable: true, | | 12 | +//// set(v) { | | 13 | +//// val = v; | | 14 | +//// }, | | 15 | +//// }); | | 16 | +//// | | 17 | +//// obj.a/**/ = 100; | | 18 | + | | 19 | +verify.quickInfoAt("", "(property) obj.a: any"); |
|