Skip to content

Commit

Permalink
Add Additional JSDoc Typechecking (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbader-godaddy authored May 14, 2024
1 parent 9feff1f commit 5241b70
Show file tree
Hide file tree
Showing 199 changed files with 4,951 additions and 3,595 deletions.
1,557 changes: 1,059 additions & 498 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/gasket-cli/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface Dependencies {

export interface PackageJson extends Dependencies {
name: string;
version: string;
version?: string;
description?: string;
license?: string;
repository?:
Expand All @@ -21,6 +21,7 @@ export interface PackageJson extends Dependencies {
};
scripts?: Record<string, string>;
optionalDependencies?: Record<string, string>;
homepage?: string;
}

export interface ModuleInfo {
Expand Down
2 changes: 1 addition & 1 deletion packages/gasket-cli/test/unit/hooks/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const mockError = new Error('Bad things man.');
const mockConfig = { mocked: true };
const PluginEngine = require('@gasket/engine');

class MockCommand { };
class MockCommand { }
MockCommand.flags = {};

jest.mock('@gasket/engine');
Expand Down
2 changes: 1 addition & 1 deletion packages/gasket-data/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { GasketDataIntl } from '@gasket/plugin-intl';

declare module '@gasket/data' {
export interface GasketData {
config: { [key: string | number]: string | undefined };
config?: { [key: string | number]: string | undefined };
intl?: GasketDataIntl;
}

Expand Down
45 changes: 26 additions & 19 deletions packages/gasket-engine/lib/engine.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Configuration } from 'webpack';
declare module '@gasket/engine' {
export type MaybeMultiple<T> = T | Array<T>;
export type MaybeAsync<T> = T | Promise<T>;
Expand All @@ -6,7 +7,7 @@ declare module '@gasket/engine' {
// To be extended by plugins
export interface HookExecTypes {}

export type HookId = keyof HookExecTypes
export type HookId = keyof HookExecTypes;

export type HookTimings = {
before?: Array<string>;
Expand Down Expand Up @@ -41,8 +42,8 @@ declare module '@gasket/engine' {

// This is the config
export interface GasketConfig {
root: string,
env: string
root: string;
env: string;
}

export default class GasketEngine {
Expand All @@ -67,31 +68,33 @@ declare module '@gasket/engine' {
): ReturnType<HookExecTypes[Id]>;
execApply<Id extends HookId, Return = void>(
hook: Id,
callback: (plugin: Plugin, handler: ApplyHookHandler<Id>) => Promise<Return>
callback: (
plugin: Plugin,
handler: ApplyHookHandler<Id>
) => Promise<Return>
): Promise<Return[]>;
execApplySync<Id extends HookId, Return = void>(
hook: Id,
callback: (plugin: Plugin, handler: ApplyHookHandler<Id>) => Return
): Return[];

hook<Id extends HookId>(opts: {
event: Id,
pluginName?: string,
timing?: HookTimings,
handler: HookHandler<Id>
event: Id;
pluginName?: string;
timing?: HookTimings;
handler: HookHandler<Id>;
}): void;
}

export interface Gasket extends GasketEngine {
command: {
id: string
}
id: string;
};
}

type PartialRecursive<T> =
T extends Object
? { [K in keyof T]?: PartialRecursive<T[K]> } | undefined
: T | undefined
type PartialRecursive<T> = T extends Object
? { [K in keyof T]?: PartialRecursive<T[K]> } | undefined
: T | undefined;

type Plugins = {
plugins?: {
Expand All @@ -101,10 +104,14 @@ declare module '@gasket/engine' {
};
};

export type GasketConfigFile = Omit<GasketConfig, 'root' | 'env' | 'command'> & Plugins & {
root?: string,
env?: string,
export type GasketConfigFile = Omit<
GasketConfig,
'root' | 'env' | 'command'
> &
Plugins & {
root?: string;
env?: string;

environments?: Record<string, PartialRecursive<GasketConfig & Plugins>>
}
environments?: Record<string, PartialRecursive<GasketConfig & Plugins>>;
};
}
4 changes: 0 additions & 4 deletions packages/gasket-fetch/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const API = {

/**
* Assert fetch API compliant classes.
*
* @param {Function} Request constructor for Request class.
* @param {Function} Headers constructor for Headers class.
* @param {Function} Response constructor for Response class.
Expand All @@ -34,7 +33,6 @@ function assertExports(Request, Headers, Response) {

/**
* Assert fetch API executing GET request.
*
* @async
* @param {Function} fetch implementation of fetch.
* @returns {Function} runnable test descriptor.
Expand All @@ -55,7 +53,6 @@ function assertGet(fetch) {

/**
* Assert fetch API executing POST request.
*
* @async
* @param {Function} fetch implementation of fetch.
* @returns {Function} runnable test descriptor.
Expand Down Expand Up @@ -91,7 +88,6 @@ function assertPost(fetch) {

/**
* Assert AbortController aborting fetch requests.
*
* @async
* @param {Function} fetch implementation of fetch.
* @param {Function} AbortController constructor for aborting fetch request.
Expand Down
Loading

0 comments on commit 5241b70

Please sign in to comment.