From 22e36bfa12fec27e9b14f5a09339a9fb249bfa7d Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Tue, 9 Aug 2022 03:28:27 +0200 Subject: [PATCH] fix: declare module and fix conflict typing name (#805) * fix: declare module and fix conflict typing name * update css, marco, style --- css.d.ts | 21 +++++++++++++-------- index.d.ts | 30 ++++++++++++++++-------------- macro.d.ts | 20 +++++++++++--------- style.d.ts | 4 +++- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/css.d.ts b/css.d.ts index 30fb692f..d83e9977 100644 --- a/css.d.ts +++ b/css.d.ts @@ -1,11 +1,16 @@ // Definitions by: @types/styled-jsx -declare function css(chunks: TemplateStringsArray, ...args: any[]): JSX.Element -declare namespace css { - function global(chunks: TemplateStringsArray, ...args: any[]): JSX.Element - function resolve( - chunks: TemplateStringsArray, - ...args: any[] - ): { className: string; styles: JSX.Element } +declare module 'styled-jsx/css' { + function css(chunks: TemplateStringsArray, ...args: any[]): JSX.Element + namespace css { + export function global( + chunks: TemplateStringsArray, + ...args: any[] + ): JSX.Element + export function resolve( + chunks: TemplateStringsArray, + ...args: any[] + ): { className: string; styles: JSX.Element } + } + export = css } -export = css diff --git a/index.d.ts b/index.d.ts index 96825b65..3024c42c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -7,18 +7,20 @@ declare module 'react' { } } -export type StyleRegistry = { - styles(options?: { nonce?: string }): JSX.Element[] - flush(): void - add(props: any): void - remove(props: any): void +declare module 'styled-jsx' { + export type StyledJsxStyleRegistry = { + styles(options?: { nonce?: string }): JSX.Element[] + flush(): void + add(props: any): void + remove(props: any): void + } + export function useStyleRegistry(): StyledJsxStyleRegistry + export function StyleRegistry({ + children, + registry + }: { + children: JSX.Element | React.ReactNode + registry?: StyledJsxStyleRegistry + }): JSX.Element + export function createStyleRegistry(): StyledJsxStyleRegistry } -export function useStyleRegistry(): StyleRegistry -export function StyleRegistry({ - children, - registry -}: { - children: JSX.Element | React.ReactNode - registry?: StyleRegistry -}): JSX.Element -export function createStyleRegistry(): StyleRegistry diff --git a/macro.d.ts b/macro.d.ts index c9b7a4fa..3287392a 100644 --- a/macro.d.ts +++ b/macro.d.ts @@ -1,11 +1,13 @@ -declare namespace css { - function resolve( - chunks: TemplateStringsArray, - ...args: any[] - ): { - className: string - styles: JSX.Element +declare module 'styled-jsx/marco' { + namespace marco { + function resolve( + chunks: TemplateStringsArray, + ...args: any[] + ): { + className: string + styles: JSX.Element + } } -} -export = css + export = marco +} diff --git a/style.d.ts b/style.d.ts index 716fb641..5b58bcf3 100644 --- a/style.d.ts +++ b/style.d.ts @@ -1 +1,3 @@ -export default function JSXStyle(props: any): null +declare module 'styled-jsx/style' { + export default function JSXStyle(props: any): null +}