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/lsp/language_server.rs | |
parent | cda15f2a98b10330422d1c8352d163d703ee6a49 (diff) |
feat(cli): support "types" when type checking (#10999)
Fixes #10677
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r-- | cli/lsp/language_server.rs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 491e402ad..00f49b05d 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -70,6 +70,7 @@ pub struct StateSnapshot { pub assets: Assets, pub config: ConfigSnapshot, pub documents: DocumentCache, + pub maybe_config_uri: Option<ModuleSpecifier>, pub module_registries: registries::ModuleRegistry, pub performance: Performance, pub sources: Sources, @@ -92,6 +93,9 @@ pub(crate) struct Inner { module_registries: registries::ModuleRegistry, /// The path to the module registries cache module_registries_location: PathBuf, + /// An optional configuration file which has been specified in the client + /// options. + maybe_config_file: Option<ConfigFile>, /// An optional URL which provides the location of a TypeScript configuration /// file which will be used by the Deno LSP. maybe_config_uri: Option<Url>, @@ -138,6 +142,7 @@ impl Inner { config, diagnostics_server, documents: Default::default(), + maybe_config_file: Default::default(), maybe_config_uri: Default::default(), maybe_import_map: Default::default(), maybe_import_map_uri: Default::default(), @@ -326,6 +331,7 @@ impl Inner { LspError::internal_error() })?, documents: self.documents.clone(), + maybe_config_uri: self.maybe_config_uri.clone(), module_registries: self.module_registries.clone(), performance: self.performance.clone(), sources: self.sources.clone(), @@ -477,6 +483,7 @@ impl Inner { }; let (value, maybe_ignored_options) = config_file.as_compiler_options()?; tsconfig.merge(&value); + self.maybe_config_file = Some(config_file); self.maybe_config_uri = Some(config_url); if let Some(ignored_options) = maybe_ignored_options { // TODO(@kitsonk) turn these into diagnostics that can be sent to the @@ -2281,20 +2288,28 @@ impl Inner { if !params.uris.is_empty() { for identifier in ¶ms.uris { let specifier = self.url_map.normalize_url(&identifier.uri); - sources::cache(&specifier, &self.maybe_import_map) - .await - .map_err(|err| { - error!("{}", err); - LspError::internal_error() - })?; - } - } else { - sources::cache(&referrer, &self.maybe_import_map) + sources::cache( + &specifier, + &self.maybe_import_map, + &self.maybe_config_file, + ) .await .map_err(|err| { error!("{}", err); LspError::internal_error() })?; + } + } else { + sources::cache( + &referrer, + &self.maybe_import_map, + &self.maybe_config_file, + ) + .await + .map_err(|err| { + error!("{}", err); + LspError::internal_error() + })?; } // now that we have dependencies loaded, we need to re-analyze them and // invalidate some diagnostics |