Skip to content

Assertion failure when move-to-file code contains entities from ambient module #59701

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

Closed
DanielRosenwasser opened this issue Aug 20, 2024 · 0 comments · Fixed by #60333
Closed
Assignees
Labels
Bug A bug in TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Aug 20, 2024

// @filename: src/globals.ts
declare module "ambient" {
    export interface Thing {}
}
// @filename: src/yadda.ts
import type * as ambient from "ambient";

export class Yadda {
  foo(): ambient.Thing {
    throw new Error("not implemented");
  }

  bar(): ambient.DoesNotExist {
    throw new Error("not implemented");
  }
}
// @filename: src/tsconfig.json
{
    "compilerOptions": {
        "moduleResolution": "bundler",
        "target": "esnext",
        "strict": true,
        "outDir": "dist"
    },
    "include": [
        "src"
    ]
}

Move to a new file on Yadda, and the following assertion error is issued from TSServer

Response received: getEditsForRefactor (729). Request took 2 ms. Success: false . Message: Error processing request. Debug Failure.
Error: Debug Failure.
    at Object.addImportFromExportedSymbol (node_modules/typescript/lib/typescript.js:154243:32)
    at node_modules/typescript/lib/typescript.js:144288:19
    at Map.forEach (<anonymous>)
    at addTargetFileImports (node_modules/typescript/lib/typescript.js:144282:17)
    at getNewStatementsAndRemoveFromOldFile (node_modules/typescript/lib/typescript.js:143512:3)
    at doChange3 (node_modules/typescript/lib/typescript.js:143496:3)
    at node_modules/typescript/lib/typescript.js:143481:79
    at _ChangeTracker.with (node_modules/typescript/lib/typescript.js:174306:5)
    at Object.getRefactorEditsToMoveToFile [as getEditsForAction] (node_modules/typescript/lib/typescript.js:143481:62)
    at Object.getEditsForRefactor (node_modules/typescript/lib/typescript.js:142603:31)
    at Object.getEditsForRefactor2 [as getEditsForRefactor] (node_modules/typescript/lib/typescript.js:149939:32)
    at IpcIOSession.getEditsForRefactor (node_modules/typescript/lib/typescript.js:191087:49)
    at getEditsForRefactor (node_modules/typescript/lib/typescript.js:189305:43)
    at node_modules/typescript/lib/typescript.js:191491:69
    at IpcIOSession.executeWithRequestId (node_modules/typescript/lib/typescript.js:191483:14)
    at IpcIOSession.executeCommand (node_modules/typescript/lib/typescript.js:191491:29)
    at IpcIOSession.onMessage (node_modules/typescript/lib/typescript.js:191533:51)
    at process.<anonymous> (node_modules/typescript/lib/tsserver.js:523:14)
    at process.emit (node:events:519:28)
    at emit (node:internal/child_process:951:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants