vitalets / react-native-extended-stylesheet

Extended StyleSheets for React Native
MIT License
2.93k stars 132 forks source link

Property 'child' does not exist on type 'typeof EStyleSheet'. #106

Closed huestack closed 5 years ago

huestack commented 5 years ago

Function child is missing in typings for react-native-extended-stylesheet. When using it with Typescript, calling child method fails with following error message:

Property 'child' does not exist on type 'typeof EStyleSheet'.

Environment

React Native Environment Info: System: OS: macOS 10.14.4 CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Memory: 245.03 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 11.12.0 - /usr/local/bin/node Yarn: 1.15.2 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 Android SDK: API Levels: 19, 22, 23, 25, 27, 28 Build Tools: 28.0.3 System Images: android-19 | Intel x86 Atom, android-28 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.3 AI-182.5107.16.33.5314842 Xcode: 10.2/10E125 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.59.2 => 0.59.2 npmGlobalPackages: create-react-native-app: 2.0.2 create-react-native-typescript-app: 1.2.0 react-native-cli: 2.0.1

Gerasimov94 commented 5 years ago

same

Gerasimov94 commented 5 years ago

As temporary solution, you can create a types.d.ts file in root folder of your application and use this:

import {AnyObject} from 'react-native-extended-stylesheet';

declare namespace EStyleSheet {
    export function child(styles: AnyObject, type: string, index: number, arrLength: number): AnyObject;
}

declare module 'react-native-extended-stylesheet' {
    export = EStyleSheet
}

it's working fine for me.

huestack commented 5 years ago

@Gerasimov94 Thanks. I did that eventually.