Turn on exactOptionalPropertyTypes (#110)

Turn on exactOptionalPropertyTypes
This commit is contained in:
Will Scullin 2022-05-11 17:20:49 -07:00 committed by GitHub
parent a46b0df970
commit d44cae76a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 72 additions and 154 deletions

View File

@ -51,14 +51,14 @@ interface State {
cpu: CpuState;
vm: VideoModesState;
io: Apple2IOState;
mmu?: MMUState;
ram?: RAMState[];
mmu: MMUState | undefined;
ram: RAMState[] | undefined;
}
export class Apple2 implements Restorable<State>, DebuggerContainer {
private paused = false;
private theDebugger?: Debugger;
private theDebugger: Debugger | undefined;
private runTimer: number | null = null;
private runAnimationFrame: number | null = null;

View File

@ -167,7 +167,7 @@ interface BaseDrive {
/** Displayed disk name */
name: string;
/** (Optional) Disk side (Front/Back, A/B) */
side?: string;
side?: string | undefined;
/** Quarter track position of read/write head. */
track: byte;
/** Position of the head on the track. */
@ -213,7 +213,7 @@ interface DriveState {
encoding: typeof ENCODING_BITSTREAM | typeof ENCODING_NIBBLE;
volume: byte;
name: string;
side?: string;
side?: string | undefined;
tracks: memory[];
track: byte;
head: byte;

View File

@ -11,8 +11,8 @@ import { loadJSON, loadHttpFile, getHashParts } from './util/files';
export interface DiskIIData {
number: 1 | 2;
on: boolean;
name?: string;
side?: string;
name: string;
side?: string | undefined;
}
/**

View File

@ -22,8 +22,16 @@ export interface DrivesProps {
*/
export const Drives = ({ io, sectors }: DrivesProps) => {
const [disk2, setDisk2] = useState<Disk2>();
const [data1, setData1] = useState<DiskIIData>({ on: false, number: 1, name: 'Disk 1' });
const [data2, setData2] = useState<DiskIIData>({ on: false, number: 2, name: 'Disk 2' });
const [data1, setData1] = useState<DiskIIData>({
on: false,
number: 1,
name: 'Disk 1',
});
const [data2, setData2] = useState<DiskIIData>({
on: false,
number: 2,
name: 'Disk 2',
});
useEffect(() => {
const setData = [setData1, setData2];
@ -32,7 +40,11 @@ export const Drives = ({ io, sectors }: DrivesProps) => {
setData[drive - 1]?.(data => ({...data, on }));
},
label: (drive, name, side) => {
setData[drive - 1]?.(data => ({...data, name, side }));
setData[drive - 1]?.(data => ({
...data,
name: name ?? `Disk ${drive}`,
side,
}));
},
dirty: () => {}
};

View File

@ -126,11 +126,14 @@ export const ModalCloseButton = ({ onClose }: ModalCloseButtonProp) => {
);
};
type OnCloseCallback = (closeBox?: boolean) => void;
/**
* ModalHeader component properties
*/
export interface ModalHeaderProps {
onClose?: (closeBox?: boolean) => void;
onClose?: OnCloseCallback;
title: string;
}
@ -166,20 +169,20 @@ export interface ModalProps {
*
* @param isOpen true to show modal
* @param title Modal title
* @onClose Close callback
* @param onClose Close callback
* @returns Modal component
*/
export const Modal: FunctionalComponent<ModalProps> = ({
isOpen,
title,
children,
onClose
title,
...props
}) => {
return (
isOpen ? (
<ModalOverlay>
<div style={modalStyle}>
{title && <ModalHeader onClose={onClose} title={title} />}
{title && <ModalHeader title={title} {...props} />}
{children}
</div>
</ModalOverlay>

View File

@ -10,7 +10,7 @@ export type DriveNumber = MemberOf<typeof DRIVE_NUMBERS>;
export interface DiskOptions {
name: string;
side?: string;
side?: string | undefined;
volume: byte;
readOnly: boolean;
data?: memory[][];
@ -48,7 +48,7 @@ export interface JSONBinaryImage {
export interface Disk {
name: string;
side?: string;
side?: string | undefined;
readOnly: boolean;
}

View File

@ -323,8 +323,8 @@ function doLoadLocal(drive: DriveNumber, file: File, options: Partial<LoadOption
} else if (includes(TAPE_TYPES, ext)) {
tape.doLoadLocalTape(file);
} else if (BIN_TYPES.includes(ext) || type === '06' || options.address) {
const address = aux !== undefined ? parseInt(aux, 16) : undefined;
doLoadBinary(file, { address, ...options });
const auxAddress = aux !== undefined ? { address: parseInt(aux, 16) } : {};
doLoadBinary(file, { ...options, ...auxAddress });
} else {
const addressInput = document.querySelector<HTMLInputElement>('#local_file_address');
const addressStr = addressInput?.value;

168
package-lock.json generated
View File

@ -37,8 +37,8 @@
"raw-loader": "^4.0.0",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.5",
"ts-loader": "^8.0.15",
"typescript": "^4.1.3",
"ts-loader": "^9.3.0",
"typescript": "^4.6.4",
"webpack": "^5.28.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.6.0",
@ -5263,17 +5263,16 @@
}
},
"node_modules/enhanced-resolve": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.5.0.tgz",
"integrity": "sha512-Nv9m36S/vxpsI+Hc4/ZGRs0n9mXqSWGGq49zxb/cJfPAQMbUtttJAlNPS4AQzaBdw/pKskw5bMbekT/Y7W/Wlg==",
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.9.3.tgz",
"integrity": "sha512-Bq9VSor+kjvW3f9/MiiR4eE3XYgOl7/rS8lnSxbRbF3kS0B2r+Y9w5krBWxZgDxASVZbdYrn5wT4j/Wb0J9qow==",
"dev": true,
"dependencies": {
"graceful-fs": "^4.1.2",
"memory-fs": "^0.5.0",
"tapable": "^1.0.0"
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
},
"engines": {
"node": ">=6.9.0"
"node": ">=10.13.0"
}
},
"node_modules/envinfo": {
@ -5288,18 +5287,6 @@
"node": ">=4"
}
},
"node_modules/errno": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz",
"integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==",
"dev": true,
"dependencies": {
"prr": "~1.0.1"
},
"bin": {
"errno": "cli.js"
}
},
"node_modules/es-module-lexer": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.4.1.tgz",
@ -10567,19 +10554,6 @@
"node": ">= 4.0.0"
}
},
"node_modules/memory-fs": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz",
"integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==",
"dev": true,
"dependencies": {
"errno": "^0.1.3",
"readable-stream": "^2.0.1"
},
"engines": {
"node": ">=4.3.0 <5.0.0 || >=5.10"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
@ -11381,12 +11355,6 @@
"node": ">= 0.10"
}
},
"node_modules/prr": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
"integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=",
"dev": true
},
"node_modules/psl": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
@ -12315,9 +12283,9 @@
"dev": true
},
"node_modules/tapable": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz",
"integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
"dev": true,
"engines": {
"node": ">=6"
@ -12592,23 +12560,22 @@
}
},
"node_modules/ts-loader": {
"version": "8.0.18",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-8.0.18.tgz",
"integrity": "sha512-hRZzkydPX30XkLaQwJTDcWDoxZHK6IrEMDQpNd7tgcakFruFkeUp/aY+9hBb7BUGb+ZWKI0jiOGMo0MckwzdDQ==",
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.3.0.tgz",
"integrity": "sha512-2kLLAdAD+FCKijvGKi9sS0OzoqxLCF3CxHpok7rVgCZ5UldRzH0TkbwG9XECKjBzHsAewntC5oDaI/FwKzEUog==",
"dev": true,
"dependencies": {
"chalk": "^4.1.0",
"enhanced-resolve": "^4.0.0",
"loader-utils": "^2.0.0",
"enhanced-resolve": "^5.0.0",
"micromatch": "^4.0.0",
"semver": "^7.3.4"
},
"engines": {
"node": ">=10.0.0"
"node": ">=12.0.0"
},
"peerDependencies": {
"typescript": "*",
"webpack": "*"
"webpack": "^5.0.0"
}
},
"node_modules/ts-loader/node_modules/ansi-styles": {
@ -12773,9 +12740,9 @@
}
},
"node_modules/typescript": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz",
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
"version": "4.6.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz",
"integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
@ -13367,28 +13334,6 @@
"node": ">=0.4.0"
}
},
"node_modules/webpack/node_modules/enhanced-resolve": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.7.0.tgz",
"integrity": "sha512-6njwt/NsZFUKhM6j9U8hzVyD4E4r0x7NQzhTCbcWOJ0IQjNSAoalWmb0AE51Wn+fwan5qVESWi7t2ToBxs9vrw==",
"dev": true,
"dependencies": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/webpack/node_modules/tapable": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.0.tgz",
"integrity": "sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw==",
"dev": true,
"engines": {
"node": ">=6"
}
},
"node_modules/websocket-driver": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.4.tgz",
@ -17765,14 +17710,13 @@
"dev": true
},
"enhanced-resolve": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.5.0.tgz",
"integrity": "sha512-Nv9m36S/vxpsI+Hc4/ZGRs0n9mXqSWGGq49zxb/cJfPAQMbUtttJAlNPS4AQzaBdw/pKskw5bMbekT/Y7W/Wlg==",
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.9.3.tgz",
"integrity": "sha512-Bq9VSor+kjvW3f9/MiiR4eE3XYgOl7/rS8lnSxbRbF3kS0B2r+Y9w5krBWxZgDxASVZbdYrn5wT4j/Wb0J9qow==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"memory-fs": "^0.5.0",
"tapable": "^1.0.0"
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
}
},
"envinfo": {
@ -17781,15 +17725,6 @@
"integrity": "sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==",
"dev": true
},
"errno": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz",
"integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==",
"dev": true,
"requires": {
"prr": "~1.0.1"
}
},
"es-module-lexer": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.4.1.tgz",
@ -21810,16 +21745,6 @@
"fs-monkey": "1.0.3"
}
},
"memory-fs": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz",
"integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==",
"dev": true,
"requires": {
"errno": "^0.1.3",
"readable-stream": "^2.0.1"
}
},
"merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
@ -22422,12 +22347,6 @@
"ipaddr.js": "1.9.1"
}
},
"prr": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
"integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=",
"dev": true
},
"psl": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
@ -23157,9 +23076,9 @@
"dev": true
},
"tapable": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz",
"integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
"dev": true
},
"tar": {
@ -23348,14 +23267,13 @@
}
},
"ts-loader": {
"version": "8.0.18",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-8.0.18.tgz",
"integrity": "sha512-hRZzkydPX30XkLaQwJTDcWDoxZHK6IrEMDQpNd7tgcakFruFkeUp/aY+9hBb7BUGb+ZWKI0jiOGMo0MckwzdDQ==",
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.3.0.tgz",
"integrity": "sha512-2kLLAdAD+FCKijvGKi9sS0OzoqxLCF3CxHpok7rVgCZ5UldRzH0TkbwG9XECKjBzHsAewntC5oDaI/FwKzEUog==",
"dev": true,
"requires": {
"chalk": "^4.1.0",
"enhanced-resolve": "^4.0.0",
"loader-utils": "^2.0.0",
"enhanced-resolve": "^5.0.0",
"micromatch": "^4.0.0",
"semver": "^7.3.4"
},
@ -23476,9 +23394,9 @@
}
},
"typescript": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz",
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
"version": "4.6.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz",
"integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==",
"dev": true
},
"unicode-canonical-property-names-ecmascript": {
@ -23661,22 +23579,6 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.1.0.tgz",
"integrity": "sha512-LWCF/Wn0nfHOmJ9rzQApGnxnvgfROzGilS8936rqN/lfcYkY9MYZzdMqN+2NJ4SlTc+m5HiSa+kNfDtI64dwUA==",
"dev": true
},
"enhanced-resolve": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.7.0.tgz",
"integrity": "sha512-6njwt/NsZFUKhM6j9U8hzVyD4E4r0x7NQzhTCbcWOJ0IQjNSAoalWmb0AE51Wn+fwan5qVESWi7t2ToBxs9vrw==",
"dev": true,
"requires": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
}
},
"tapable": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.0.tgz",
"integrity": "sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw==",
"dev": true
}
}
},

View File

@ -46,8 +46,8 @@
"raw-loader": "^4.0.0",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.5",
"ts-loader": "^8.0.15",
"typescript": "^4.1.3",
"ts-loader": "^9.3.0",
"typescript": "^4.6.4",
"webpack": "^5.28.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.6.0",

View File

@ -12,6 +12,7 @@
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"exactOptionalPropertyTypes": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"sourceMap": true,