diff --git a/example/tsconfig.json b/example/tsconfig.json index 59862d7..0929738 100644 --- a/example/tsconfig.json +++ b/example/tsconfig.json @@ -11,7 +11,7 @@ "resolveJsonModule": true, "strict": true, "paths": { - "stitches-native": ["../src/index"] + "stitches-native": ["../src/types/index.d.ts"] }, } } diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index cd99538..0000000 --- a/src/index.ts +++ /dev/null @@ -1,63 +0,0 @@ -// NOTE: this index file is only used by the example Expo app in order to get typings working properly in the app - -import * as internals from './internals'; -import type Stitches from './types/stitches'; -import type * as Config from './types/config'; -import type * as CSSUtil from './types/css-util'; -import type * as StyledComponent from './types/styled-component'; - -export type CreateStitches = Config.CreateStitches; -export type CSSProperties = CSSUtil.CSSProperties; -export type DefaultThemeMap = Config.DefaultThemeMap; - -/** Returns a Style interface from a configuration, leveraging the given media and style map. */ - -export type CSS< - Config extends { - media?: {}; - theme?: {}; - themeMap?: {}; - utils?: {}; - } = { - media: {}; - theme: {}; - themeMap: {}; - utils: {}; - } -> = CSSUtil.CSS< - Config['media'], - Config['theme'], - Config['themeMap'], - Config['utils'] ->; - -/** Returns the properties, attributes, and children expected by a component. */ -export type ComponentProps = Component extends ( - ...args: any[] -) => any - ? Parameters[0] - : never; - -/** Returns a type that expects a value to be a kind of CSS property value. */ -export type PropertyValue = { - readonly [CSSUtil.$$PropertyValue]: K; -}; - -/** Returns a type that expects a value to be a kind of theme scale value. */ -export type ScaleValue = { readonly [CSSUtil.$$ScaleValue]: K }; - -/** Returns a type that suggests variants from a component as possible prop values. */ -export type VariantProps = StyledComponent.TransformProps< - Component[StyledComponent.$$StyledComponentProps], // TODO: why does TS complain here but not in `index.d.ts`? - Component[StyledComponent.$$StyledComponentMedia] ->; - -export const defaultThemeMap = internals.defaultThemeMap as unknown as Config.DefaultThemeMap; // prettier-ignore - -export const createStitches = internals.createStitches as unknown as Config.CreateStitches; // prettier-ignore - -export const styled = internals.styled as unknown as Stitches['styled']; - -export const css = internals.css as unknown as Stitches['css']; - -// TODO: should we export `createTheme`? How would that be used in RN? diff --git a/src/types/index.d.ts b/src/types/index.d.ts index b85b3d5..ce9f748 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -45,10 +45,11 @@ export type PropertyValue = { export type ScaleValue = { readonly [CSSUtil.$$ScaleValue]: K }; /** Returns a type that suggests variants from a component as possible prop values. */ -export type VariantProps = StyledComponent.TransformProps< - Component[StyledComponent.$$StyledComponentProps], - Component[StyledComponent.$$StyledComponentMedia] ->; +export type VariantProps = + StyledComponent.TransformProps< + Component[StyledComponent.$$StyledComponentProps], + Component[StyledComponent.$$StyledComponentMedia] + >; /** Map of CSS properties to token scales. */ export declare const defaultThemeMap: DefaultThemeMap;