strictNullChecks (#4666)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
This commit is contained in:
syuilo 2019-04-13 01:43:22 +09:00 committed by GitHub
parent 4ee40c3345
commit 987168b863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
214 changed files with 939 additions and 785 deletions

View file

@ -37,7 +37,7 @@ export type Undo = {
/**
*
*/
turn: Color;
turn: Color | null;
};
/**
@ -47,12 +47,12 @@ export default class Reversi {
public map: MapPixel[];
public mapWidth: number;
public mapHeight: number;
public board: Color[];
public turn: Color = BLACK;
public board: (Color | null | undefined)[];
public turn: Color | null = BLACK;
public opts: Options;
public prevPos = -1;
public prevColor: Color = null;
public prevColor: Color | null = null;
private logs: Undo[] = [];
@ -145,12 +145,12 @@ export default class Reversi {
// ターン計算
this.turn =
this.canPutSomewhere(!this.prevColor) ? !this.prevColor :
this.canPutSomewhere(this.prevColor) ? this.prevColor :
this.canPutSomewhere(this.prevColor!) ? this.prevColor :
null;
}
public undo() {
const undo = this.logs.pop();
const undo = this.logs.pop()!;
this.prevColor = undo.color;
this.prevPos = undo.pos;
this.board[undo.pos] = null;
@ -254,10 +254,10 @@ export default class Reversi {
/**
* (null = )
*/
public get winner(): Color {
public get winner(): Color | null {
return this.isEnded ?
this.blackCount == this.whiteCount ? null :
this.opts.isLlotheo === this.blackCount > this.whiteCount ? WHITE : BLACK :
undefined;
undefined as never;
}
}