diff --git a/index.d.ts b/index.d.ts index 3ece520..dc7c881 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,5 @@ export declare namespace Base { - interface Options { } + interface Options {} } declare type ApiExtension = { @@ -23,10 +23,10 @@ declare type UnionToIntersection = ( declare type AnyFunction = (...args: any) => any; declare type ReturnTypeOf = T extends AnyFunction - ? ReturnType - : T extends AnyFunction[] - ? UnionToIntersection, void>> - : never; + ? ReturnType + : T extends AnyFunction[] + ? UnionToIntersection, void>> + : never; type ClassWithPlugins = Constructor & { plugins: Plugin[]; @@ -34,22 +34,32 @@ type ClassWithPlugins = Constructor & { type RemainingRequirements = keyof PredefinedOptions extends never - ? Base.Options - : Omit + ? Base.Options + : Omit; type NonOptionalKeys = { [K in keyof Obj]: {} extends Pick ? undefined : K; }[keyof Obj]; -type RequiredIfRemaining = - NonOptionalKeys> extends undefined +type RequiredIfRemaining = NonOptionalKeys< + RemainingRequirements +> extends undefined ? [(Partial & NowProvided)?] - : [Partial & RemainingRequirements & NowProvided]; + : [ + Partial & + RemainingRequirements & + NowProvided + ]; -type ConstructorRequiringVersion = { +type ConstructorRequiringVersion< + Class extends ClassWithPlugins, + PredefinedOptions +> = { defaultOptions: PredefinedOptions; } & { - new (...options: RequiredIfRemaining): Class & { + new ( + ...options: RequiredIfRemaining + ): Class & { options: NowProvided & PredefinedOptions; }; }; @@ -78,12 +88,12 @@ export declare class Base { */ static plugin< Class extends ClassWithPlugins, - Plugins extends [Plugin, ...Plugin[]], - >( - this: Class, - ...plugins: Plugins, + Plugins extends [Plugin, ...Plugin[]] + >( + this: Class, + ...plugins: Plugins ): Class & { - plugins: [...Class['plugins'], ...Plugins]; + plugins: [...Class["plugins"], ...Plugins]; } & Constructor>>; /** @@ -104,7 +114,8 @@ export declare class Base { */ static defaults< PredefinedOptionsOne, - ClassOne extends Constructor> & ClassWithPlugins + ClassOne extends Constructor> & + ClassWithPlugins >( this: ClassOne, defaults: PredefinedOptionsOne @@ -122,8 +133,12 @@ export declare class Base { ): ConstructorRequiringVersion< ClassOne & ClassTwo & ClassThree, PredefinedOptionsOne & PredefinedOptionsTwo & PredefinedOptionsThree - > & ClassOne & ClassTwo & ClassThree; - } & ClassOne & ClassTwo; + > & + ClassOne & + ClassTwo & + ClassThree; + } & ClassOne & + ClassTwo; } & ClassOne; static defaultOptions: {}; @@ -135,4 +150,4 @@ export declare class Base { constructor(options: TOptions); } -export { }; +export {}; diff --git a/package-lock.json b/package-lock.json index e08142c..8c2324c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -946,6 +946,12 @@ "irregular-plurals": "^3.2.0" } }, + "prettier": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz", + "integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==", + "dev": true + }, "queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", diff --git a/package.json b/package.json index abae84e..19c48da 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ }, "types": "./index.d.ts", "scripts": { - "test": "npm run -s test:code && npm run -s test:typescript && npm run -s test:coverage", + "lint": "prettier --check '*.{md,json,js,ts}' 'examples/**' 'plugins/**'", + "lint:fix": "prettier --write '*.{md,json,js,ts}' 'examples/**' 'plugins/**'", + "test": "npm run -s test:code && npm run -s test:typescript && npm run -s test:coverage && npm run -s lint", "test:code": "c8 uvu . '^(examples/.*/)?test.js$'", "test:coverage": "c8 check-coverage", "test:typescript": "tsd && tsd examples/*" @@ -32,6 +34,7 @@ "license": "ISC", "devDependencies": { "c8": "^7.7.2", + "prettier": "^2.3.2", "tsd": "^0.17.0", "uvu": "^0.5.1" },