Skip to content

Extract to function crash #38815

Closed
Closed
@andrewbranch

Description

@andrewbranch

TypeScript Version: 4.0.0-dev.20200526

Search Terms: RangeFacts.HasReturn

Try to extract these lines to a function in createLanguageService:

// Now create a new compiler
const compilerHost: CompilerHost = {
getSourceFile: getOrCreateSourceFile,
getSourceFileByPath: getOrCreateSourceFileByPath,
getCancellationToken: () => cancellationToken,
getCanonicalFileName,
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
getNewLine: () => getNewLineCharacter(newSettings, () => getNewLineOrDefaultFromHost(host)),
getDefaultLibFileName: (options) => host.getDefaultLibFileName(options),
writeFile: noop,
getCurrentDirectory: () => currentDirectory,
fileExists,
readFile,
realpath: host.realpath && (path => host.realpath!(path)),
directoryExists: directoryName => {
return directoryProbablyExists(directoryName, host);
},
getDirectories: path => {
return host.getDirectories ? host.getDirectories(path) : [];
},
readDirectory(path, extensions, exclude, include, depth) {
Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
return host.readDirectory!(path, extensions, exclude, include, depth);
},
onReleaseOldSourceFile,
hasInvalidatedResolution,
hasChangedAutomaticTypeDirectiveNames: host.hasChangedAutomaticTypeDirectiveNames
};
if (host.trace) {
compilerHost.trace = message => host.trace!(message);
}
if (host.resolveModuleNames) {
compilerHost.resolveModuleNames = (...args) => host.resolveModuleNames!(...args);
}
if (host.resolveTypeReferenceDirectives) {
compilerHost.resolveTypeReferenceDirectives = (...args) => host.resolveTypeReferenceDirectives!(...args);
}
if (host.useSourceOfProjectReferenceRedirect) {
compilerHost.useSourceOfProjectReferenceRedirect = () => host.useSourceOfProjectReferenceRedirect!();
}

Error stack:

Error: Debug Failure. False expression: Expected RangeFacts.HasReturn flag to be unset
at extractFunctionInScope (/Users/andrew/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.0.20200526/node_modules/typescript/lib/tsserver.js:136020:30)
at getFunctionExtractionAtIndex (/Users/andrew/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.0.20200526/node_modules/typescript/lib/tsserver.js:135807:24)
at Object.getEditsForAction (/Users/andrew/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.0.20200526/node_modules/typescript/lib/tsserver.js:135401:28)
at Object.getEditsForRefactor (/Users/andrew/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.0.20200526/node_modules/typescript/lib/tsserver.js:128047:41)
at Object.getEditsForRefactor (/Users/andrew/.vscode-insiders/extensions/ms-vscod...

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbol

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions