diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9b9a2cbe00e..7266f3b0163 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9509,7 +9509,8 @@ namespace ts { // in the context of the target signature before checking the relationship. Ideally we'd do // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], /*erase*/ relation === comparableRelation, reportErrors); + const eraseGenerics = relation === comparableRelation || compilerOptions.noStrictGenericChecks; + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); } else { outer: for (const t of targetSignatures) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 2488ad68101..a21c9bd5cd9 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -620,6 +620,12 @@ namespace ts { category: Diagnostics.Advanced_Options, description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, + { + name: "noStrictGenericChecks", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, + }, { // A list of plugins to load in the language service name: "plugins", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 70efe50143e..eda408c03e5 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3278,6 +3278,10 @@ "category": "Message", "code": 6184 }, + "Disable strict checking of generic signatures in function types.": { + "category": "Message", + "code": 6185 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 28e135606d6..0b1f130bf6c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3522,6 +3522,7 @@ namespace ts { noImplicitAny?: boolean; // Always combine with strict property noImplicitReturns?: boolean; noImplicitThis?: boolean; // Always combine with strict property + noStrictGenericChecks?: boolean; noUnusedLocals?: boolean; noUnusedParameters?: boolean; noImplicitUseStrict?: boolean;