Skip to content

fix(react): Reduce error message noise - #43215

Merged
uniqueiniquity merged 1 commit into
DefinitelyTyped:masterfrom
eps1lon:fix/react/better-error
Mar 31, 2020
Merged

uniqueiniquity merged 1 commit into
DefinitelyTyped:masterfrom
eps1lon:fix/react/better-error

Conversation

@eps1lon

@eps1lon eps1lon commented Mar 18, 2020 •

Copy link
Copy Markdown
Collaborator

We currently can't allow all possible react nodes as return types from render since these are hardcoded into TypeScript. It's therefore very likely that one encounters TypeScript errors that are false alarms e.g. const FunctionComponent5: React.FunctionComponent = () => false;. These produce noisy error messages and frustrated users:

With this change we remove the "noise".

Before:
ts-element-node-error-master

After:
ts-element-node-error-pr

in vscode 1.43.0 using typescript 3.8.3

@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback Author is Owner The author of this PR is a listed owner of the package. labels Mar 18, 2020
@typescript-bot

typescript-bot commented Mar 18, 2020 •

Copy link
Copy Markdown
Contributor

@eps1lon Thank you for submitting this PR!

🔔 @johnnyreilly @bbenezech @pzavolinsky @digiguru @ericanderson @DovydasNavickas @theruther4d @guilhermehubner @ferdaber @jrakotoharisoa @pascaloliv @Hotell @franklixuefei @Jessidhia @saranshkataria @lukyth @zieka @dancerphil @dimitropoulos - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot

typescript-bot commented Mar 18, 2020 •

Copy link
Copy Markdown
Contributor

A definition owner has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped!

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. and removed Awaiting reviewer feedback labels Mar 18, 2020
@orta

orta commented Mar 20, 2020

Copy link
Copy Markdown
Collaborator

I think I want a few more reviewers on this, the idea seems solid to me 👍

@eps1lon

eps1lon commented Mar 20, 2020

Copy link
Copy Markdown
Collaborator Author

I think I want a few more reviewers on this, the idea seems solid to me

I'm probably missing something but shouldn't it be more useful in the first place if typescript would just display it as not assignable to ReactElement i.e. skip the generic arguments? Why are the default generics useful here? Could I return a ReactElement where the generic arguments are not assignable?

@typescript-bot typescript-bot added the Other Approved This PR was reviewed and signed-off by a community member. label Mar 20, 2020
@uniqueiniquity

Copy link
Copy Markdown
Contributor

@eps1lon To make sure your feedback about displaying generic arguments in the error is seen and handled appropriately, I'd recommend you file an issue on the TypeScript repo itself.

Should I go ahead and merge this PR in the meantime?

@eps1lon

eps1lon commented Mar 31, 2020

Copy link
Copy Markdown
Collaborator Author

Yes, please.

@uniqueiniquity
uniqueiniquity merged commit 9986a0c into DefinitelyTyped:master Mar 31, 2020
@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/[email protected] to npm.

@eps1lon
eps1lon deleted the fix/react/better-error branch March 31, 2020 18:31
sbusch added a commit to sbusch/DefinitelyTyped that referenced this pull request Jul 27, 2020
typescript-bot pushed a commit that referenced this pull request Aug 22, 2020
…rop, fix tests by @sbusch

* fix types for other components (compare with event and eventWrapper, they just have no special props)

* also define props for view-specific event component override

* fix withDragAndDrop type definition. disable automatic exports.

* any is unnecessary here

* fix tests

* revert change to ViewsProps due to @eps1lon comments / #43215

* change DragAndDropCalendarProps from type to interface, as suggested by @DanielRosenwasser

* 🤖 Merge PR #46905 Package Proclaim: Make msg parameter optional for all assertions by @JakeChampion

* Make msg param optional for assertions in proclaim

* Mark message and operator params of fail as optional

* Update tests to check the optional parameters are indeed optionals

* Make the commonjs export of proclaim point to proclaim.ok function

* Add test to prove proclaim.ok points to proclaim

* Properly describe props for (custom) View, with new test with wrong prop (expecting error). Pass generic types for event and resource at more places (and fix test).

Plus: turned off automatic exports for index.d.ts aswell due to own Omit (added to keep compat with older TS versions).

* typo

* Revert strict views (with their disfunctional tests), but retain ViewProps for optional use (guarded with a test)

Strict views cannot expressed du to current limitaion in TypeScript, see <microsoft/TypeScript#13195>

Co-authored-by: Jake Champion <[email protected]>
chivesrs pushed a commit to chivesrs/DefinitelyTyped that referenced this pull request Sep 2, 2020
…ix withDragAndDrop, fix tests by @sbusch

* fix types for other components (compare with event and eventWrapper, they just have no special props)

* also define props for view-specific event component override

* fix withDragAndDrop type definition. disable automatic exports.

* any is unnecessary here

* fix tests

* revert change to ViewsProps due to @eps1lon comments / DefinitelyTyped#43215

* change DragAndDropCalendarProps from type to interface, as suggested by @DanielRosenwasser

* 🤖 Merge PR DefinitelyTyped#46905 Package Proclaim: Make msg parameter optional for all assertions by @JakeChampion

* Make msg param optional for assertions in proclaim

* Mark message and operator params of fail as optional

* Update tests to check the optional parameters are indeed optionals

* Make the commonjs export of proclaim point to proclaim.ok function

* Add test to prove proclaim.ok points to proclaim

* Properly describe props for (custom) View, with new test with wrong prop (expecting error). Pass generic types for event and resource at more places (and fix test).

Plus: turned off automatic exports for index.d.ts aswell due to own Omit (added to keep compat with older TS versions).

* typo

* Revert strict views (with their disfunctional tests), but retain ViewProps for optional use (guarded with a test)

Strict views cannot expressed du to current limitaion in TypeScript, see <microsoft/TypeScript#13195>

Co-authored-by: Jake Champion <[email protected]>
danielrearden pushed a commit to danielrearden/DefinitelyTyped that referenced this pull request Sep 22, 2020
…ix withDragAndDrop, fix tests by @sbusch

* fix types for other components (compare with event and eventWrapper, they just have no special props)

* also define props for view-specific event component override

* fix withDragAndDrop type definition. disable automatic exports.

* any is unnecessary here

* fix tests

* revert change to ViewsProps due to @eps1lon comments / DefinitelyTyped#43215

* change DragAndDropCalendarProps from type to interface, as suggested by @DanielRosenwasser

* 🤖 Merge PR DefinitelyTyped#46905 Package Proclaim: Make msg parameter optional for all assertions by @JakeChampion

* Make msg param optional for assertions in proclaim

* Mark message and operator params of fail as optional

* Update tests to check the optional parameters are indeed optionals

* Make the commonjs export of proclaim point to proclaim.ok function

* Add test to prove proclaim.ok points to proclaim

* Properly describe props for (custom) View, with new test with wrong prop (expecting error). Pass generic types for event and resource at more places (and fix test).

Plus: turned off automatic exports for index.d.ts aswell due to own Omit (added to keep compat with older TS versions).

* typo

* Revert strict views (with their disfunctional tests), but retain ViewProps for optional use (guarded with a test)

Strict views cannot expressed du to current limitaion in TypeScript, see <microsoft/TypeScript#13195>

Co-authored-by: Jake Champion <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author is Owner The author of this PR is a listed owner of the package. Other Approved This PR was reviewed and signed-off by a community member. Owner Approved A listed owner of this package signed off on the pull request. Popular package This PR affects a popular package (as counted by NPM download counts).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants