Skip to content
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

[WIP] support for project references in languageService codepath #1111

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ export function create (rawOptions: CreateOptions = {}): Register {
return transformers
}

const compilerHost: _ts.TODO

// Create the compiler host for type checking.
const serviceHost: _ts.LanguageServiceHost = {
getProjectVersion: () => String(projectVersion),
Expand Down Expand Up @@ -568,11 +570,24 @@ export function create (rawOptions: CreateOptions = {}): Register {
getCurrentDirectory: () => cwd,
getCompilationSettings: () => config.options,
getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options),
getCustomTransformers: getCustomTransformers
getCustomTransformers: getCustomTransformers,
getProjectReferences() { return config.projectReferences },
// TODO Add both of the following function signatures to an "Internals" declaration somewhere,
// copied from TS source code
useSourceOfProjectReferenceRedirect() { return true },
setCompilerHost(_compilerHost: _ts.CompilerHost) {
compilerHost = _compilerHost
setResolverHost(compilerHost)
}
}

const registry = ts.createDocumentRegistry(ts.sys.useCaseSensitiveFileNames, cwd)
const service = ts.createLanguageService(serviceHost, registry)
setResolverHost(serviceHost)
// TODO ADD THIS TO THE RESOLVER FACTORY AFTER THAT'S BEEN MERGED
function setResolverHost(newHost: _ts.ModuleResolutionHost) {
serviceHost = newHost
}

const updateMemoryCache = (contents: string, fileName: string) => {
// Add to `rootFiles` if not already there
Expand Down