Skip to content

Commit

Permalink
relax some typings where the actual generic type does not matter
Browse files Browse the repository at this point in the history
  • Loading branch information
sastan committed Feb 12, 2022
1 parent ae979d1 commit 28cbaef
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .changeset/brave-elephants-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'twind': patch
'@twind/with-next': patch
---

relax some typings where the actual generic type does not matter
3 changes: 2 additions & 1 deletion packages/twind/src/extract.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Twind } from './types'
import { consume } from './consume'
import { stringify } from './sheets'
import { tw as tw$ } from './runtime'
Expand Down Expand Up @@ -53,7 +54,7 @@ export interface ExtractResult {
* @param tw a {@link Twind} instance (default: twind managed tw)
* @returns the possibly modified html and css
*/
export function extract(html: string, tw = tw$): ExtractResult {
export function extract(html: string, tw: Twind<any, any> = tw$): ExtractResult {
tw.clear()
return { html: consume(html, tw), css: stringify(tw.target) }
}
3 changes: 2 additions & 1 deletion packages/twind/src/inline.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Twind } from './types'
import { extract } from './extract'
import { tw as tw$ } from './runtime'
import { identity } from './utils'
Expand All @@ -9,7 +10,7 @@ export interface InlineOptions {
/**
* {@link Twind} instance to use (default: {@link tw$ | module tw})
*/
tw?: typeof tw$
tw?: Twind<any, any>

/**
* Allows to minify the resulting CSS.
Expand Down
22 changes: 4 additions & 18 deletions packages/with-next/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
/* eslint-env node, browser */
import type { AppProps } from 'next/app'
import type { BaseTheme, TwindConfig, TwindUserConfig, Preset } from 'twind'
import type { TwindConfig, TwindUserConfig } from 'twind'

import { createElement } from 'react'
import { install as install$ } from 'twind'

export default install

function install<Theme extends BaseTheme = BaseTheme>(
config: TwindConfig<Theme>,
function install(
config: TwindConfig<any> | TwindUserConfig<any>,
): React.JSXElementConstructor<AppProps>

function install<Theme = BaseTheme, Presets extends Preset<any>[] = Preset[]>(
config: TwindUserConfig<Theme, Presets>,
): React.JSXElementConstructor<AppProps>

function install<Props, Component, Theme extends BaseTheme = BaseTheme>(
config: TwindConfig<Theme>,
AppComponent: React.JSXElementConstructor<Props> & Component,
): Component

function install<Props, Component, Theme = BaseTheme, Presets extends Preset<any>[] = Preset[]>(
config: TwindUserConfig<Theme, Presets>,
AppComponent: React.JSXElementConstructor<Props> & Component,
): Component

function install<Props, Component>(
config: TwindConfig | TwindUserConfig,
config: TwindConfig<any> | TwindUserConfig<any>,
AppComponent: React.JSXElementConstructor<Props> & Component,
): Component

Expand Down

0 comments on commit 28cbaef

Please sign in to comment.