Skip to content

Commit dc28aaa

Browse files
committed
Add --noStrictGenericChecks compiler option
1 parent d27f4d4 commit dc28aaa

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9509,7 +9509,8 @@ namespace ts {
95099509
// in the context of the target signature before checking the relationship. Ideally we'd do
95109510
// this regardless of the number of signatures, but the potential costs are prohibitive due
95119511
// to the quadratic nature of the logic below.
9512-
result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], /*erase*/ relation === comparableRelation, reportErrors);
9512+
const eraseGenerics = relation === comparableRelation || compilerOptions.noStrictGenericChecks;
9513+
result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors);
95139514
}
95149515
else {
95159516
outer: for (const t of targetSignatures) {

src/compiler/commandLineParser.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,12 @@ namespace ts {
620620
category: Diagnostics.Advanced_Options,
621621
description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files
622622
},
623+
{
624+
name: "noStrictGenericChecks",
625+
type: "boolean",
626+
category: Diagnostics.Advanced_Options,
627+
description: Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
628+
},
623629
{
624630
// A list of plugins to load in the language service
625631
name: "plugins",

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3278,6 +3278,10 @@
32783278
"category": "Message",
32793279
"code": 6184
32803280
},
3281+
"Disable strict checking of generic signatures in function types.": {
3282+
"category": "Message",
3283+
"code": 6185
3284+
},
32813285
"Variable '{0}' implicitly has an '{1}' type.": {
32823286
"category": "Error",
32833287
"code": 7005

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3522,6 +3522,7 @@ namespace ts {
35223522
noImplicitAny?: boolean; // Always combine with strict property
35233523
noImplicitReturns?: boolean;
35243524
noImplicitThis?: boolean; // Always combine with strict property
3525+
noStrictGenericChecks?: boolean;
35253526
noUnusedLocals?: boolean;
35263527
noUnusedParameters?: boolean;
35273528
noImplicitUseStrict?: boolean;

0 commit comments

Comments
 (0)