Skip to content

Commit

Permalink
- improve declaration types so they no longer resolve to the type fil…
Browse files Browse the repository at this point in the history
…e and instead map to the style implementation
  • Loading branch information
FrederickEngelhardt committed Jun 28, 2023
1 parent 3373651 commit 413f341
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,34 @@
* Adding key augmention is tracked here: https://github.com/Microsoft/TypeScript/issues/12754
*/

import {StyleSheet} from 'react-native';
import { StyleSheet, ViewStyle, TextStyle, ImageStyle } from "react-native";

export = EStyleSheet;

declare namespace EStyleSheet {
type AnyObject<T = {}> = T & {[key: string]: any};
type Event = 'build';
type NamedStyles<T> = { [P in keyof T]: ViewStyle | TextStyle | ImageStyle };
type Event = "build";

export function create<T extends NamedStyles<T> | NamedStyles<any>>(
styles: T | NamedStyles<T>
): T;
export function build<T>(
rawGlobalVars?: NamedStyles<T> | Record<string, any>
): void;
export function value<T>(expr: any, prop?: string): any;
export function child<T>(
styles: NamedStyles<T>,
styleName: string,
index: number,
count: number
): NamedStyles<T>;
export function subscribe(event: Event, listener: () => any): void;
export function clearCache(): void;

export function create<T>(styles: AnyObject<T>): AnyObject<T>;
export function build<T>(rawGlobalVars?: T): void;
export function value<T>(expr: any, prop?: string): any;
export function child<T>(styles: T, styleName: string, index: number, count: number): T;
export function subscribe(event: Event, listener: () => any): void;
export function clearCache(): void;

// inherited from StyleSheet
export const flatten: typeof StyleSheet.flatten;
export const setStyleAttributePreprocessor: typeof StyleSheet.setStyleAttributePreprocessor;
export const hairlineWidth: typeof StyleSheet.hairlineWidth;
export const absoluteFillObject: typeof StyleSheet.absoluteFillObject;
export const absoluteFill: typeof StyleSheet.absoluteFill;
// inherited from StyleSheet
export const flatten: typeof StyleSheet.flatten;
export const setStyleAttributePreprocessor: typeof StyleSheet.setStyleAttributePreprocessor;
export const hairlineWidth: typeof StyleSheet.hairlineWidth;
export const absoluteFillObject: typeof StyleSheet.absoluteFillObject;
export const absoluteFill: typeof StyleSheet.absoluteFill;
}


0 comments on commit 413f341

Please sign in to comment.