@@ -18,6 +18,10 @@ import {
18
18
import { SimpleFile } from './simple-file' ;
19
19
import { areUint8ArraysEqual } from './common' ;
20
20
21
+ /**
22
+ * Extends the interface from microbit-fs-building to include the board ID that
23
+ * corresponds to each of the cached objects.
24
+ */
21
25
interface MpFsBuilderCacheWithId extends MpFsBuilderCache {
22
26
boardId : number ;
23
27
}
@@ -32,6 +36,14 @@ export interface IntelHexWithId {
32
36
boardId : number ;
33
37
}
34
38
39
+ /**
40
+ * Options for importing Hex files into a MicropythonFsHex instance.
41
+ */
42
+ export interface ImportOptions {
43
+ overwrite ?: boolean ;
44
+ formatFirst ?: boolean ;
45
+ }
46
+
35
47
/**
36
48
* Manage filesystem files in one or multiple MicroPython hex files.
37
49
*
@@ -301,10 +313,7 @@ export class MicropythonFsHex implements FsInterface {
301
313
*/
302
314
importFilesFromIntelHex (
303
315
intelHex : string ,
304
- {
305
- overwrite = false ,
306
- formatFirst = false ,
307
- } : { overwrite ?: boolean ; formatFirst ?: boolean } = { }
316
+ { overwrite = false , formatFirst = false } : ImportOptions = { }
308
317
) : string [ ] {
309
318
const files = getIntelHexFiles ( intelHex ) ;
310
319
if ( ! Object . keys ( files ) . length ) {
@@ -347,10 +356,7 @@ export class MicropythonFsHex implements FsInterface {
347
356
*/
348
357
importFilesFromUniversalHex (
349
358
universalHex : string ,
350
- {
351
- overwrite = false ,
352
- formatFirst = false ,
353
- } : { overwrite ?: boolean ; formatFirst ?: boolean } = { }
359
+ { overwrite = false , formatFirst = false } : ImportOptions = { }
354
360
) : string [ ] {
355
361
if ( ! microbitUh . isUniversalHex ( universalHex ) ) {
356
362
throw new Error ( 'Universal Hex provided is invalid.' ) ;
@@ -428,17 +434,7 @@ export class MicropythonFsHex implements FsInterface {
428
434
* erases the files after there are no error during hex file parsing.
429
435
* @returns A filename list of added files.
430
436
*/
431
- importFilesFromHex (
432
- hexStr : string ,
433
- {
434
- overwrite = false ,
435
- formatFirst = false ,
436
- } : { overwrite ?: boolean ; formatFirst ?: boolean } = { }
437
- ) {
438
- const options = {
439
- overwrite,
440
- formatFirst,
441
- } ;
437
+ importFilesFromHex ( hexStr : string , options : ImportOptions = { } ) {
442
438
return microbitUh . isUniversalHex ( hexStr )
443
439
? this . importFilesFromUniversalHex ( hexStr , options )
444
440
: this . importFilesFromIntelHex ( hexStr , options ) ;
0 commit comments