Skip to content

Commit

Permalink
(feat) support node16/nodenext
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon committed Jun 16, 2022
1 parent caf179a commit 41f74e8
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/language-server/src/plugins/typescript/service.ts
Expand Up @@ -292,8 +292,6 @@ async function createLanguageService(
const forcedCompilerOptions: ts.CompilerOptions = {
allowNonTsExtensions: true,
target: ts.ScriptTarget.Latest,
module: ts.ModuleKind.ESNext,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
allowJs: true,
noEmit: true,
declaration: false,
Expand Down Expand Up @@ -344,6 +342,25 @@ async function createLanguageService(
...parsedConfig.options,
...forcedCompilerOptions
};
if (
!compilerOptions.moduleResolution ||
compilerOptions.moduleResolution === ts.ModuleResolutionKind.Classic
) {
compilerOptions.moduleResolution = ts.ModuleResolutionKind.NodeJs;
}
if (
!compilerOptions.module ||
[
ts.ModuleKind.AMD,
ts.ModuleKind.CommonJS,
ts.ModuleKind.ES2015,
ts.ModuleKind.None,
ts.ModuleKind.System,
ts.ModuleKind.UMD
].includes(compilerOptions.module)
) {
compilerOptions.module = ts.ModuleKind.ESNext;
}

// detect which JSX namespace to use (svelte | svelteNative) if not specified or not compatible
if (!compilerOptions.jsxFactory || !compilerOptions.jsxFactory.startsWith('svelte')) {
Expand Down

0 comments on commit 41f74e8

Please sign in to comment.