From 0cf7ff0cfc3c3c0093d59513b0ce4ff5c373853c Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Mon, 4 Feb 2019 19:01:21 -0800 Subject: [PATCH 1/2] fix: abstract base classes should implement shared type interfaces ISSUES CLOSED: #683 --- packages/maker/base/src/Maker.ts | 2 +- packages/plugin/base/src/Plugin.ts | 7 +++++-- packages/publisher/base/src/Publisher.ts | 6 +++--- packages/utils/types/src/index.ts | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/maker/base/src/Maker.ts b/packages/maker/base/src/Maker.ts index 189d4f7355..250917b371 100644 --- a/packages/maker/base/src/Maker.ts +++ b/packages/maker/base/src/Maker.ts @@ -36,7 +36,7 @@ export interface MakerOptions { packageJSON: any; } -export default abstract class Maker { +export default abstract class Maker implements IForgeMaker { public config!: C; public abstract name: string; public abstract defaultPlatforms: ForgePlatform[]; diff --git a/packages/plugin/base/src/Plugin.ts b/packages/plugin/base/src/Plugin.ts index afab284caf..754d8388e2 100644 --- a/packages/plugin/base/src/Plugin.ts +++ b/packages/plugin/base/src/Plugin.ts @@ -1,9 +1,9 @@ -import { ForgeHookFn, StartOptions } from '@electron-forge/shared-types'; +import { ForgeConfig, ForgeHookFn, IForgePlugin, StartOptions } from '@electron-forge/shared-types'; import { ChildProcess } from 'child_process'; export { StartOptions }; -export default abstract class Plugin { +export default abstract class Plugin implements IForgePlugin { public abstract name: string; /* tslint:disable variable-name */ __isElectronForgePlugin!: true; @@ -17,6 +17,9 @@ export default abstract class Plugin { }); } + init(_dir: string, _config: ForgeConfig) { + } + getHook(hookName: string): ForgeHookFn | null { return null; } diff --git a/packages/publisher/base/src/Publisher.ts b/packages/publisher/base/src/Publisher.ts index 5e9e5f86fe..43637c4c00 100644 --- a/packages/publisher/base/src/Publisher.ts +++ b/packages/publisher/base/src/Publisher.ts @@ -1,4 +1,4 @@ -import { ForgePlatform, ForgeConfig, ForgeMakeResult } from '@electron-forge/shared-types'; +import { ForgePlatform, ForgeConfig, ForgeMakeResult, IForgePublisher } from '@electron-forge/shared-types'; /* eslint-disable no-unused-vars */ @@ -19,7 +19,7 @@ export interface PublisherOptions { forgeConfig: ForgeConfig; } -export default abstract class Publisher { +export default abstract class Publisher implements IForgePublisher { public abstract name: string; public defaultPlatforms?: ForgePlatform[]; /* tslint:disable variable-name */ @@ -38,7 +38,7 @@ export default abstract class Publisher { get platforms() { if (this.providedPlatforms) return this.providedPlatforms; if (this.defaultPlatforms) return this.defaultPlatforms; - return ['win32', 'linux', 'darwin', 'mas']; + return ['win32', 'linux', 'darwin', 'mas'] as ForgePlatform[]; } /** diff --git a/packages/utils/types/src/index.ts b/packages/utils/types/src/index.ts index 069033ad59..a7f1fa9620 100644 --- a/packages/utils/types/src/index.ts +++ b/packages/utils/types/src/index.ts @@ -60,7 +60,7 @@ export interface IForgePlugin { init(dir: string, forgeConfig: ForgeConfig): void; getHook?(hookName: string): ForgeHookFn | null; - startLogic?(opts: StartOptions): Promise; + startLogic?(opts: StartOptions): Promise; } export interface IForgeResolvableMaker { @@ -71,7 +71,7 @@ export interface IForgeResolvableMaker { export interface IForgeMaker { __isElectronForgeMaker: boolean; - platforms?: undefined; + readonly platforms?: ForgePlatform[]; } export interface IForgeResolvablePublisher { @@ -82,7 +82,7 @@ export interface IForgeResolvablePublisher { export interface IForgePublisher { __isElectronForgePublisher: boolean; - platforms?: undefined; + readonly platforms?: ForgePlatform[]; } export interface StartOptions { From fbe47fefc0cfaac2bbaffcee07a03d0ddf3cf5a9 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Tue, 5 Feb 2019 18:01:26 -0800 Subject: [PATCH 2/2] tslint doesn't like it when I indicate unused vars --- packages/plugin/base/src/Plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin/base/src/Plugin.ts b/packages/plugin/base/src/Plugin.ts index 754d8388e2..14d63ef220 100644 --- a/packages/plugin/base/src/Plugin.ts +++ b/packages/plugin/base/src/Plugin.ts @@ -17,7 +17,7 @@ export default abstract class Plugin implements IForgePlugin { }); } - init(_dir: string, _config: ForgeConfig) { + init(dir: string, config: ForgeConfig) { } getHook(hookName: string): ForgeHookFn | null {