interface Opts {
onFrame: () => void;
onAudioSample: null;
emulateSound: boolean;
sampleRate: number;
}
class NES {
constructor(opts: Opts) {
this.opts = {
onFrame() { },
onAudioSample: null,
emulateSound: true,
sampleRate: 44100,
}
if (typeof opts !== "undefined") {
let key: keyof Opts
for (key in this.opts) {
if (typeof opts[key] !== "undefined") {
// got err here
this.opts[key] = opts[key];
}
}
}
}
opts: Opts
}
you can cheak the error on TS playground:here
typescript: v3.8.3
err: Type 'number'
is not assignable to type never
.
I don't understand why it is a never
type.