Description
TypeScript Version: 2.8.0-dev.20180217
Search Terms: "is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes", "Property '[Symbol.unscopables]' is missing in type"
Code
bug.tsx:
// Test this by running tsc --jsx
import * as React from 'react';
import { View } from 'react-native'
const screen = {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}
export function Login() {
return(
<View style={ screen }>
</View>
)
}
I also created a repository with the correct dependencies to make debugging this easier:
https://github.com/frankpf/tsc-react-native-bug
Expected behavior:
No error.
Actual behavior:
On the <View style={ screen }>, I get this error:
src/bug.tsx(12,11): error TS2322: Type '{ children: never[]; style: { flex: number; justifyContent: string; alignItems: string; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<ViewProperties, ComponentState>> & Reado...'.
Type '{ children: never[]; style: { flex: number; justifyContent: string; alignItems: string; }; }' is not assignable to type 'Readonly<ViewProperties>'.
Types of property 'style' are incompatible.
Type '{ flex: number; justifyContent: string; alignItems: string; }' is not assignable to type 'StyleProp<ViewStyle>'.
Type '{ flex: number; justifyContent: string; alignItems: string; }' is not assignable to type 'RecursiveArray<false | ViewStyle | RegisteredStyle<ViewStyle> | null | undefined>'.
Property '[Symbol.unscopables]' is missing in type '{ flex: number; justifyContent: string; alignItems: string; }'.
One super weird thing is that if I just pass the object literal, I get no error. So
<View style={ screen }>
errors, but this
<View style= { flex: 1, justifyContent: 'center', alignItems: 'center' }}>
does not.
If I remove the justifyContent
and alignItems
properties from the screen
variable:
const screen = {
flex: 1
}
tsc also doesn't complain.