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

Use of typescript generics for extended parametres

$
0
0

My purpose is simple: I want to find a way of using generics for extended parametres, in this example, throwData is the thing I am interested in. Instead of any, I want to use something more informative such as generic. Is there any way I can stuff like that?

 titleStylesCondition<    IP extends {      hasOwnProperty: (a: string) => boolean;      throwData?: any;      title?: string;    }>(itemProps: IP) {    const { palette, isDark } = this.context;    const styles = getStyles(palette, isDark);    const titleStyles = this.get("props.titleStyles", {});    if (      itemProps.hasOwnProperty("Industry") ||      itemProps.throwData.hasOwnProperty("Auto") ||      itemProps.title === "BMW"    ) {      return styles.autoStyling;  }

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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