-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
UnactionableThere isn't something we can do with this issueThere isn't something we can do with this issue
Description
TypeScript Version: 3.7.2
Search Terms:
LanguageServiceHost, getDefaultLibFileName
Code
import * as ts from 'typescript';
let compilerOptions: ts.CompilerOptions = {
allowNonTsExtensions: true,
target: ts.ScriptTarget.Latest,
module: ts.ModuleKind.ESNext,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
allowJs: true
};
const serviceHost: ts.LanguageServiceHost = {
getScriptFileNames: () => [],
getScriptVersion: () => '0',
getScriptSnapshot: path => ts.ScriptSnapshot.fromString(ts.sys.readFile(path)),
getCurrentDirectory: () => '',
getCompilationSettings: () => compilerOptions,
getDefaultLibFileName: ts.getDefaultLibFileName, // this doesn't work
fileExists: ts.sys.fileExists,
readFile: ts.sys.readFile,
readDirectory: ts.sys.readDirectory
};Expected behavior:
I can pass ts.getDefaultLibFileName for the property getDefaultLibFileName of serviceHost.
Actual behavior:
I have to pass ts.getDefaultLibFilePath for the property getDefaultLibFileName.
When I pass ts.getDefaultLibFileName, getScriptSnapshot only has the fileName (e.g. lib.esnext.full.d.ts) as an argument instead of the full path (e.g. /home/simon/folder/node_modules/typescript/lib/lib.esnext.full.d.ts) and when getScriptSnapshot is called, it fails to read the file.
Maybe the getDefaultLibFileName property could be replaced with a getDefaultLibFilePath property, currently it is a bit confusing :/
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
UnactionableThere isn't something we can do with this issueThere isn't something we can do with this issue