diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2021-06-22 07:18:32 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 07:18:32 +1000 |
commit | 281c4cd8fcf5fd54f558a6922736def2c7804529 (patch) | |
tree | 65ac91c5a41a64dc0b85ee9c5949d7086e8620ef /cli/tsc | |
parent | cda15f2a98b10330422d1c8352d163d703ee6a49 (diff) |
feat(cli): support "types" when type checking (#10999)
Fixes #10677
Diffstat (limited to 'cli/tsc')
-rw-r--r-- | cli/tsc/99_main_compiler.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index be0ed012a..a2f3af176 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -19,6 +19,9 @@ delete Object.prototype.__proto__; let logDebug = false; let logSource = "JS"; + /** @type {string=} */ + let cwd; + // The map from the normalized specifier to the original. // TypeScript normalizes the specifier in its internal processing, // but the original specifier is needed when looking up the source from the runtime. @@ -130,7 +133,6 @@ delete Object.prototype.__proto__; // analysis in Rust operates on fully resolved URLs, // it makes sense to use the same scheme here. const ASSETS = "asset:///"; - const CACHE = "cache:///"; /** Diagnostics that are intentionally ignored when compiling TypeScript in * Deno, as they provide misleading or incorrect information. */ @@ -251,9 +253,10 @@ delete Object.prototype.__proto__; * * @type {ts.CompilerHost & ts.LanguageServiceHost} */ const host = { - fileExists(fileName) { - debug(`host.fileExists("${fileName}")`); - return false; + fileExists(specifier) { + debug(`host.fileExists("${specifier}")`); + specifier = normalizedToOriginalMap.get(specifier) ?? specifier; + return core.opSync("op_exists", { specifier }); }, readFile(specifier) { debug(`host.readFile("${specifier}")`); @@ -317,7 +320,8 @@ delete Object.prototype.__proto__; ); }, getCurrentDirectory() { - return CACHE; + debug(`host.getCurrentDirectory()`); + return cwd ?? core.opSync("op_cwd", null); }, getCanonicalFileName(fileName) { return fileName; @@ -787,12 +791,13 @@ delete Object.prototype.__proto__; } } - /** @param {{ debug: boolean; }} init */ - function serverInit({ debug: debugFlag }) { + /** @param {{ debug: boolean; rootUri?: string; }} init */ + function serverInit({ debug: debugFlag, rootUri }) { if (hasStarted) { throw new Error("The language server has already been initialized."); } hasStarted = true; + cwd = rootUri; languageService = ts.createLanguageService(host); setLogDebug(debugFlag, "TSLS"); debug("serverInit()"); |