Skip to content

Commit ad5e8eb

Browse files
refactor: fix TypeScript errors
1 parent 7404c20 commit ad5e8eb

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/components/Lose.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { createRef, type Ref, Text, useScene } from 'phaser-jsx';
1+
import { createRef, Text, useScene } from 'phaser-jsx';
2+
import type { RefObject } from 'react';
23

34
interface Props {
45
onClick: () => void;
5-
ref: (ref: Ref<Phaser.GameObjects.Text>) => void;
6+
ref: (ref: RefObject<Phaser.GameObjects.Text | null>) => void;
67
}
78

89
export function Lose(props: Props) {

src/components/Win.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { createRef, type Ref, Text, useScene } from 'phaser-jsx';
1+
import { createRef, Text, useScene } from 'phaser-jsx';
2+
import type { RefObject } from 'react';
23

34
import { Audio } from '../constants';
45

56
interface Props {
67
onClick: () => void;
7-
ref: (ref: Ref<Phaser.GameObjects.Text>) => void;
8+
ref: (ref: RefObject<Phaser.GameObjects.Text | null>) => void;
89
}
910

1011
export function Win(props: Props) {

src/scenes/Main.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Phaser from 'phaser';
2-
import { type Ref, render } from 'phaser-jsx';
2+
import { render } from 'phaser-jsx';
3+
import type { RefObject } from 'react';
34

45
import { Lose, Title, Win } from '../components';
56
import { Audio, Image, Scene } from '../constants';
@@ -177,7 +178,7 @@ export class Main extends Phaser.Scene {
177178
}
178179

179180
startGame() {
180-
let winnerTextRef: Ref<Phaser.GameObjects.Text>;
181+
let winnerTextRef: RefObject<Phaser.GameObjects.Text | null>;
181182

182183
render(
183184
<Win
@@ -187,7 +188,7 @@ export class Main extends Phaser.Scene {
187188
this,
188189
);
189190

190-
let gameOverTextRef: Ref<Phaser.GameObjects.Text>;
191+
let gameOverTextRef: RefObject<Phaser.GameObjects.Text | null>;
191192

192193
render(
193194
<Lose

0 commit comments

Comments
 (0)