Skip to content

Commit

Permalink
chore: add readonly qualifications
Browse files Browse the repository at this point in the history
  • Loading branch information
CSharperMantle committed Apr 28, 2023
1 parent 4ca524b commit 2d20b46
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/common/TSize.ts → src/common/ISize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Represents a size (width and height).
*/
export type TSize = {
export interface ISize {
readonly width: number
readonly height: number
}
4 changes: 2 additions & 2 deletions src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { isNil } from "./isNil"
import { rearrange } from "./rearrange"
import { waitForEvent } from "./waitForEvent"

import type { ISize } from "./ISize"
import type { TPosition } from "./TPosition"
import type { TSize } from "./TSize"

export {
DefaultGameUpdateIntervalMilliseconds,
Expand All @@ -43,4 +43,4 @@ export {
isNil,
formatDuration,
}
export type { TSize, TPosition }
export type { ISize, TPosition }
4 changes: 2 additions & 2 deletions src/components/CommonLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import { appStore } from "../viewmodel"
import { MainAppBar } from "./mainAppBar/MainAppBar"

export interface IPageLocationElement {
name: string
path: string
readonly name: string
readonly path: string
}

export interface ICommonLayoutProps {
Expand Down
6 changes: 3 additions & 3 deletions src/components/blocksGrid/IBlockDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import type { IBlockSprite } from "../../viewmodel"

export interface IBlockDisplay extends IBlockSprite {
hasContent: boolean
hasBorder: boolean
symbolColor: string
readonly hasContent: boolean
readonly hasBorder: boolean
readonly symbolColor: string
}
6 changes: 3 additions & 3 deletions src/components/blocksGrid/blocksGridSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import { forEach } from "lodash"

import { createSlice } from "@reduxjs/toolkit"

import { IBlockSprite } from "../../viewmodel"

import type { PayloadAction } from "@reduxjs/toolkit"

import type { IBlockSprite } from "../../viewmodel"

interface IBlocksGridState {
sprites: IBlockSprite[]
readonly sprites: IBlockSprite[]
}

const blocksGridInitialState: IBlocksGridState = { sprites: [] }
Expand Down
6 changes: 3 additions & 3 deletions src/customization/color_scheme/IColorScheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/

export interface IColorSchemeRule {
atomicNumberRange: { from: number; to: number }
color: string
readonly atomicNumberRange: { readonly from: number; readonly to: number }
readonly color: string
}

export interface IColorScheme {
rules: IColorSchemeRule[]
readonly rules: IColorSchemeRule[]
}
4 changes: 2 additions & 2 deletions src/customization/map/IMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see https://www.gnu.org/licenses/ .
*/

import type { TSize } from "../../common"
import type { ISize } from "../../common"

export interface IMapCell {
readonly atomicNumber: number
Expand All @@ -27,5 +27,5 @@ export type TMapRow = IMapCell[]
export interface IMap {
readonly map: TMapRow[]
readonly totalAvailableBlocksCount: number
readonly playAreaSize: TSize
readonly playAreaSize: ISize
}
2 changes: 1 addition & 1 deletion src/model/EventArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { Block } from "./Block"

export type TBlocksChangedEventArgs = {
export interface IBlocksChangedEventArgs {
readonly blocks: Block[]
readonly disappeared: boolean
}
4 changes: 2 additions & 2 deletions src/model/TetriminoHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Block } from "./Block"
import { Direction } from "./Direction"
import { TetriminoKind } from "./TetriminoKind"

import type { TPosition, TSize } from "../common"
import type { ISize, TPosition } from "../common"

const CubicDownMask: number[][] = [
[3, 4],
Expand Down Expand Up @@ -408,7 +408,7 @@ export function getPositionByFirstBlock(

export function getInitialPositionByKind(
kind: TetriminoKind,
playAreaSize: TSize
playAreaSize: ISize
): TPosition {
let length: number
switch (kind) {
Expand Down
4 changes: 2 additions & 2 deletions src/model/generation/IGeneratorMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
import { MessageType } from "./MessageType"

export interface IGeneratorMessage<T> {
type: MessageType
content: T
readonly type: MessageType
readonly content: T
}
4 changes: 2 additions & 2 deletions src/model/generation/internal/PatternGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import { TetriminoKind } from "../../TetriminoKind"
import { sort } from "./TetriminoSorter"

import type { TPosition, TSize } from "../../../common"
import type { TPosition, ISize } from "../../../common"
import type { IMap } from "../../../customization"

function fastRandom(startInc: number, endExc: number): number {
Expand Down Expand Up @@ -233,7 +233,7 @@ class KindDirectionsPair {
* @param tetriminos The tetriminos to prime.
* @param playAreaSize Size of play area.
*/
function primeTetriminos(tetriminos: Tetrimino[], playAreaSize: TSize) {
function primeTetriminos(tetriminos: Tetrimino[], playAreaSize: ISize) {
// Move to initial position and rotate randomly
tetriminos.forEach((tetrimino) => {
const originalPos = tetrimino.position
Expand Down
8 changes: 4 additions & 4 deletions src/model/generation/internal/TetriminoSorter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import toposort from "toposort"
import { isNil, rearrange } from "../../../common"
import { Tetrimino } from "../../Tetrimino"

import type { TSize } from "../../../common"
import type { ISize } from "../../../common"

function getEdges(
tetriminos: Tetrimino[],
playAreaSize: TSize
playAreaSize: ISize
): [number, number][] {
// Create owners map
const owners: number[][] = new Array(playAreaSize.height)
Expand Down Expand Up @@ -70,7 +70,7 @@ function tryGetOccupant(
map: number[][],
row: number,
col: number,
playAreaSize: TSize
playAreaSize: ISize
): number | null {
if (
row < 0 ||
Expand All @@ -86,7 +86,7 @@ function tryGetOccupant(

export function sort(
tetriminos: Tetrimino[],
playAreaSize: TSize
playAreaSize: ISize
): Tetrimino[] {
const edges = getEdges(tetriminos, playAreaSize)
const sortedIndices = toposort(edges)
Expand Down
4 changes: 2 additions & 2 deletions src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { GameState } from "./GameState"
import { Tetrimino } from "./Tetrimino"
import { TetriminoKind } from "./TetriminoKind"

import type { TBlocksChangedEventArgs } from "./EventArgs"
import type { IBlocksChangedEventArgs } from "./EventArgs"

export {
Block,
Expand All @@ -35,4 +35,4 @@ export {
TetriminoKind,
}

export type { TBlocksChangedEventArgs }
export type { IBlocksChangedEventArgs }
4 changes: 2 additions & 2 deletions src/viewmodel/GameViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
import { appStore } from "./appStore"

import type { TPosition } from "../common"
import type { TBlocksChangedEventArgs } from "../model"
import type { IBlocksChangedEventArgs } from "../model"
import type { IBlockSprite } from "./IBlockSprite"

const Hammer: HammerStatic = isBrowser ? require("hammerjs") : null
Expand Down Expand Up @@ -198,7 +198,7 @@ export class GameViewModel {
}

private modelBlocksChangedEventHandler(
eventArgs: TBlocksChangedEventArgs
eventArgs: IBlocksChangedEventArgs
): void {
const blocks = eventArgs.blocks
if (!eventArgs.disappeared) {
Expand Down
6 changes: 3 additions & 3 deletions src/viewmodel/IBlockSprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

export interface IBlockSprite {
atomicNumber: number
column: number
row: number
readonly atomicNumber: number
readonly column: number
readonly row: number
}

0 comments on commit 2d20b46

Please sign in to comment.