diff --git a/src/editor/Editor.tsx b/src/editor/Editor.tsx index 968c39d2..3033742e 100644 --- a/src/editor/Editor.tsx +++ b/src/editor/Editor.tsx @@ -225,7 +225,7 @@ const mapDispatchToProps: DispatchProps = { onProgramStorageChanged: storageChanged, // REVISIT: the options here might need to be changed - hopefully there is // one setting that works for all hub types for cases where we aren't connected. - onCheck: compile, + onCheck: (script) => compile(script, []), onToggleDocs: () => toggleBoolean(SettingId.ShowDocs), }; diff --git a/src/firmware/FlashButton.tsx b/src/firmware/FlashButton.tsx index cba488ad..89e73804 100644 --- a/src/firmware/FlashButton.tsx +++ b/src/firmware/FlashButton.tsx @@ -28,7 +28,7 @@ const mapDispatchToProps: DispatchProps = { onFile: flashFirmware, onReject: (file) => notification.add('error', `'${file.name}' is not a valid firmware file.`), - onClick: () => flashFirmware(), + onClick: () => flashFirmware(null), }; const mergeProps = ( diff --git a/src/firmware/actions.ts b/src/firmware/actions.ts index cda81bac..d02cd4e5 100644 --- a/src/firmware/actions.ts +++ b/src/firmware/actions.ts @@ -129,15 +129,15 @@ export type FailToFinishReason = * Action that flashes firmware to a hub. */ export type FlashFirmwareFlashAction = Action & { - /** The firmware zip file data or undefined to get firmware later. */ - data?: ArrayBuffer; + /** The firmware zip file data or `null` to get firmware later. */ + data: ArrayBuffer | null; }; /** * Creates a new action to flash firmware to a hub. - * @param data The firmware zip file data or undefined to get firmware later. + * @param data The firmware zip file data or `null` to get firmware later. */ -export function flashFirmware(data?: ArrayBuffer): FlashFirmwareFlashAction { +export function flashFirmware(data: ArrayBuffer | null): FlashFirmwareFlashAction { return { type: FlashFirmwareActionType.FlashFirmware, data }; } diff --git a/src/firmware/sagas.test.ts b/src/firmware/sagas.test.ts index e6504e4d..6ef5f873 100644 --- a/src/firmware/sagas.test.ts +++ b/src/firmware/sagas.test.ts @@ -88,7 +88,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -240,7 +240,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -296,7 +296,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -370,7 +370,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -440,7 +440,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -513,7 +513,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -579,7 +579,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -651,7 +651,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -739,7 +739,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -811,7 +811,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -912,7 +912,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -1022,7 +1022,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -1172,7 +1172,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader @@ -1854,7 +1854,7 @@ describe('flashFirmware', () => { // saga is triggered by this action - saga.put(flashFirmwareAction()); + saga.put(flashFirmwareAction(null)); // first step is to connect to the hub bootloader diff --git a/src/firmware/sagas.ts b/src/firmware/sagas.ts index a6e72b52..d3b36f60 100644 --- a/src/firmware/sagas.ts +++ b/src/firmware/sagas.ts @@ -277,7 +277,7 @@ function* flashFirmware(action: FlashFirmwareFlashAction): Generator { program = editor.getValue(); } - if (action.data !== undefined) { + if (action.data !== null) { ({ firmware, deviceId } = yield* loadFirmware(action.data, program)); } diff --git a/src/lwp3-bootloader/actions.ts b/src/lwp3-bootloader/actions.ts index 6efa0d25..c8ea49b6 100644 --- a/src/lwp3-bootloader/actions.ts +++ b/src/lwp3-bootloader/actions.ts @@ -124,13 +124,13 @@ export function didFailToConnect( export function didFailToConnect( reason: BootloaderConnectionFailureReason, - err?: Error, + arg1?: Error, ): BootloaderConnectionDidFailToConnectAction { if (reason === BootloaderConnectionFailureReason.Unknown) { return { type: BootloaderConnectionActionType.DidFailToConnect, reason, - err, + err: arg1, }; } return { type: BootloaderConnectionActionType.DidFailToConnect, reason }; diff --git a/src/mpy/actions.ts b/src/mpy/actions.ts index 7663f295..b84e8240 100644 --- a/src/mpy/actions.ts +++ b/src/mpy/actions.ts @@ -14,10 +14,10 @@ export type MpyCompileAction = Action & { /** The script to compile. */ readonly script: string; /** The compiler command line options */ - options?: string[]; + options: string[]; }; -export function compile(script: string, options?: string[]): MpyCompileAction { +export function compile(script: string, options: string[]): MpyCompileAction { return { type: MpyActionType.Compile, script, options }; } diff --git a/src/mpy/sagas.test.ts b/src/mpy/sagas.test.ts index 6a9fa18d..57878652 100644 --- a/src/mpy/sagas.test.ts +++ b/src/mpy/sagas.test.ts @@ -18,7 +18,7 @@ enum MpyFeatureFlags { test('compiler works', async () => { const saga = new AsyncSaga(mpy); - saga.put(compile('print("hello!")')); + saga.put(compile('print("hello!")', [])); const action = await saga.take(); expect(action.type).toBe(MpyActionType.DidCompile); @@ -32,7 +32,7 @@ test('compiler works', async () => { test('compiler error works', async () => { const saga = new AsyncSaga(mpy); - saga.put(compile('syntax error!')); + saga.put(compile('syntax error!', [])); const action = await saga.take(); expect(action.type).toBe(MpyActionType.DidFailToCompile);