diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-02-21 08:35:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-21 08:35:25 -0500 |
commit | 9166d8a4e9b0f611b1e06c9e339b44f7c450d72e (patch) | |
tree | 1c4efed34b9c5bebc1f42fdaa8ad28dcca30896a /cli/tools/check.rs | |
parent | 061ee9d38cdf8ff0ade2373c1e075f841c534c47 (diff) |
feat(publish): type check on publish (#22506)
Supersedes #22501 and also fixes that issue.
Diffstat (limited to 'cli/tools/check.rs')
-rw-r--r-- | cli/tools/check.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cli/tools/check.rs b/cli/tools/check.rs index 08fc6f087..68bf9716e 100644 --- a/cli/tools/check.rs +++ b/cli/tools/check.rs @@ -44,6 +44,8 @@ pub struct CheckOptions { /// If true, valid `.tsbuildinfo` files will be ignored and type checking /// will always occur. pub reload: bool, + /// Mode to type check with. + pub type_check_mode: TypeCheckMode, } pub struct TypeChecker { @@ -97,6 +99,7 @@ impl TypeChecker { mut graph: ModuleGraph, options: CheckOptions, ) -> Result<(Arc<ModuleGraph>, Diagnostics), AnyError> { + debug_assert_ne!(options.type_check_mode, TypeCheckMode::None); if graph.roots.is_empty() { return Ok((graph.into(), Default::default())); } @@ -120,8 +123,8 @@ impl TypeChecker { } } + let type_check_mode = options.type_check_mode; let ts_config = ts_config_result.ts_config; - let type_check_mode = self.cli_options.type_check_mode(); let maybe_check_hash = match self.npm_resolver.check_state_hash() { Some(npm_check_hash) => { match get_check_hash( @@ -300,7 +303,13 @@ fn get_check_hash( } hasher.write_str(module.specifier.as_str()); - hasher.write_str(&module.source); + hasher.write_str( + // the fast check module will only be set when publishing + module + .fast_check_module() + .map(|s| s.source.as_ref()) + .unwrap_or(&module.source), + ); } Module::Node(_) => { // the @types/node package will be in the resolved |