Skip to content

Requesting "Extract to typedef" from within comment in type alias in JS file triggers a crash #48593

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 Apr 6, 2022 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@DanielRosenwasser
Copy link
Member

Follow-up to #48540

type Foo = {
   /**
    * $
    */
   oops: string;
};

Request "extract to typedef" at $.

Response received: getEditsForRefactor (2477). Request took 2 ms. Success: false . Message: Error processing request. Debug Failure. False expression: Node must have a real position for this operation
Error: Debug Failure. False expression: Node must have a real position for this operation
    at NodeObject.assertHasRealPosition (node_modules/typescript/lib/tsserver.js:162217:22)
    at NodeObject.getStart (node_modules/typescript/lib/tsserver.js:162223:18)
    at processChildNode (node_modules/typescript/lib/tsserver.js:145833:47)
    at processChildNodes (node_modules/typescript/lib/tsserver.js:145934:48)
    at node_modules/typescript/lib/tsserver.js:145822:21
    at visitNodes (node_modules/typescript/lib/tsserver.js:30197:24)
    at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30681:24)
    at processNode (node_modules/typescript/lib/tsserver.js:145819:20)
    at formatSpanWorker (node_modules/typescript/lib/tsserver.js:145619:17)
    at node_modules/typescript/lib/tsserver.js:145582:140
    at Object.getFormattingScanner (node_modules/typescript/lib/tsserver.js:144209:23)
    at Object.formatNodeGivenIndentation (node_modules/typescript/lib/tsserver.js:145582:31)
    at getFormattedTextOfNode (node_modules/typescript/lib/tsserver.js:148003:45)
    at format (node_modules/typescript/lib/tsserver.js:147974:52)
    at computeNewText (node_modules/typescript/lib/tsserver.js:147977:23)
    at node_modules/typescript/lib/tsserver.js:147941:39
    at Object.mapDefined (node_modules/typescript/lib/tsserver.js:605:30)
    at node_modules/typescript/lib/tsserver.js:147939:42
    at Object.mapDefined (node_modules/typescript/lib/tsserver.js:605:30)
    at Object.getTextChangesFromChanges (node_modules/typescript/lib/tsserver.js:147925:27)
    at ChangeTracker.getChanges (node_modules/typescript/lib/tsserver.js:147864:45)
    at Function.ChangeTracker.with (node_modules/typescript/lib/tsserver.js:147284:32)
    at Object.getRefactorEditsToExtractType [as getEditsForAction] (node_modules/typescript/lib/tsserver.js:160030:62)
    at Object.getEditsForRefactor (node_modules/typescript/lib/tsserver.js:148589:41)
    at Object.getEditsForRefactor (node_modules/typescript/lib/tsserver.js:164351:32)
    at IpcIOSession.Session.getEditsForRefactor (node_modules/typescript/lib/tsserver.js:175483:59)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (node_modules/typescript/lib/tsserver.js:174103:61)
    at node_modules/typescript/lib/tsserver.js:175866:88
    at IpcIOSession.Session.executeWithRequestId (node_modules/typescript/lib/tsserver.js:175857:28)
    at IpcIOSession.Session.executeCommand (node_modules/typescript/lib/tsserver.js:175866:33)
    at IpcIOSession.Session.onMessage (node_modules/typescript/lib/tsserver.js:175892:35)
    at process.<anonymous> (node_modules/typescript/lib/tsserver.js:178527:31)
    at process.emit (node:events:390:28)
    at emit (node:internal/child_process:917:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Help Wanted You can do this Domain: JavaScript The issue relates to JavaScript specifically Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Domain: Refactorings e.g. extract to constant or function, rename symbol labels Apr 6, 2022
@MQuy
Copy link
Contributor

MQuy commented Apr 6, 2022

which typescript version are you using? I tried with this testcase on master and it passes.

// @allowJs: true
// @Filename: a.js
////type Foo = {
////    /**
////     * /*a*/$/*b*/
////     */
////    oops: string;
////};

goTo.file('a.js')
goTo.select("a", "b");
edit.applyRefactor({
    refactorName: "Extract type",
    actionName: "Extract to typedef",
    actionDescription: "Extract to typedef",
    newContent:
`/**
 * @typedef {{
    oops: string;
}} /*RENAME*/NewType
 */

type Foo = NewType;`,
});

@DanielRosenwasser
Copy link
Member Author

Hmm, you're right, it's because I'm using the nightly extension rather than the actual latest. Sorry!

@DanielRosenwasser DanielRosenwasser added Duplicate An existing issue was already created and removed Bug A bug in TypeScript Help Wanted You can do this Domain: Refactorings e.g. extract to constant or function, rename symbol Domain: JavaScript The issue relates to JavaScript specifically Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". labels Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants