Skip to content

Commit

Permalink
Refactor: remove non-null assertion operators (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Oct 3, 2022
1 parent 2eea809 commit 1331c25
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 43 deletions.
7 changes: 3 additions & 4 deletions src/types/logiqx/dat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import Parent from './parent.js';
*/
export default class DAT {
@Type(() => Header)
private readonly header!: Header;
private readonly header: Header;

@Type(() => Game)
private readonly game!: Game | Game[];
private readonly game: Game | Game[];

private gameNamesToParents!: Map<string, Parent>;
private readonly gameNamesToParents: Map<string, Parent> = new Map();

constructor(header: Header, games: Game[]) {
this.header = header;
Expand All @@ -33,7 +33,6 @@ export default class DAT {

private generateGameNamesToParents(): DAT {
// Find all parents
this.gameNamesToParents = new Map<string, Parent>();
this.getGames().forEach((game: Game) => {
if (game.isParent()) {
this.gameNamesToParents.set(game.getName(), new Parent(game.getName(), game));
Expand Down
16 changes: 8 additions & 8 deletions src/types/logiqx/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ export interface GameProps {

export default class Game implements GameProps {
@Expose({ name: 'name' })
readonly name!: string;
readonly name: string;

@Expose({ name: 'description' })
readonly description!: string;
readonly description: string;

@Expose({ name: 'sourcefile' })
readonly sourceFile?: string;
Expand Down Expand Up @@ -83,22 +83,22 @@ export default class Game implements GameProps {
readonly manufacturer?: string;

@Type(() => Release)
readonly release!: Release | Release[];
readonly release: Release | Release[];

@Type(() => BIOSSet)
readonly biosSet!: BIOSSet | BIOSSet[];
readonly biosSet: BIOSSet | BIOSSet[];

@Type(() => ROM)
readonly rom!: ROM | ROM[];
readonly rom: ROM | ROM[];

@Type(() => Disk)
readonly disk!: Disk | Disk[];
readonly disk: Disk | Disk[];

@Type(() => Sample)
readonly sample!: Sample | Sample[];
readonly sample: Sample | Sample[];

@Type(() => Archive)
readonly archive!: Archive | Archive[];
readonly archive: Archive | Archive[];

constructor(options?: GameProps) {
this.name = options?.name || '';
Expand Down
4 changes: 2 additions & 2 deletions src/types/logiqx/parent.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Game from './game.js';

export default class Parent {
name!: string;
private readonly name: string;

private readonly games!: Game[];
private readonly games: Game[];

constructor(name: string, games: Game | Game[]) {
this.name = name;
Expand Down
52 changes: 26 additions & 26 deletions src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,67 +62,67 @@ export default class Options implements OptionsProps {

readonly inputExclude: string[] = [];

readonly output!: string;
readonly output: string;

readonly header!: string;
readonly header: string;

readonly dirMirror!: boolean;
readonly dirMirror: boolean;

readonly dirDatName!: boolean;
readonly dirDatName: boolean;

readonly dirLetter!: boolean;
readonly dirLetter: boolean;

readonly single: boolean = false;

readonly zipExclude!: string;
readonly zipExclude: string;

readonly overwrite!: boolean;
readonly overwrite: boolean;

readonly preferGood!: boolean;
readonly preferGood: boolean;

readonly preferLanguage: string[] = [];

readonly preferRegion: string[] = [];

readonly preferRevisionNewer!: boolean;
readonly preferRevisionNewer: boolean;

readonly preferRevisionOlder!: boolean;
readonly preferRevisionOlder: boolean;

readonly preferRetail!: boolean;
readonly preferRetail: boolean;

readonly preferParent!: boolean;
readonly preferParent: boolean;

readonly languageFilter: string[] = [];

readonly regionFilter: string[] = [];

readonly onlyBios!: boolean;
readonly onlyBios: boolean;

readonly noBios!: boolean;
readonly noBios: boolean;

readonly noUnlicensed!: boolean;
readonly noUnlicensed: boolean;

readonly onlyRetail!: boolean;
readonly onlyRetail: boolean;

readonly noDemo!: boolean;
readonly noDemo: boolean;

readonly noBeta!: boolean;
readonly noBeta: boolean;

readonly noSample!: boolean;
readonly noSample: boolean;

readonly noPrototype!: boolean;
readonly noPrototype: boolean;

readonly noTestRoms!: boolean;
readonly noTestRoms: boolean;

readonly noAftermarket!: boolean;
readonly noAftermarket: boolean;

readonly noHomebrew!: boolean;
readonly noHomebrew: boolean;

readonly noBad!: boolean;
readonly noBad: boolean;

readonly verbose!: number;
readonly verbose: number;

readonly help!: boolean;
readonly help: boolean;

constructor(options?: OptionsProps) {
this.commands = options?.commands || [];
Expand Down
6 changes: 3 additions & 3 deletions src/types/releaseCandidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ export default class ReleaseCandidate {
.filter((language, idx, languages) => languages.indexOf(language) === idx)
.sort();

private readonly game!: Game;
private readonly game: Game;

private readonly release?: Release;

private readonly roms!: ROM[];
private readonly roms: ROM[];

private readonly files!: File[];
private readonly files: File[];

constructor(game: Game, release: Release | undefined, roms: ROM[], files: File[]) {
this.game = game;
Expand Down

0 comments on commit 1331c25

Please sign in to comment.