-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallyFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
The crash happens when a parameter is followed by a C-style comment in a JS file:
function call(callback /*oh no*/) {
return callback(this)
}
Expected behavior:
Provide a codefix "Infer parameter types from usage".
Actual behavior:
Crash:
Error: Debug Failure. False expression: Node must have a real position for this operation
at NodeObject.assertHasRealPosition (src/services/services.ts:37:19)
at NodeObject.getStart (src/services/services.ts:45:18)
at processChildNode (src/services/formatting/formatting.ts:645:45)
at processChildNodes (src/services/formatting/formatting.ts:757:44)
at /home/nathansa/ts/src/services/formatting/formatting.ts:623:21
at visitNodes (src/compiler/parser.ts:40:24)
at Object.forEachChild (src/compiler/parser.ts:462:24)
at processNode (src/services/formatting/formatting.ts:617:13)
at formatSpanWorker (src/services/formatting/formatting.ts:415:13)
at /home/nathansa/ts/src/services/formatting/formatting.ts:340:108
at Object.getFormattingScanner (src/services/formatting/formattingScanner.ts:38:21)
at Object.formatNodeGivenIndentation (src/services/formatting/formatting.ts:340:16)
at getFormattedTextOfNode (src/services/textChanges.ts:819:40)
at format (src/services/textChanges.ts:796:41)
at computeNewText (src/services/textChanges.ts:799:19)
at /home/nathansa/ts/src/services/textChanges.ts:769:72
at Array.map (<anonymous>)
at /home/nathansa/ts/src/services/textChanges.ts:768:48
at Array.map (<anonymous>)
at Object.getTextChangesFromChanges (src/services/textChanges.ts:758:59)
at ChangeTracker.getChanges (src/services/textChanges.ts:726:43)
at Function.ChangeTracker.with (src/services/textChanges.ts:225:28)
at Object.getCodeActions (src/services/codefixes/inferFromUsage.ts:32:59)
Fourslash repro
/// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitAny: true
// @Filename: important.js
////function coll(callback /*, name1, name2, ... */) {
//// return callback(this);
////};
verify.codeFix({
description: "Infer parameter types from usage",
index: 2,
newFileContent:
`
/**
* @param {(arg0: any) => void} callback
*/
function coll(callback /*, name1, name2, ... */) {
return callback(this);
}
`,
});
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallyFixedA PR has been merged for this issueA PR has been merged for this issue