mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
fix(check): should not panic when all specified files excluded (#21929)
Closes #21926
This commit is contained in:
parent
daed588557
commit
d88c869917
6 changed files with 25 additions and 0 deletions
|
@ -50,6 +50,7 @@ use deno_graph::JsonModule;
|
||||||
use deno_graph::Module;
|
use deno_graph::Module;
|
||||||
use deno_graph::Resolution;
|
use deno_graph::Resolution;
|
||||||
use deno_lockfile::Lockfile;
|
use deno_lockfile::Lockfile;
|
||||||
|
use deno_runtime::colors;
|
||||||
use deno_runtime::deno_fs;
|
use deno_runtime::deno_fs;
|
||||||
use deno_runtime::deno_node::NodeResolution;
|
use deno_runtime::deno_node::NodeResolution;
|
||||||
use deno_runtime::deno_node::NodeResolutionMode;
|
use deno_runtime::deno_node::NodeResolutionMode;
|
||||||
|
@ -227,6 +228,11 @@ impl ModuleLoadPreparer {
|
||||||
let lib = self.options.ts_type_lib_window();
|
let lib = self.options.ts_type_lib_window();
|
||||||
|
|
||||||
let specifiers = self.collect_specifiers(files)?;
|
let specifiers = self.collect_specifiers(files)?;
|
||||||
|
|
||||||
|
if specifiers.is_empty() {
|
||||||
|
log::warn!("{} No matching files found.", colors::yellow("Warning"));
|
||||||
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
.prepare_module_load(
|
.prepare_module_load(
|
||||||
specifiers,
|
specifiers,
|
||||||
|
|
|
@ -161,6 +161,12 @@ itest!(check_imported_files_listed_in_exclude_option {
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(check_with_excluded_file_specified {
|
||||||
|
args: "check lib/types.d.ts",
|
||||||
|
cwd: Some("check/excluded_file_specified/"),
|
||||||
|
output: "check/excluded_file_specified/check.out",
|
||||||
|
});
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cache_switching_config_then_no_config() {
|
fn cache_switching_config_then_no_config() {
|
||||||
let context = TestContext::default();
|
let context = TestContext::default();
|
||||||
|
|
1
cli/tests/testdata/check/excluded_file_specified/check.out
vendored
Normal file
1
cli/tests/testdata/check/excluded_file_specified/check.out
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Warning No matching files found.
|
6
cli/tests/testdata/check/excluded_file_specified/deno.json
vendored
Normal file
6
cli/tests/testdata/check/excluded_file_specified/deno.json
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"types": ["./lib/types.d.ts"]
|
||||||
|
},
|
||||||
|
"exclude": ["lib"]
|
||||||
|
}
|
2
cli/tests/testdata/check/excluded_file_specified/lib/types.d.ts
vendored
Normal file
2
cli/tests/testdata/check/excluded_file_specified/lib/types.d.ts
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
declare var test: number;
|
|
@ -87,6 +87,10 @@ impl TypeChecker {
|
||||||
graph: Arc<ModuleGraph>,
|
graph: Arc<ModuleGraph>,
|
||||||
options: CheckOptions,
|
options: CheckOptions,
|
||||||
) -> Result<Diagnostics, AnyError> {
|
) -> Result<Diagnostics, AnyError> {
|
||||||
|
if graph.roots.is_empty() {
|
||||||
|
return Ok(Default::default());
|
||||||
|
}
|
||||||
|
|
||||||
// node built-in specifiers use the @types/node package to determine
|
// node built-in specifiers use the @types/node package to determine
|
||||||
// types, so inject that now (the caller should do this after the lockfile
|
// types, so inject that now (the caller should do this after the lockfile
|
||||||
// has been written)
|
// has been written)
|
||||||
|
|
Loading…
Reference in a new issue