feat(unstable/npm): initial type checking of npm specifiers (#16332)

This commit is contained in:
David Sherret 2022-10-21 11:20:18 -04:00 committed by GitHub
parent 0e1a71fec6
commit bcfe279fba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 2135 additions and 280 deletions

View file

@ -18,6 +18,7 @@ use crate::cache::TypeCheckCache;
use crate::diagnostics::Diagnostics;
use crate::graph_util::GraphData;
use crate::graph_util::ModuleEntry;
use crate::npm::NpmPackageResolver;
use crate::tsc;
use crate::tsc::Stats;
use crate::version;
@ -57,6 +58,7 @@ pub fn check(
roots: &[(ModuleSpecifier, ModuleKind)],
graph_data: Arc<RwLock<GraphData>>,
cache: &TypeCheckCache,
npm_resolver: NpmPackageResolver,
options: CheckOptions,
) -> Result<CheckResult, AnyError> {
let check_js = options.ts_config.get_check_js();
@ -106,6 +108,7 @@ pub fn check(
graph_data,
hash_data,
maybe_config_specifier: options.maybe_config_specifier,
maybe_npm_resolver: Some(npm_resolver.clone()),
maybe_tsbuildinfo,
root_names,
})?;
@ -114,6 +117,9 @@ pub fn check(
response.diagnostics.filter(|d| {
if let Some(file_name) = &d.file_name {
!file_name.starts_with("http")
&& ModuleSpecifier::parse(file_name)
.map(|specifier| !npm_resolver.in_npm_package(&specifier))
.unwrap_or(true)
} else {
true
}