-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Enforce compatibility with exactOptionalPropertyTypes
#36345
Conversation
This pull request was exported from Phabricator. Differential Revision: D43700862 |
@@ -281,12 +281,10 @@ export function SectionList_scrollable(Props: { | |||
ref={ref} | |||
ListHeaderComponent={HeaderComponent} | |||
ListFooterComponent={FooterComponent} | |||
// eslint-disable-next-line react/no-unstable-nested-components | |||
// $FlowFixMe[missing-local-annot] | |||
SectionSeparatorComponent={info => ( |
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.
⚠️ packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js line 285 – Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “SectionList_scrollable” and pass data as props. If you want to allow component creation in props, set allowAsProps option to true. (react/no-unstable-nested-components)
// $FlowFixMe[missing-local-annot] | ||
SectionSeparatorComponent={info => ( | ||
<CustomSeparatorComponent {...info} text="SECTION SEPARATOR" /> | ||
)} | ||
// eslint-disable-next-line react/no-unstable-nested-components | ||
// $FlowFixMe[missing-local-annot] | ||
ItemSeparatorComponent={info => ( |
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.
⚠️ packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js line 289 – Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “SectionList_scrollable” and pass data as props. If you want to allow component creation in props, set allowAsProps option to true. (react/no-unstable-nested-components)
Base commit: f4e56fd |
This pull request was exported from Phabricator. Differential Revision: D43700862 |
Summary: Pull Request resolved: facebook#36345 `exactOptionalPropertyTypes` is a TypeScript 4.4+ option set by users which changes behavior of optional properties, to disable accepting explicit `undefined`. This is not enabled when using `--strict`, and is stricter than Flow, leading to most of the typings having an `| undefined` unique to TypeScript (added with DefinitelyTyped/DefinitelyTyped@694c663). We have not always followed this (I have myself previously assumed the two are equivalent). We can enforce that the convention is followed with a plugin `eslint-plugin-redundant-undefined`. This forces us to declare that every optional property accepts an explicit undefined (which Flow would allow). Alternatively, if we do not want to support this, we can enable the existing dtslint rule `no-redundant-undefined`. Changelog: [General][Fixed] - Enforce compatibility with `exactOptionalPropertyTypes` Differential Revision: D43700862 fbshipit-source-id: 2dd18244145bd95935effeb1476a2ab010f2a32e
76c1aaa
to
7295a1a
Compare
This pull request was exported from Phabricator. Differential Revision: D43700862 |
Summary: Pull Request resolved: facebook#36345 `exactOptionalPropertyTypes` is a TypeScript 4.4+ option set by users which changes behavior of optional properties, to disable accepting explicit `undefined`. This is not enabled when using `--strict`, and is stricter than Flow, leading to most of the typings having an `| undefined` unique to TypeScript (added with DefinitelyTyped/DefinitelyTyped@694c663). We have not always followed this (I have myself previously assumed the two are equivalent). We can enforce that the convention is followed with a plugin `eslint-plugin-redundant-undefined`. This forces us to declare that every optional property accepts an explicit undefined (which Flow would allow). Alternatively, if we do not want to support this, we can enable the existing dtslint rule `no-redundant-undefined`. Changelog: [General][Fixed] - Enforce compatibility with `exactOptionalPropertyTypes` Differential Revision: D43700862 fbshipit-source-id: 20dcbdf02dda4c2ab5c0d61b4d3bee16475b7b44
7295a1a
to
33a16f9
Compare
@@ -18,6 +18,7 @@ | |||
"strict-export-declare-modifiers": false, | |||
"whitespace": false, | |||
"use-default-type-parameter": false, | |||
"no-redundant-jsdoc": false | |||
"no-redundant-jsdoc": false, | |||
"no-any-union": false |
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.
For what type do we need this currently?
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.
There are two in "globals.d.ts", where at least the websocket one is consistent with the ones TypeScript provides for browser code.
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.
We could constrain it a little more, but I think it would make a typing error for anything already assuming it is a specific value without checking.
I left a separate comment in microsoft/TypeScript#44419 (comment) since this style of mass-redundant-undefined removes signal the app is asking for, by saying explicit undefined is okay by default. We certainly haven't tested that it always works, but the main source of truth We could also instead clean the slate, and effectively undo DefinitelyTyped/DefinitelyTyped@694c663, so that future Also FYI @orta since you seem to have good context on how we should be treating these options 😅. |
33a16f9
to
2c5fc91
Compare
Summary: Pull Request resolved: facebook#36345 `exactOptionalPropertyTypes` is a TypeScript 4.4+ option set by users which changes behavior of optional properties, to disable accepting explicit `undefined`. This is not enabled when using `--strict`, and is stricter than Flow, leading to most of the typings having an `| undefined` unique to TypeScript (added with DefinitelyTyped/DefinitelyTyped@694c663). We have not always followed this (I have myself previously assumed the two are equivalent). We can enforce that the convention is followed with a plugin `eslint-plugin-redundant-undefined`. This forces us to declare that every optional property accepts an explicit undefined (which Flow would allow). Alternatively, if we do not want to support this, we can enable the existing dtslint rule `no-redundant-undefined`. Changelog: [General][Fixed] - Enforce compatibility with `exactOptionalPropertyTypes` Reviewed By: lunaleaps Differential Revision: D43700862 fbshipit-source-id: df1b7c99909db3b761fd6dd7498c1cf6c1cfa6fd
This pull request was exported from Phabricator. Differential Revision: D43700862 |
Summary: Pull Request resolved: facebook#36345 `exactOptionalPropertyTypes` is a TypeScript 4.4+ option set by users which changes behavior of optional properties, to disable accepting explicit `undefined`. This is not enabled when using `--strict`, and is stricter than Flow, leading to most of the typings having an `| undefined` unique to TypeScript (added with DefinitelyTyped/DefinitelyTyped@694c663). We have not always followed this (I have myself previously assumed the two are equivalent). We can enforce that the convention is followed with a plugin `eslint-plugin-redundant-undefined`. This forces us to declare that every optional property accepts an explicit undefined (which Flow would allow). Alternatively, if we do not want to support this, we can enable the existing dtslint rule `no-redundant-undefined`. Changelog: [General][Fixed] - Enforce compatibility with `exactOptionalPropertyTypes` Reviewed By: lunaleaps Differential Revision: D43700862 fbshipit-source-id: 85dd15b77a0b65304453395034bc52b60694b47b
2c5fc91
to
6d61a30
Compare
This pull request was exported from Phabricator. Differential Revision: D43700862 |
This pull request has been merged in 7858a21. |
Summary: Pull Request resolved: facebook#36345 `exactOptionalPropertyTypes` is a TypeScript 4.4+ option set by users which changes behavior of optional properties, to disable accepting explicit `undefined`. This is not enabled when using `--strict`, and is stricter than Flow, leading to most of the typings having an `| undefined` unique to TypeScript (added with DefinitelyTyped/DefinitelyTyped@694c663). We have not always followed this (I have myself previously assumed the two are equivalent). We can enforce that the convention is followed with a plugin `eslint-plugin-redundant-undefined`. This forces us to declare that every optional property accepts an explicit undefined (which Flow would allow). Alternatively, if we do not want to support this, we can enable the existing dtslint rule `no-redundant-undefined`. Changelog: [General][Fixed] - Enforce compatibility with `exactOptionalPropertyTypes` Reviewed By: lunaleaps Differential Revision: D43700862 fbshipit-source-id: 996094762b28918177521a9471d868ba87f0f263
Summary:
exactOptionalPropertyTypes
is a TypeScript 4.4+ option set by users which changes behavior of optional properties, to disable accepting explicitundefined
.This is not enabled when using
--strict
, and is stricter than Flow, leading to most of the typings having an| undefined
unique to TypeScript (added with DefinitelyTyped/DefinitelyTyped@694c663).We have not always followed this (I have myself previously assumed the two are equivalent), so this sets the flag in our tsconfig, and updates properties which are not compatible right now.
We can enforce that the convention is followed with a plugin
eslint-plugin-redundant-undefined
. This forces us to declare that every optional property accepts an explicit undefined (which Flow would allow). Alternatively, if we do not want to support this, we can enable the existing dtslint ruleno-redundant-undefined
.Changelog:
[General][Fixed] - Enforce compatibility with
exactOptionalPropertyTypes
Differential Revision: D43700862