From b6f733ed153ceca5d2f052d95ebd4f78406aea76 Mon Sep 17 00:00:00 2001 From: Mark Lawlor Date: Mon, 29 Aug 2022 09:44:11 +1000 Subject: [PATCH] fix: typescript types after upgrade --- packages/nativewind/src/style-sheet/runtime.ts | 8 ++++++-- packages/nativewind/src/styled/index.tsx | 2 +- packages/nativewind/src/styled/use-tailwind.ts | 5 +++-- packages/nativewind/src/styled/with-styled-children.ts | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/nativewind/src/style-sheet/runtime.ts b/packages/nativewind/src/style-sheet/runtime.ts index 6450a54..d04f46e 100644 --- a/packages/nativewind/src/style-sheet/runtime.ts +++ b/packages/nativewind/src/style-sheet/runtime.ts @@ -47,7 +47,8 @@ export type Snapshot = Record; const emptyStyles: StylesArray = Object.assign([], { mask: 0 }); -export interface StylesArray extends Array> { +export interface StylesArray + extends Array> { childClassNames?: string[]; mask?: number; } @@ -467,7 +468,10 @@ export class StyleSheetRuntime extends ColorSchemeStore { return reEvaluate(); } - getChildStyles(parent: StylesArray, options: MatchChildAtRuleOptions) { + getChildStyles( + parent: StylesArray, + options: MatchChildAtRuleOptions + ) { if (!parent.childClassNames) return; const styles: Style[] = []; diff --git a/packages/nativewind/src/styled/index.tsx b/packages/nativewind/src/styled/index.tsx index 027654f..c5a9151 100644 --- a/packages/nativewind/src/styled/index.tsx +++ b/packages/nativewind/src/styled/index.tsx @@ -88,7 +88,7 @@ export function styled( * Actual implementation */ export function styled< - T extends { style?: StyleProp; children?: ReactNode | undefined }, + T extends { style?: StyleProp; children?: ReactNode | undefined }, P extends keyof T, C extends keyof T >( diff --git a/packages/nativewind/src/styled/use-tailwind.ts b/packages/nativewind/src/styled/use-tailwind.ts index ca87290..0dae145 100644 --- a/packages/nativewind/src/styled/use-tailwind.ts +++ b/packages/nativewind/src/styled/use-tailwind.ts @@ -2,16 +2,17 @@ import { useContext, useMemo } from "react"; import { StyleProp, StyleSheet } from "react-native"; import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector"; import { Snapshot, StoreContext, StylesArray } from "../style-sheet"; +import { Style } from "../style-sheet/runtime"; import { StateBitOptions } from "../utils/selector"; -export interface UseTailwindOptions extends StateBitOptions { +export interface UseTailwindOptions extends StateBitOptions { className: string; inlineStyles?: StyleProp; additionalStyles?: StylesArray; flatten?: boolean; } -export function useTailwind({ +export function useTailwind({ className, inlineStyles, additionalStyles, diff --git a/packages/nativewind/src/styled/with-styled-children.ts b/packages/nativewind/src/styled/with-styled-children.ts index b5adc56..2f5748c 100644 --- a/packages/nativewind/src/styled/with-styled-children.ts +++ b/packages/nativewind/src/styled/with-styled-children.ts @@ -7,7 +7,7 @@ import { ComponentState } from "./use-component-state"; export interface WithStyledChildrenOptions { componentChildren: ReactNode; store: StyleSheetRuntime; - stylesArray: StylesArray; + stylesArray: StylesArray; mask: number; componentState: ComponentState; }