You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Minimal ReactNative Component to illustrate the problem:
importReact,{Component}from'react';import{StyleSheet,Text}from'react-native';exportclassSampleextendsComponent<{},{}>{render(){return(<Textstyle={styles.text}>HelloTypeScript</Text> // error on styles, see below);}}conststyles=StyleSheet.create({text: {position: 'absolute',// cause of the error: string instead of 'absolute'top: 0,left: 0}});
Error:
error TS2322: Type '{ position: string; top: number; left: number; }' is not assignable to type 'TextStyle | undefined'.
Type '{ position: string; top: number; left: number; }' is not assignable to type 'TextStyle'.
Types of property 'position' are incompatible.
Type 'string' is not assignable to type '"absolute" | "relative" | undefined'.
I like it that the reactnative declaration doesn't use string, but only allows the set of possible strings.
Is there any way to let TypeScript infer this to type 'absolute'?
Maybe if I could mark this position field as readonly, it could infer to type 'absolute'.
TypeScript Version: 2.1.0-dev.20161008
Minimal ReactNative Component to illustrate the problem:
Error:
I like it that the reactnative declaration doesn't use string, but only allows the set of possible strings.
Is there any way to let TypeScript infer this to type 'absolute'?
Maybe if I could mark this
position
field as readonly, it could infer to type 'absolute'.Related to #10676?
The text was updated successfully, but these errors were encountered: