mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-22 11:19:32 +00:00
Switch monaco to off of moduleResolution: classic
Fixes #270408 Trying to move some of the monaco related checks/tconfigs off of `moduleResolution: classic`. This legacy config is causing a lot of pain while trying to update the trusted-types typings, which is itself blocking picking up the latest dompurify I initially tried a more scoped change but just could not get it working. So instead I ended up trying to rework our `LanguageServiceHost` to be more standard
This commit is contained in:
@@ -1,21 +1,26 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TypeScriptLanguageServiceHost = void 0;
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
const typescript_1 = __importDefault(require("typescript"));
|
||||
const node_fs_1 = __importDefault(require("node:fs"));
|
||||
/**
|
||||
* A TypeScript language service host
|
||||
*/
|
||||
class TypeScriptLanguageServiceHost {
|
||||
ts;
|
||||
libs;
|
||||
files;
|
||||
topLevelFiles;
|
||||
compilerOptions;
|
||||
defaultLibName;
|
||||
constructor(ts, libs, files, compilerOptions, defaultLibName) {
|
||||
constructor(ts, topLevelFiles, compilerOptions) {
|
||||
this.ts = ts;
|
||||
this.libs = libs;
|
||||
this.files = files;
|
||||
this.topLevelFiles = topLevelFiles;
|
||||
this.compilerOptions = compilerOptions;
|
||||
this.defaultLibName = defaultLibName;
|
||||
}
|
||||
// --- language service host ---------------
|
||||
getCompilationSettings() {
|
||||
@@ -23,8 +28,8 @@ class TypeScriptLanguageServiceHost {
|
||||
}
|
||||
getScriptFileNames() {
|
||||
return [
|
||||
...this.libs.keys(),
|
||||
...this.files.keys(),
|
||||
...this.topLevelFiles.keys(),
|
||||
this.ts.getDefaultLibFilePath(this.compilerOptions)
|
||||
];
|
||||
}
|
||||
getScriptVersion(_fileName) {
|
||||
@@ -34,14 +39,11 @@ class TypeScriptLanguageServiceHost {
|
||||
return '1';
|
||||
}
|
||||
getScriptSnapshot(fileName) {
|
||||
if (this.files.has(fileName)) {
|
||||
return this.ts.ScriptSnapshot.fromString(this.files.get(fileName));
|
||||
}
|
||||
else if (this.libs.has(fileName)) {
|
||||
return this.ts.ScriptSnapshot.fromString(this.libs.get(fileName));
|
||||
if (this.topLevelFiles.has(fileName)) {
|
||||
return this.ts.ScriptSnapshot.fromString(this.topLevelFiles.get(fileName));
|
||||
}
|
||||
else {
|
||||
return this.ts.ScriptSnapshot.fromString('');
|
||||
return typescript_1.default.ScriptSnapshot.fromString(node_fs_1.default.readFileSync(fileName).toString());
|
||||
}
|
||||
}
|
||||
getScriptKind(_fileName) {
|
||||
@@ -51,16 +53,19 @@ class TypeScriptLanguageServiceHost {
|
||||
return '';
|
||||
}
|
||||
getDefaultLibFileName(_options) {
|
||||
return this.defaultLibName;
|
||||
}
|
||||
isDefaultLibFileName(fileName) {
|
||||
return fileName === this.getDefaultLibFileName(this.compilerOptions);
|
||||
return this.ts.getDefaultLibFilePath(_options);
|
||||
}
|
||||
readFile(path, _encoding) {
|
||||
return this.files.get(path) || this.libs.get(path);
|
||||
if (this.topLevelFiles.get(path)) {
|
||||
return this.topLevelFiles.get(path);
|
||||
}
|
||||
return typescript_1.default.sys.readFile(path, _encoding);
|
||||
}
|
||||
fileExists(path) {
|
||||
return this.files.has(path) || this.libs.has(path);
|
||||
if (this.topLevelFiles.has(path)) {
|
||||
return true;
|
||||
}
|
||||
return typescript_1.default.sys.fileExists(path);
|
||||
}
|
||||
}
|
||||
exports.TypeScriptLanguageServiceHost = TypeScriptLanguageServiceHost;
|
||||
|
||||
Reference in New Issue
Block a user