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

feat: replace JSX with TSX for type safety #35

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bartzalewski
Copy link

use as a starting point (?)

Copy link

vercel bot commented Feb 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mario-kart-3-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 6, 2024 11:00pm

src/Landing.tsx Outdated
}
}

const handleKeyDown = (event) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const handleKeyDown = (event) => {
const handleKeyDown = (event: KeyboardEvent) => {

src/Landing.tsx Outdated

const logo = useRef()
const startButton = useRef()
const homeRef = useRef()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const homeRef = useRef()
const homeRef = useRef<null | HTMLDivElement>(null)

src/Landing.tsx Outdated
const { gameStarted, actions } = useStore()

const logo = useRef()
const startButton = useRef()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const startButton = useRef()
const startButton = useRef<null | HTMLDivElement>(null)

src/Landing.tsx Outdated
export const Landing = () => {
const { gameStarted, actions } = useStore()

const logo = useRef()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const logo = useRef()
const logo = useRef<null | HTMLImageElement>(null)

@@ -11,7 +11,13 @@ import FakeFlame from '../../ShaderMaterials/FakeFlame/FakeFlame'
import { useStore } from '../../store'
import gsap from 'gsap'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type MarioProps = {
  currentSpeed: number;
  steeringAngleWheels: number;
  isBoosting: boolean;
  shouldLaunch: boolean;
}

isBoosting,
shouldLaunch,
...props
}) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}) {
}: MarioProps) {

@@ -21,36 +27,31 @@ export function Mario({ currentSpeed, steeringAngleWheels, isBoosting, shouldLau
const [scale, setScale] = React.useState(1)
const { actions } = useStore()
const [shouldSlow, setShouldSlow] = React.useState(false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [shouldSlow, setShouldSlow] = React.useState(false)
const [,, setShouldSlow] = React.useState(false)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tuple type '[boolean, Dispatch<SetStateAction<boolean>>]' of length '2' has no element at index '2'.ts(2493)

Shouldn't that state be removed?

isBoosting,
shouldLaunch,
...props
}) {
const { nodes, materials } = useGLTF('./models/characters/mariokarttest.glb')

const frontLeftWheel = useRef()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const frontLeftWheel = useRef()
const frontLeftWheel = useRef<Mesh>(null!)
const frontRightWheel = useRef<Mesh>(null!)
const rearWheels = useRef<Mesh>(null!)
const frontWheels = useRef<Mesh>(null!)

@@ -21,36 +27,31 @@ export function Mario({ currentSpeed, steeringAngleWheels, isBoosting, shouldLau
const [scale, setScale] = React.useState(1)
const { actions } = useStore()
const [shouldSlow, setShouldSlow] = React.useState(false)
const mario = useRef();
const mario = useRef()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const mario = useRef()
const mario = useRef<Group<Object3DEventMap>>(null!);

Copy link

@ShashankSuresh ShashankSuresh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi - Good work in adding typescript.

We have a few areas where typescript is complaining. Could you please fix them?

@ShashankSuresh
Copy link

For the file /workspaces/Mario-Kart-3.js/src/components/models/items/Banana_peel_mario_kart.tsx

please add props

type BananaProps = {
  onCollide?: number, 
  id: number, 
  position: number, 
  setNetworkBananas: SetStateAction<void>, 
  networkBananas: number
}

@bartzalewski
Copy link
Author

Hi - Good work in adding typescript.

We have a few areas where typescript is complaining. Could you please fix them?

There are lots of areas where TypeScript is complaining. I think I would need some help here.

@ShashankSuresh
Copy link

Hey. How can I help?
Can you let me know how I can contribute the same PR?

@bartzalewski
Copy link
Author

Hey. How can I help? Can you let me know how I can contribute the same PR?

I believe every file in which there's a TypeScript error, must be fixed.

@ShashankSuresh
Copy link

Hey. How can I help? Can you let me know how I can contribute the same PR?

I believe every file in which there's a TypeScript error, must be fixed.

Yeah. If you give me permission to fork this repo or raise a PR from the main repo, I can fix those type issues. First, we need to merge your PR. What do you suggest?

@bartzalewski
Copy link
Author

Hey. How can I help? Can you let me know how I can contribute the same PR?

I believe every file in which there's a TypeScript error, must be fixed.

Yeah. If you give me permission to fork this repo or raise a PR from the main repo, I can fix those type issues. First, we need to merge your PR. What do you suggest?

Hmm, I didn't see any issues caused by my code, so I think it's ok to merge.

@bartzalewski bartzalewski marked this pull request as ready for review March 7, 2024 23:06
@ShashankSuresh
Copy link

Hey. How can I help? Can you let me know how I can contribute the same PR?

I believe every file in which there's a TypeScript error, must be fixed.

Yeah. If you give me permission to fork this repo or raise a PR from the main repo, I can fix those type issues. First, we need to merge your PR. What do you suggest?

Hmm, I didn't see any issues caused by my code, so I think it's ok to merge.

I think so too. My only worry is if there is any linters during the build process. Anyway, please let me know once it's merged. I'll raise a new PR with the types fixed. 😀

@bartzalewski
Copy link
Author

Hey. How can I help? Can you let me know how I can contribute the same PR?

I believe every file in which there's a TypeScript error, must be fixed.

Yeah. If you give me permission to fork this repo or raise a PR from the main repo, I can fix those type issues. First, we need to merge your PR. What do you suggest?

Hmm, I didn't see any issues caused by my code, so I think it's ok to merge.

I think so too. My only worry is if there is any linters during the build process. Anyway, please let me know once it's merged. I'll raise a new PR with the types fixed. 😀

cc: @Lunakepio

@ShashankSuresh
Copy link

Whats the latest update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants