Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoimports crashes with aliased export #59583

Open
iisaduan opened this issue Aug 9, 2024 · 0 comments · May be fixed by #60260
Open

autoimports crashes with aliased export #59583

iisaduan opened this issue Aug 9, 2024 · 0 comments · May be fixed by #60260
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: Auto-import Fix Available A PR has been opened for this issue

Comments

@iisaduan
Copy link
Member

iisaduan commented Aug 9, 2024

found while working on #59582.
search terms: autoimports, module augmentation, alias, export list, mergeSymbol

💻 Code

fourslash test:

/// <reference path="fourslash.ts" />
// @module: nodenext

// @Filename: /node_modules/@sapphire/pieces/index.d.ts
//// interface Container {
////   stores: unknown;
//// }
////
//// declare class Piece {
////   container: Container;
//// }
////
//// export { Piece, type Container as Alias };

// @FileName: /augmentation.ts
//// declare module "@sapphire/pieces" {
////   interface Alias {
////     client: unknown;
////   }
//// }

// @Filename: /index.ts
//// import { Piece } from "@sapphire/pieces";
//// class FullPiece extends Piece {
////   /*1*/
//// }

const preferences = {
  includeCompletionsWithClassMemberSnippets: true,
  includeCompletionsWithInsertText: true,
};

verify.completions({
  marker: "1",
  includes: [
    {
      name: "container",
      insertText: "container: Alias;",
      filterText: "container",
      hasAction: true,
      source: "ClassMemberSnippet/",
    },
  ],
  preferences,
  isNewIdentifierLocation: true,
});

verify.applyCodeActionFromCompletion("1", {
  name: "container",
  source: "ClassMemberSnippet/",
  description: `Includes imports of types referenced by "container"`,
  newFileContent: `import { Alias, Piece } from "@sapphire/pieces";
class FullPiece extends Piece {
  
}`,
  preferences,
});

🙁 Actual behavior

       tests/cases/fourslash/autoImportCompletionExportListAugmentation5.ts
         fourslash test autoImportCompletionExportListAugmentation5.ts runs correctly:
     Error: Debug Failure. False expression.
      at Object.addImportFromExportedSymbol (src\services\codefixes\importFixes.ts:300:19)
      at C:\TypeScript\src\services\codefixes\helpers.ts:947:38
      at Array.forEach (<anonymous>)
      at importSymbols (src\services\codefixes\helpers.ts:947:13)
      at Object.addNewNodeForMemberSymbol (src\services\codefixes\helpers.ts:231:21)
      at getEntryForMemberCompletion (src\services\completions.ts:2055:13)
      at createCompletionEntry (src\services\completions.ts:1807:39)
      at getCompletionEntriesFromSymbols (src\services\completions.ts:2678:23)
      at completionInfoFromData (src\services\completions.ts:1334:25)
      at Object.getCompletionsAtPosition (src\services\completions.ts:764:30)
      at Object.getCompletionsAtPosition2 [as getCompletionsAtPosition] (src\services\services.ts:2231:28)
      at Function.proxy.<computed> [as getCompletionsAtPosition] (src\harness\fourslashImpl.ts:480:61)
      at _TestState.getCompletionListAtCaret (src\harness\fourslashImpl.ts:1794:37)
      at _TestState.verifyCompletionsWorker (src\harness\fourslashImpl.ts:1014:40)
      at _TestState.verifyCompletions (src\harness\fourslashImpl.ts:1008:25)
      at Verify.completions (src\harness\fourslashInterfaceImpl.ts:269:31)
      at eval (autoImportCompletionExportListAugmentation5.js:28:8)
      at runCode (src\harness\fourslashImpl.ts:4698:9)
      at runFourSlashTestContent (src\harness\fourslashImpl.ts:4669:5)
      at runFourSlashTest (src\harness\fourslashImpl.ts:4652:5)
      at Context.<anonymous> (src\testRunner\fourslashRunner.ts:59:39)
      at processImmediate (node:internal/timers:478:21)

🙂 Expected behavior

no crash! :D

@andrewbranch andrewbranch added Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: Auto-import labels Aug 27, 2024
@andrewbranch andrewbranch added this to the TypeScript 5.7.0 milestone Aug 27, 2024
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: Auto-import Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants