mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(check): should not panic when all specified files excluded (#21929)
Closes #21926
This commit is contained in:
parent
b528ab0061
commit
b572a72add
6 changed files with 25 additions and 0 deletions
|
@ -50,6 +50,7 @@ use deno_graph::JsonModule;
|
|||
use deno_graph::Module;
|
||||
use deno_graph::Resolution;
|
||||
use deno_lockfile::Lockfile;
|
||||
use deno_runtime::colors;
|
||||
use deno_runtime::deno_fs;
|
||||
use deno_runtime::deno_node::NodeResolution;
|
||||
use deno_runtime::deno_node::NodeResolutionMode;
|
||||
|
@ -227,6 +228,11 @@ impl ModuleLoadPreparer {
|
|||
let lib = self.options.ts_type_lib_window();
|
||||
|
||||
let specifiers = self.collect_specifiers(files)?;
|
||||
|
||||
if specifiers.is_empty() {
|
||||
log::warn!("{} No matching files found.", colors::yellow("Warning"));
|
||||
}
|
||||
|
||||
self
|
||||
.prepare_module_load(
|
||||
specifiers,
|
||||
|
|
|
@ -161,6 +161,12 @@ itest!(check_imported_files_listed_in_exclude_option {
|
|||
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]
|
||||
fn cache_switching_config_then_no_config() {
|
||||
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>,
|
||||
options: CheckOptions,
|
||||
) -> Result<Diagnostics, AnyError> {
|
||||
if graph.roots.is_empty() {
|
||||
return Ok(Default::default());
|
||||
}
|
||||
|
||||
// node built-in specifiers use the @types/node package to determine
|
||||
// types, so inject that now (the caller should do this after the lockfile
|
||||
// has been written)
|
||||
|
|
Loading…
Reference in a new issue