Register returns any, breaking typescript's type check
See original GitHub issueDescribe the bug
The register
function returns any
, breaking typescript’s type check.
Code snippet
// MyComponent/index.ts
import { register } from 'react-native-bundle-splitter';
export default register({ loader: () => import('./MyComponent') });
// MyComponent/MyComponent.tsx
import React from 'react';
import { View } from 'react-native';
type Props = {
isActive: boolean;
};
export default (_props: Props) => {
return <View />;
};
// Screens/index.tsx
import React from 'react';
import MyComponent from '../MyComponent';
export default () => {
// The following code should fail the type check
return <MyComponent wrongProp1={[]} wrongProp2={false} />;
};
Repo for reproducing https://github.com/demedos/bundle-split-repro
To Reproduce Steps to reproduce the behavior:
- Add the bundle split to a component
- Import the component into another one
- Pass the wrong props
Expected behavior
Typescript’s type check (yarn tsc
) should throw an error
Screenshots If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
- Desktop OS: NA
- Device: NA
- OS: NA
- JS engine: NA
- Library version: 2.1.0
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Casting to :any breaks type check - Stack Overflow
I would expect some error message like Type any is not assignable to type string . I let a bug slip through to...
Read more >Runtime type checking · Issue #1573 · microsoft/TypeScript
I request a runtime type checking system that perhaps looks something like this: function square(x: number!) { return x * x; } Where...
Read more >Take control of unexpected data at runtime with TypeScript
Using TypeScript to stop unexpected data from breaking your app. In this article, we'll explore how to use TypeScript type definitions to ...
Read more >TSConfig Reference - Docs on every TSConfig option
Ensures that any non-empty case inside a switch statement includes either break or return . This means you won't accidentally ship a case...
Read more >A Complete Guide to Using TypeScript in Node.js - Better Stack
The TypeScript compiler is able to automatically detect the types of any library that's written in TypeScript (like date-fns ), so that it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closed, because https://github.com/kirillzyusko/react-native-bundle-splitter/pull/34 has been merged.
Sounds good, thank you 🙂 The only downside of this is that passing
FC<Props>
as a generic may be wrong, because even if the source component is a FC,optimized
always returns a new pure component. Nonetheless, it should work without any problem