Skip to content

Commit d38096a

Browse files
committed
chore: revert change in checker
1 parent 5853d2a commit d38096a

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16098,10 +16098,7 @@ namespace ts {
1609816098
const isPerformingExcessPropertyChecks = !(intersectionState & IntersectionState.Target) && (isObjectLiteralType(source) && getObjectFlags(source) & ObjectFlags.FreshLiteral);
1609916099
if (isPerformingExcessPropertyChecks) {
1610016100
if (hasExcessProperties(<FreshObjectLiteralType>source, target, reportErrors)) {
16101-
// Skip report relation error if there is diag with suggestion emitted
16102-
// So the fixSpelling can work with JSX attribute suggestion
16103-
const skipReport = isComparingJsxAttributes && errorInfo?.code === Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code;
16104-
if (reportErrors && !skipReport) {
16101+
if (reportErrors) {
1610516102
reportRelationError(headMessage, source, target);
1610616103
}
1610716104
return Ternary.False;

src/services/codefixes/fixSpelling.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ namespace ts.codefix {
77
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
88
Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code,
99
Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2.code,
10+
// for JSX class components
11+
Diagnostics.No_overload_matches_this_call.code,
12+
// for JSX FC
13+
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
1014
];
1115
registerCodeFix({
1216
errorCodes,
1317
getCodeActions(context) {
14-
const { sourceFile } = context;
15-
const info = getInfo(sourceFile, context.span.start, context);
18+
const { sourceFile, errorCode } = context;
19+
const info = getInfo(sourceFile, context.span.start, context, errorCode);
1620
if (!info) return undefined;
1721
const { node, suggestedSymbol } = info;
1822
const { target } = context.host.getCompilationSettings();
@@ -21,18 +25,23 @@ namespace ts.codefix {
2125
},
2226
fixIds: [fixId],
2327
getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => {
24-
const info = getInfo(diag.file, diag.start, context);
28+
const info = getInfo(diag.file, diag.start, context, diag.code);
2529
const { target } = context.host.getCompilationSettings();
2630
if (info) doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target!);
2731
}),
2832
});
2933

30-
function getInfo(sourceFile: SourceFile, pos: number, context: CodeFixContextBase): { node: Node, suggestedSymbol: Symbol } | undefined {
34+
function getInfo(sourceFile: SourceFile, pos: number, context: CodeFixContextBase, errorCode: number): { node: Node, suggestedSymbol: Symbol } | undefined {
3135
// This is the identifier of the misspelled word. eg:
3236
// this.speling = 1;
3337
// ^^^^^^^
3438
const node = getTokenAtPosition(sourceFile, pos);
3539
const parent = node.parent;
40+
// Only fix spelling for No_overload_matches_this_call emitted on the React class component
41+
if ((
42+
errorCode === Diagnostics.No_overload_matches_this_call.code ||
43+
errorCode === Diagnostics.Type_0_is_not_assignable_to_type_1.code) &&
44+
!isJsxAttribute(parent)) return undefined;
3645
const checker = context.program.getTypeChecker();
3746

3847
let suggestedSymbol: Symbol | undefined;

0 commit comments

Comments
 (0)