Skip to content

Commit

Permalink
fix: add missing plugins type
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq committed Aug 21, 2023
1 parent 47d2edf commit df898ce
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 9 deletions.
2 changes: 0 additions & 2 deletions lib/config/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export interface Compile {
exclude?: string[]
}

export type AnyFn = (...args: unknown[]) => unknown

/**
* 小程序编译时的文件类型集合
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/config/design-width.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface DesignWidthFnInput {
export interface DesignWidthInput {
/**
* 样式文件内容
*/
Expand All @@ -17,6 +17,6 @@ export interface DesignWidthFnInput {
*
* @returns 设计稿尺寸
*/
export type DesignWidthFn = (input: DesignWidthFnInput) => number
export type DesignWidthFn = (input?: number | string | DesignWidthInput) => number

export type DesignWidth = number | DesignWidthFn
2 changes: 1 addition & 1 deletion lib/config/npm/cssnano.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @see https://github.com/cssnano/cssnano/blob/master/packages/cssnano/types/index.d.ts
*/

import type { AnyFn } from '../common'
import type { AnyFn } from '../../utility-types'

export type CSSNanoConfig<T> = T | [T] | [T, Record<string, any>]

Expand Down
3 changes: 2 additions & 1 deletion lib/config/npm/stylus-loader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/

import type { Buffer } from 'node:buffer'
import type { AnyFn, LoaderContext } from '../common'
import type { LoaderContext } from '../common'
import type { AnyFn } from '../../utility-types'
import type { StylusOptions } from './stylus'

export interface StylusOptionsResolveURL {
Expand Down
2 changes: 1 addition & 1 deletion lib/config/npm/stylus.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @see https://stylus-lang.com/
*/

import type { AnyFn } from '../common'
import type { AnyFn } from '../../utility-types'

export type StylusOptionsDefineItemValue = string | number | boolean

Expand Down
5 changes: 4 additions & 1 deletion lib/config/plugins/official/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { PluginHtmlOptions } from './html'
import type { PluginInjectOptions } from './inject'
import type { PluginHttpOptions } from './http'
import type { Awaitable } from '../../../utility-types'

export interface OfficialPluginOptionsMap {
'@tarojs/plugin-html': PluginHtmlOptions
Expand All @@ -11,5 +12,7 @@ export interface OfficialPluginOptionsMap {
export type OfficialPluginName = keyof OfficialPluginOptionsMap

export type OfficialPluginTuple = {
[K in OfficialPluginName]: [K, OfficialPluginOptionsMap[K]?]
[K in OfficialPluginName]:
| [K, OfficialPluginOptionsMap[K]?]
| [K, () => Awaitable<OfficialPluginOptionsMap[K]>]
}[OfficialPluginName]
6 changes: 5 additions & 1 deletion lib/config/plugins/third-party/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { Awaitable } from '../../../utility-types'

export interface ThirdPartyPluginOptionsMap {}

export type ThirdPartyPluginName = keyof ThirdPartyPluginOptionsMap

export type ThirdPartyPluginTuple = {
[K in ThirdPartyPluginName]: [K, ThirdPartyPluginOptionsMap[K]?]
[K in ThirdPartyPluginName]:
| [K, ThirdPartyPluginOptionsMap[K]?]
| [K, () => Awaitable<ThirdPartyPluginOptionsMap[K]>]
}[ThirdPartyPluginName]
15 changes: 15 additions & 0 deletions lib/utility-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Promise or not
*/
export type Awaitable<T> = T | PromiseLike<T>

/**
* Array or not
*/
export type Arrayable<T> = T | T[]

/**
* Any function
*/
export type AnyFn<T = unknown> = (...args: T[]) => T

/**
* A literal type that supports custom further strings but preserves autocompletion in IDEs.
*
Expand Down

0 comments on commit df898ce

Please sign in to comment.