-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Hide function type missing props if return and target type same. #36746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14074,8 +14074,8 @@ namespace ts { | |
source: Type, | ||
target: Type, | ||
relation: Map<RelationComparisonResult>, | ||
headMessage: DiagnosticMessage | undefined, | ||
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, | ||
_headMessage: DiagnosticMessage | undefined, | ||
_containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, | ||
errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined | ||
): boolean { | ||
const callSignatures = getSignaturesOfType(source, SignatureKind.Call); | ||
|
@@ -14085,13 +14085,15 @@ namespace ts { | |
const returnType = getReturnTypeOfSignature(s); | ||
return !(returnType.flags & (TypeFlags.Any | TypeFlags.Never)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); | ||
})) { | ||
const resultObj: { errors?: Diagnostic[] } = errorOutputContainer || {}; | ||
checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); | ||
const diagnostic = resultObj.errors![resultObj.errors!.length - 1]; | ||
const [sourceType, targetType] = getTypeNamesForErrorDisplay(source, target); | ||
const diagnostic = error(node, Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); | ||
addRelatedInfo(diagnostic, createDiagnosticForNode( | ||
node, | ||
signatures === constructSignatures ? Diagnostics.Did_you_mean_to_use_new_with_this_expression : Diagnostics.Did_you_mean_to_call_this_expression | ||
)); | ||
if (errorOutputContainer && errorOutputContainer.skipLogging) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really familiar with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the else clause, you'd add the diagnostic to the headMessage or containingMessageChain, which is was |
||
(errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diagnostic); | ||
} | ||
return true; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
tests/cases/conformance/jsx/file.tsx(24,28): error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'? | ||
tests/cases/conformance/jsx/file.tsx(36,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement<any>'. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn't there supposed to be some new text about "did you mean to call?"? Or does that not apply in this case? |
||
Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props | ||
tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement<any>'. | ||
Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props | ||
|
||
|
||
==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== | ||
|
@@ -51,7 +49,6 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) = | |
) } | ||
~~~~~~~~~~~~~ | ||
!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement<any>'. | ||
!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props | ||
!!! related TS6212 tests/cases/conformance/jsx/file.tsx:36:15: Did you mean to call this expression? | ||
{ user => ( | ||
~~~~~~~~~ | ||
|
@@ -60,7 +57,6 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) = | |
) } | ||
~~~~~~~~~~~~~ | ||
!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement<any>'. | ||
!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props | ||
!!! related TS6212 tests/cases/conformance/jsx/file.tsx:39:15: Did you mean to call this expression? | ||
</FetchUser> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
tests/cases/compiler/elaborationForPossiblyCallableTypeStillReferencesArgumentAtTopLevel.ts(3,4): error TS2345: Argument of type 'new () => number' is not assignable to parameter of type 'number'. | ||
tests/cases/compiler/elaborationForPossiblyCallableTypeStillReferencesArgumentAtTopLevel.ts(3,4): error TS2322: Type 'new () => number' is not assignable to type 'number'. | ||
|
||
|
||
==== tests/cases/compiler/elaborationForPossiblyCallableTypeStillReferencesArgumentAtTopLevel.ts (1 errors) ==== | ||
declare var ohno: new () => number; | ||
declare function ff(t: number): void; | ||
ff(ohno) | ||
~~~~ | ||
!!! error TS2345: Argument of type 'new () => number' is not assignable to parameter of type 'number'. | ||
!!! error TS2322: Type 'new () => number' is not assignable to type 'number'. | ||
!!! related TS6213 tests/cases/compiler/elaborationForPossiblyCallableTypeStillReferencesArgumentAtTopLevel.ts:3:4: Did you mean to use 'new' with this expression? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these parameters are unused, personally, I'd remove them.