mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Fix crash on addImportFromExportedSymbol with default exported symbol (#52694)
This commit is contained in:
parent
7fb6c99c19
commit
7612a3afc7
@ -3959,8 +3959,12 @@ function needsNameFromDeclaration(symbol: Symbol) {
|
||||
return !(symbol.flags & SymbolFlags.Transient) && (symbol.escapedName === InternalSymbolName.ExportEquals || symbol.escapedName === InternalSymbolName.Default);
|
||||
}
|
||||
|
||||
function getDefaultLikeExportNameFromDeclaration(symbol: Symbol) {
|
||||
return firstDefined(symbol.declarations, d => isExportAssignment(d) ? tryCast(skipOuterExpressions(d.expression), isIdentifier)?.text : undefined);
|
||||
function getDefaultLikeExportNameFromDeclaration(symbol: Symbol): string | undefined {
|
||||
return firstDefined(symbol.declarations, d =>
|
||||
isExportAssignment(d)
|
||||
? tryCast(skipOuterExpressions(d.expression), isIdentifier)?.text
|
||||
: tryCast(getNameOfDeclaration(d), isIdentifier)?.text
|
||||
);
|
||||
}
|
||||
|
||||
function getSymbolParentOrFail(symbol: Symbol) {
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// Issue #52662
|
||||
|
||||
// @filename: other.ts
|
||||
//// export default class Other {}
|
||||
|
||||
// @filename: base.ts
|
||||
//// import Other from "./other";
|
||||
//// export class Base {
|
||||
//// foo(): Other {
|
||||
//// throw new Error("");
|
||||
//// }
|
||||
//// }
|
||||
|
||||
// @filename: derived.ts
|
||||
//// import { Base } from "./base";
|
||||
//// export class Derived extends Base {
|
||||
//// /**/
|
||||
//// }
|
||||
|
||||
verify.completions({
|
||||
marker: "",
|
||||
isNewIdentifierLocation: true,
|
||||
preferences: {
|
||||
includeCompletionsWithInsertText: true,
|
||||
includeCompletionsWithClassMemberSnippets: true,
|
||||
},
|
||||
includes: [
|
||||
{
|
||||
name: "foo",
|
||||
sortText: completion.SortText.ClassMemberSnippets,
|
||||
insertText: "foo(): Other {\n}",
|
||||
hasAction: true,
|
||||
source: completion.CompletionSource.ClassMemberSnippet,
|
||||
}
|
||||
],
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user