Apply code formatting

This commit is contained in:
copilot-swe-agent[bot] 2025-09-03 23:39:48 +00:00
parent 7cbbb7e307
commit 381d4a61bd
2 changed files with 59 additions and 58 deletions

View File

@ -1123,6 +1123,8 @@ import {
VariableLikeDeclaration,
VariableStatement,
VarianceFlags,
Version,
versionMajorMinor,
visitEachChild as visitEachChildWorker,
visitNode,
visitNodes,
@ -1132,15 +1134,13 @@ import {
walkUpBindingElementsAndPatterns,
walkUpOuterExpressions,
walkUpParenthesizedExpressions,
walkUpParenthesizedTypes,
walkUpParenthesizedTypesAndGetParentAndChild,
Version,
versionMajorMinor,
WhileStatement,
WideningContext,
WithStatement,
WriterContextOut,
YieldExpression,
walkUpParenthesizedTypes,
walkUpParenthesizedTypesAndGetParentAndChild,
WhileStatement,
WideningContext,
WithStatement,
WriterContextOut,
YieldExpression,
} from "./_namespaces/ts.js";
import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers.js";
import * as performance from "./_namespaces/ts.performance.js";
@ -47994,47 +47994,48 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}
if (isIdentifier(node.name)) {
checkCollisionsForDeclarationName(node, node.name);
if (!(node.flags & (NodeFlags.Namespace | NodeFlags.GlobalAugmentation))) {
const sourceFile = getSourceFileOfNode(node);
const pos = getNonModifierTokenPosOfNode(node);
const span = getSpanOfTokenAtPosition(sourceFile, pos);
// Check if we should generate an error (TS 6.0+) or suggestion (older versions)
const currentVersion = new Version(versionMajorMinor);
const errorVersion = new Version("6.0");
const shouldError = currentVersion.compareTo(errorVersion) >= Comparison.EqualTo;
// Check if ignoreDeprecations should suppress this error
let shouldSuppress = false;
if (shouldError && compilerOptions.ignoreDeprecations) {
// Only valid ignoreDeprecations values: "5.0" and "6.0"
if (compilerOptions.ignoreDeprecations === "6.0") {
shouldSuppress = true;
}
}
if (shouldError && !shouldSuppress) {
// In TypeScript 6.0+, this is an error unless suppressed by ignoreDeprecations
const errorDiagnostic = createFileDiagnostic(
sourceFile,
span.start,
span.length,
Diagnostics.The_module_keyword_is_not_allowed_for_namespace_declarations_Use_the_namespace_keyword_instead
);
diagnostics.add(errorDiagnostic);
} else {
// In older versions or when suppressed, keep as suggestion
const suggestionDiagnostic = createFileDiagnostic(
sourceFile,
span.start,
span.length,
Diagnostics.A_namespace_declaration_should_not_be_declared_using_the_module_keyword_Please_use_the_namespace_keyword_instead
);
suggestionDiagnostics.add(suggestionDiagnostic);
}
}
if (isIdentifier(node.name)) {
checkCollisionsForDeclarationName(node, node.name);
if (!(node.flags & (NodeFlags.Namespace | NodeFlags.GlobalAugmentation))) {
const sourceFile = getSourceFileOfNode(node);
const pos = getNonModifierTokenPosOfNode(node);
const span = getSpanOfTokenAtPosition(sourceFile, pos);
// Check if we should generate an error (TS 6.0+) or suggestion (older versions)
const currentVersion = new Version(versionMajorMinor);
const errorVersion = new Version("6.0");
const shouldError = currentVersion.compareTo(errorVersion) >= Comparison.EqualTo;
// Check if ignoreDeprecations should suppress this error
let shouldSuppress = false;
if (shouldError && compilerOptions.ignoreDeprecations) {
// Only valid ignoreDeprecations values: "5.0" and "6.0"
if (compilerOptions.ignoreDeprecations === "6.0") {
shouldSuppress = true;
}
}
if (shouldError && !shouldSuppress) {
// In TypeScript 6.0+, this is an error unless suppressed by ignoreDeprecations
const errorDiagnostic = createFileDiagnostic(
sourceFile,
span.start,
span.length,
Diagnostics.The_module_keyword_is_not_allowed_for_namespace_declarations_Use_the_namespace_keyword_instead,
);
diagnostics.add(errorDiagnostic);
}
else {
// In older versions or when suppressed, keep as suggestion
const suggestionDiagnostic = createFileDiagnostic(
sourceFile,
span.start,
span.length,
Diagnostics.A_namespace_declaration_should_not_be_declared_using_the_module_keyword_Please_use_the_namespace_keyword_instead,
);
suggestionDiagnostics.add(suggestionDiagnostic);
}
}
}
checkExportsOnMergedDeclarations(node);

View File

@ -1820,14 +1820,14 @@
"category": "Error",
"code": 1539
},
"A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead.": {
"category": "Suggestion",
"code": 1540,
"reportsDeprecated": true
},
"The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead.": {
"category": "Error",
"code": 1547
"A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead.": {
"category": "Suggestion",
"code": 1540,
"reportsDeprecated": true
},
"The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead.": {
"category": "Error",
"code": 1547
},
"Type-only import of an ECMAScript module from a CommonJS module must have a 'resolution-mode' attribute.": {
"category": "Error",