summaryrefslogtreecommitdiff
path: root/cli/tsc/99_main_compiler.js
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-10-25 18:35:09 +0100
committerGitHub <noreply@github.com>2024-10-25 18:35:09 +0100
commit38c7af456518ac4fdbd36e3bfa731c38195bb773 (patch)
tree363228814b1b43cda6252e1adabdcf24e3989bb7 /cli/tsc/99_main_compiler.js
parent730331622ee17cf603447f4eb53631b9cfd7bef1 (diff)
feat(lsp): "typescript.preferences.preferTypeOnlyAutoImports" setting (#26546)
Diffstat (limited to 'cli/tsc/99_main_compiler.js')
-rw-r--r--cli/tsc/99_main_compiler.js39
1 files changed, 5 insertions, 34 deletions
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js
index 719f2b982..e3a0bee59 100644
--- a/cli/tsc/99_main_compiler.js
+++ b/cli/tsc/99_main_compiler.js
@@ -516,7 +516,6 @@ delete Object.prototype.__proto__;
/** @typedef {{
* ls: ts.LanguageService & { [k:string]: any },
* compilerOptions: ts.CompilerOptions,
- * forceEnabledVerbatimModuleSyntax: boolean,
* }} LanguageServiceEntry */
/** @type {{ unscoped: LanguageServiceEntry, byScope: Map<string, LanguageServiceEntry> }} */
const languageServiceEntries = {
@@ -1026,7 +1025,7 @@ delete Object.prototype.__proto__;
: ts.sortAndDeduplicateDiagnostics(
checkFiles.map((s) => program.getSemanticDiagnostics(s)).flat(),
)),
- ].filter(filterMapDiagnostic.bind(null, false));
+ ].filter(filterMapDiagnostic);
// emit the tsbuildinfo file
// @ts-ignore: emitBuildInfo is not exposed (https://github.com/microsoft/TypeScript/issues/49871)
@@ -1041,28 +1040,11 @@ delete Object.prototype.__proto__;
debug("<<< exec stop");
}
- /**
- * @param {boolean} isLsp
- * @param {ts.Diagnostic} diagnostic
- */
- function filterMapDiagnostic(isLsp, diagnostic) {
+ /** @param {ts.Diagnostic} diagnostic */
+ function filterMapDiagnostic(diagnostic) {
if (IGNORED_DIAGNOSTICS.includes(diagnostic.code)) {
return false;
}
- if (isLsp) {
- // TS1484: `...` is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
- // We force-enable `verbatimModuleSyntax` in the LSP so the `type`
- // modifier is used when auto-importing types. But we don't want this
- // diagnostic unless it was explicitly enabled by the user.
- if (diagnostic.code == 1484) {
- const entry = (lastRequestScope
- ? languageServiceEntries.byScope.get(lastRequestScope)
- : null) ?? languageServiceEntries.unscoped;
- if (entry.forceEnabledVerbatimModuleSyntax) {
- return false;
- }
- }
- }
// make the diagnostic for using an `export =` in an es module a warning
if (diagnostic.code === 1203) {
diagnostic.category = ts.DiagnosticCategory.Warning;
@@ -1159,12 +1141,10 @@ delete Object.prototype.__proto__;
"strict": true,
"target": "esnext",
"useDefineForClassFields": true,
- "verbatimModuleSyntax": true,
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment",
}),
- forceEnabledVerbatimModuleSyntax: true,
};
setLogDebug(enableDebugLogging, "TSLS");
debug("serverInit()");
@@ -1230,17 +1210,8 @@ delete Object.prototype.__proto__;
const ls = oldEntry
? oldEntry.ls
: ts.createLanguageService(host, documentRegistry);
- let forceEnabledVerbatimModuleSyntax = false;
- if (!config["verbatimModuleSyntax"]) {
- config["verbatimModuleSyntax"] = true;
- forceEnabledVerbatimModuleSyntax = true;
- }
const compilerOptions = lspTsConfigToCompilerOptions(config);
- newByScope.set(scope, {
- ls,
- compilerOptions,
- forceEnabledVerbatimModuleSyntax,
- });
+ newByScope.set(scope, { ls, compilerOptions });
languageServiceEntries.byScope.delete(scope);
}
for (const oldEntry of languageServiceEntries.byScope.values()) {
@@ -1305,7 +1276,7 @@ delete Object.prototype.__proto__;
...ls.getSemanticDiagnostics(specifier),
...ls.getSuggestionDiagnostics(specifier),
...ls.getSyntacticDiagnostics(specifier),
- ].filter(filterMapDiagnostic.bind(null, true)));
+ ].filter(filterMapDiagnostic));
}
return respond(id, diagnosticMap);
} catch (e) {