Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Is it possible to defer binding third party TypeScript declarations used by a library until the consumer is compiled?

$
0
0

I am wondering if someone has any insight on how there might be a better solution for the issue detailed here: https://github.com/callstack/react-native-paper/issues/2965

Basically, this library uses a utility type to derive a type from something declared by @types/react-native. But, react-native is a peer dependency of this library and the runtime version is unknown when react-native-paper is compiled. Something like this:

type Props = React.ComponentProps<typeof NativeText> & {  style?: StyleProp<TextStyle>;  theme: ReactNativePaper.Theme;};

It seems the effect of this is that you wind up with compile errors if any consumers try to use react-native-paper with a version of react-native that differs from the version it was compiled with. Because the props of NativeText can and do vary between versions of react-native.

Is there a better way to do this? Is there some way to defer the binding/expansion of the utility types to when the library consumer code is actually getting compiled? At that time, the consumer should be supplying a version of @types/react-native that actually matches their runtime dependency version. Is there a way to have the compiler bind the types to the declarations provided by the consumer instead?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>