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
[react-native] Tests failing with typescript@next #30958
Comments
Let’s revert my PR for now if that fixes things. Alternatively just returning “any” instead of ReactType is fine I think. Perhaps what happened is that the TS tests used TS latest (3.1) and next (3.3) and didn’t cover 3.2 and we’ll need to test with 3.2. Edit: I think what happened is that the definition of |
This error is caused by 4dd9510 |
…pes/react 4dd9510 changed `React.ReactType` to look at entries in the `JSX.IntrinsicElements` map, which caused rendering `React.ReactType<any>` elements to fail. This commit fixes the RN type declarations by returning `any`. We don't care about the actual return type that much -- it's concretely a string but externally, as a user of react-native, you'd want to only use it as a JSX component type and not as a string. And since it's a string that isn't registered with `JSX.IntrinsicElements`, there's no extra type information (ex: list of valid props) associated with it. Longer term, it might make sense for `@types/react-native` to add native component types like `RCTView` to `JSX.IntrinsicElements` and go back to using `React.ReactType<'RCTView'>` with `requireNativeComponent`, but this is a disruptive change. Test plan: Ran tests, verified they pass again. Fixes #30958.
Tests for
@types/react-native
are failing with the following error, which is blocking many other PRs:It looks like it's related to TypeScripts improved tagged unions logic, as well as a recent change to the types for react-native in #30874 by @ide.
I'm not sure what the best route is to fix this -- it could be argued as either a
@types/react-native
issue, or a TypeScript issue -- but wanted to make sure that it was on people's radars.One possible solution could be to have
requireNativeComponent
return aReact.ComponentType<any>
instead of aReact.ReactType
, though I don't know what other effects that would have.There's a related (I think) issue in the Typescript repo here: microsoft/TypeScript#28631
@types/react-native
package and had problems.I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescriptN/A - occurs with typescript@nextDefinitions by:
inindex.d.ts
) so they can respond.The text was updated successfully, but these errors were encountered: