Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable noImplicitOverride #461

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/AudioSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export class MusicAudioSystem extends AudioSystem {
return this.player;
}

stopAll(): void {
override stopAll(): void {
super.stopAll();
if (!this._player) return;
this._player.stop();
Expand All @@ -305,7 +305,7 @@ export class MusicAudioSystem extends AudioSystem {
/**
* @private
*/
_reset(): void {
override _reset(): void {
super._reset();
if (this._player) {
this._player.onPlay.remove(this._handlePlay, this);
Expand Down Expand Up @@ -386,7 +386,7 @@ export class SoundAudioSystem extends AudioSystem {
return ret;
}

stopAll(): void {
override stopAll(): void {
super.stopAll();
const players = this.players.concat();
for (let i = 0; i < players.length; ++i) {
Expand All @@ -397,7 +397,7 @@ export class SoundAudioSystem extends AudioSystem {
/**
* @private
*/
_reset(): void {
override _reset(): void {
super._reset();
for (let i = 0; i < this.players.length; ++i) {
const player = this.players[i];
Expand Down
1 change: 0 additions & 1 deletion src/BitmapFont.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class BitmapFont extends Font {
defaultGlyphHeight: number;
map: { [key: string]: GlyphArea };
missingGlyph: GlyphArea | undefined;
size: number;

/**
* 各種パラメータを指定して `BitmapFont` のインスタンスを生成する。
Expand Down
2 changes: 1 addition & 1 deletion src/Camera2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class Camera2D extends Object2D implements Camera {
/**
* @private
*/
_updateMatrix(): void {
override _updateMatrix(): void {
if (!this._matrix) return;
// カメラの angle, x, y はエンティティと逆方向に作用することに注意。
if (this.angle || this.scaleX !== 1 || this.scaleY !== 1 || this.anchorX !== 0 || this.anchorY !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/DynamicFont.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class DynamicFont extends Font {
*
* このプロパティは参照のためにのみ公開されている。ゲーム開発者はこの値を変更すべきではない。
*/
size: number;
override size: number;

/**
* ヒント。
Expand Down
6 changes: 3 additions & 3 deletions src/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class PointEventBase<T extends PointTarget> implements Event {
* ポインティング操作の開始を表すイベントの基底クラス。
*/
export class PointDownEventBase<T extends PointTarget> extends PointEventBase<T> {
type: "point-down" = "point-down";
override type: "point-down" = "point-down";
}

/**
Expand All @@ -126,7 +126,7 @@ export class PointDownEventBase<T extends PointTarget> extends PointEventBase<T>
* PointUpEvent#pointにはPointDownEvent#pointと同じ値が格納される。
*/
export class PointUpEventBase<T extends PointTarget> extends PointEventBase<T> {
type: "point-up" = "point-up";
override type: "point-up" = "point-up";
startDelta: CommonOffset;
prevDelta: CommonOffset;

Expand Down Expand Up @@ -159,7 +159,7 @@ export class PointUpEventBase<T extends PointTarget> extends PointEventBase<T> {
* カメラの移動等視覚的にポイントが変化している場合にも発生する。
*/
export class PointMoveEventBase<T extends PointTarget> extends PointEventBase<T> {
type: "point-move" = "point-move";
override type: "point-move" = "point-move";
startDelta: CommonOffset;
prevDelta: CommonOffset;

Expand Down
4 changes: 2 additions & 2 deletions src/LoadingScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class LoadingScene extends Scene {
this._targetScene = undefined!;
}

destroy(): void {
override destroy(): void {
this._clearTargetScene();
super.destroy();
}
Expand Down Expand Up @@ -128,7 +128,7 @@ export class LoadingScene extends Scene {
* `Scene#end()` と異なり、このメソッドの呼び出しはこのシーンを破棄しない。(ローディングシーンは再利用される。)
* このメソッドが呼び出される時、 `targetReady` がfireされた後でなければならない。
*/
end(): void {
override end(): void {
if (!this._targetScene || this._targetScene._loadingState === "initial") {
const state = this._targetScene ? this._targetScene._loadingState : "(no scene)";
const msg = "LoadingScene#end(): the target scene is in invalid state: " + state;
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/GameSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ describe("test Game", () => {
game.loadingScene = loadingScene;

class MockScene1 extends Scene {
_load(): void {
override _load(): void {
logs.push("SceneLoad");
super._load();
}
Expand All @@ -840,7 +840,7 @@ describe("test Game", () => {
logs = [];

class MockScene2 extends Scene {
_load(): void {
override _load(): void {
logs.push("Scene2Load");
super._load();
}
Expand Down Expand Up @@ -916,7 +916,7 @@ describe("test Game", () => {
game.loadingScene = loadingScene;

class MockScene1 extends Scene {
_load(): void {
override _load(): void {
logs.push("SceneLoad");
super._load();
}
Expand All @@ -940,7 +940,7 @@ describe("test Game", () => {
logs = [];

class MockScene2 extends Scene {
_load(): void {
override _load(): void {
logs.push("Scene2Load");
super._load();
}
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/OperationPluginManagerSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TestOperationPlugin {
}

class TestOperationPluginUnsupported extends TestOperationPlugin {
static isSupported(): boolean {
static override isSupported(): boolean {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/SpriteSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("test Sprite", () => {
let updated = false;

class MonitorSprite extends Sprite {
_handleUpdate(): void {
override _handleUpdate(): void {
super._handleUpdate();
updated = true;
}
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/helpers/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export class DelayedImageAsset extends ImageAsset implements DelayedAsset {
this._flushDelayed();
}

_load(loader: AssetLoadHandler): void {
override _load(loader: AssetLoadHandler): void {
if (this._delaying) {
// 遅延が要求されている状態で _load() が呼ばれた: loaderを自分に差し替えて _onAssetLoad, _onAssetError の通知を遅延する
this._lastGivenLoader = loader;
Expand Down Expand Up @@ -342,7 +342,7 @@ export class AudioAsset extends pci.AudioAsset {
this._failureController = new LoadFailureController(necessaryRetryCount);
}

inUse(): boolean {
override inUse(): boolean {
return this._inUse;
}

Expand Down Expand Up @@ -489,7 +489,7 @@ export class AudioPlayer extends pci.AudioPlayer {
this.canHandleStoppedValue = true;
}

canHandleStopped(): boolean {
override canHandleStopped(): boolean {
return this.canHandleStoppedValue;
}
}
Expand Down Expand Up @@ -677,8 +677,8 @@ export class GameHandlerSet implements g.GameHandlerSet {
export class Game extends g.Game {
terminatedGame: boolean;
autoTickForInternalEvents: boolean;
resourceFactory!: ResourceFactory; // NOTE: 継承元クラスで代入
handlerSet!: GameHandlerSet; // NOTE: 継承元クラスで代入
override resourceFactory!: ResourceFactory; // NOTE: 継承元クラスで代入
override handlerSet!: GameHandlerSet; // NOTE: 継承元クラスで代入

constructor(
configuration: g.GameConfiguration,
Expand All @@ -702,7 +702,7 @@ export class Game extends g.Game {
return this.tick(!!advance);
}

_pushPostTickTask(fun: () => void, owner: any): void {
override _pushPostTickTask(fun: () => void, owner: any): void {
super._pushPostTickTask(fun, owner);
if (this.autoTickForInternalEvents) {
setTimeout(() => {
Expand All @@ -711,7 +711,7 @@ export class Game extends g.Game {
}
}

_terminateGame(): void {
override _terminateGame(): void {
this.terminatedGame = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/entities/CacheableE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export abstract class CacheableE extends E {
* このエンティティ自身の描画を行う。
* このメソッドはエンジンから暗黙に呼び出され、ゲーム開発者が呼び出す必要はない。
*/
renderSelf(renderer: Renderer, camera?: Camera): boolean {
override renderSelf(renderer: Renderer, camera?: Camera): boolean {
const padding = CacheableE.PADDING;
if (this._renderedCamera !== camera) {
this.state &= ~EntityStateFlags.Cached;
Expand Down Expand Up @@ -148,7 +148,7 @@ export abstract class CacheableE extends E {
/**
* 利用している `Surface` を破棄した上で、このエンティティを破棄する。
*/
destroy(): void {
override destroy(): void {
if (this._cache && !this._cache.destroyed()) {
this._cache.destroy();
}
Expand Down
2 changes: 1 addition & 1 deletion src/entities/CameraCancellingE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class CameraCancellingE extends E {
this._canceller = new Object2D();
}

renderSelf(renderer: Renderer, camera?: Camera): boolean {
override renderSelf(renderer: Renderer, camera?: Camera): boolean {
if (!this.children) return false;

if (camera && camera instanceof Camera2D) {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/FilledRect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class FilledRect extends E {
* このエンティティ自身の描画を行う。
* このメソッドはエンジンから暗黙に呼び出され、ゲーム開発者が呼び出す必要はない。
*/
renderSelf(renderer: Renderer): boolean {
override renderSelf(renderer: Renderer): boolean {
renderer.fillRect(0, 0, this.width, this.height, this.cssColor);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/entities/FrameSprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class FrameSprite extends Sprite {
* デフォルトでは利用している `Surface` の破棄は行わない点に注意。
* @param destroySurface trueを指定した場合、このエンティティが抱える `Surface` も合わせて破棄する
*/
destroy(destroySurface?: boolean): void {
override destroy(destroySurface?: boolean): void {
this.stop();
super.destroy(destroySurface);
}
Expand All @@ -192,7 +192,7 @@ export class FrameSprite extends Sprite {
/**
* このエンティティに対する変更をエンジンに通知する。詳細は `E#modified()` のドキュメントを参照。
*/
modified(isBubbling?: boolean): void {
override modified(isBubbling?: boolean): void {
this._modifiedSelf(isBubbling);
super.modified(isBubbling);
}
Expand Down
6 changes: 3 additions & 3 deletions src/entities/Label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ export class Label extends CacheableE {
* このエンティティの描画キャッシュ無効化をエンジンに通知する。
* このメソッドを呼び出し後、描画キャッシュの再構築が行われ、各 `Renderer` に描画内容の変更が反映される。
*/
invalidate(): void {
override invalidate(): void {
this._invalidateSelf();
super.invalidate();
}

/**
* Label自身の描画を行う。
*/
renderSelfFromCache(renderer: Renderer): void {
override renderSelfFromCache(renderer: Renderer): void {
// glyphのはみ出し量に応じて、描画先のX座標を調整する。
let destOffsetX;
switch (this._realTextAlign) {
Expand Down Expand Up @@ -291,7 +291,7 @@ export class Label extends CacheableE {
* このエンティティを破棄する。
* 利用している `BitmapFont` の破棄は行わないため、 `BitmapFont` の破棄はコンテンツ製作者が明示的に行う必要がある。
*/
destroy(): void {
override destroy(): void {
super.destroy();
}

Expand Down
8 changes: 4 additions & 4 deletions src/entities/Pane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ export class Pane extends CacheableE {
* このメソッドは描画キャッシュの無効化を保証しない。描画キャッシュの無効化も必要な場合、 `invalidate()`を呼び出さなければならない。
* 詳細は `E#modified()` のドキュメントを参照。
*/
modified(isBubbling?: boolean): void {
override modified(isBubbling?: boolean): void {
if (isBubbling) this.state &= ~EntityStateFlags.Cached;
super.modified();
}

shouldFindChildrenByPoint(point: CommonOffset): boolean {
override shouldFindChildrenByPoint(point: CommonOffset): boolean {
const p = this._normalizedPadding;
if (p.left < point.x && this.width - p.right > point.x && p.top < point.y && this.height - p.bottom > point.y) {
return true;
Expand Down Expand Up @@ -202,7 +202,7 @@ export class Pane extends CacheableE {
* ただし、 `backgroundImage` に利用している `Surface` の破棄は行わない。
* @param destroySurface trueを指定した場合、 `backgroundImage` に利用している `Surface` も合わせて破棄する。
*/
destroy(destroySurface?: boolean): void {
override destroy(destroySurface?: boolean): void {
if (destroySurface && this._backgroundImageSurface && !this._backgroundImageSurface.destroyed()) {
this._backgroundImageSurface.destroy();
}
Expand Down Expand Up @@ -298,7 +298,7 @@ export class Pane extends CacheableE {
* Eを継承する他のクラスと異なり、Paneは子要素の位置を包括矩形に含まない。
* @private
*/
_calculateBoundingRect(m?: Matrix): CommonRect | undefined {
override _calculateBoundingRect(m?: Matrix): CommonRect | undefined {
let matrix = this.getMatrix();
if (m) {
matrix = m.multiplyNew(matrix);
Expand Down
4 changes: 2 additions & 2 deletions src/entities/Sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class Sprite extends E {
* このエンティティ自身の描画を行う。
* このメソッドはエンジンから暗黙に呼び出され、ゲーム開発者が呼び出す必要はない。
*/
renderSelf(renderer: Renderer, _camera?: Camera): boolean {
override renderSelf(renderer: Renderer, _camera?: Camera): boolean {
if (this.srcWidth <= 0 || this.srcHeight <= 0) {
return true;
}
Expand Down Expand Up @@ -190,7 +190,7 @@ export class Sprite extends E {
* デフォルトでは利用している `Surface` の破棄は行わない点に注意。
* @param destroySurface trueを指定した場合、このエンティティが抱える `Surface` も合わせて破棄する
*/
destroy(destroySurface?: boolean): void {
override destroy(destroySurface?: boolean): void {
if (this._surface && !this._surface.destroyed() && destroySurface) {
this._surface.destroy();
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"outDir": "lib",
"sourceMap": true,
"useUnknownInCatchVariables": false,
"noImplicitOverride": true,
"types": ["console"],
"typeRoots": [
"node_modules/@types",
Expand Down