mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
Enable noUncheckedSideEffectImports by default (#62443)
This commit is contained in:
@@ -1531,7 +1531,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
|
||||
var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
|
||||
var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
|
||||
var noUncheckedSideEffectImports = !!compilerOptions.noUncheckedSideEffectImports;
|
||||
var noUncheckedSideEffectImports = compilerOptions.noUncheckedSideEffectImports !== false;
|
||||
|
||||
var checkBinaryExpression = createCheckBinaryExpression();
|
||||
var emitResolver = createResolver();
|
||||
@@ -4684,9 +4684,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression, ignoreErrors?: boolean): Symbol | undefined {
|
||||
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression, ignoreErrors?: boolean, errorMessage?: DiagnosticMessage): Symbol | undefined {
|
||||
const isClassic = getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic;
|
||||
const errorMessage = isClassic ?
|
||||
errorMessage ??= isClassic ?
|
||||
Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option
|
||||
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
|
||||
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : errorMessage, ignoreErrors);
|
||||
@@ -48516,7 +48516,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
}
|
||||
else if (noUncheckedSideEffectImports && !importClause) {
|
||||
void resolveExternalModuleName(node, node.moduleSpecifier);
|
||||
void resolveExternalModuleName(node, node.moduleSpecifier, /*ignoreErrors*/ undefined, Diagnostics.Cannot_find_module_or_type_declarations_for_side_effect_import_of_0);
|
||||
}
|
||||
}
|
||||
checkImportAttributes(node);
|
||||
|
||||
@@ -1243,7 +1243,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
affectsBuildInfo: true,
|
||||
category: Diagnostics.Modules,
|
||||
description: Diagnostics.Check_side_effect_imports,
|
||||
defaultValueDescription: false,
|
||||
defaultValueDescription: true,
|
||||
},
|
||||
|
||||
// Source Maps
|
||||
|
||||
@@ -4007,6 +4007,10 @@
|
||||
"category": "Error",
|
||||
"code": 2881
|
||||
},
|
||||
"Cannot find module or type declarations for side-effect import of '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2882
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
Reference in New Issue
Block a user