switch to ES6 modules and fix canvas name

This commit is contained in:
Thibaud Gasser 2025-01-30 23:30:26 +01:00
parent f67243a2ee
commit d1e0cc0f0c
5 changed files with 5 additions and 5 deletions

View File

@ -52,7 +52,7 @@ function update(ctx: CanvasRenderingContext2D, time: number) {
}
function init() {
const canvas = document.getElementById("game") as HTMLCanvasElement | null;
const canvas = document.getElementById("canvas") as HTMLCanvasElement | null;
if (!canvas) throw new Error("unable to get canvas HTML element");
const ctx = canvas.getContext("2d") as CanvasRenderingContext2D | null;
if (!ctx) throw new Error("unable to get canvas 2D context");

View File

@ -17,7 +17,7 @@ function drawCurve(ctx: CanvasRenderingContext2D, curve: Point[]) {
function init() {
const canvas = document.getElementById("game") as HTMLCanvasElement | null;
const canvas = document.getElementById("canvas") as HTMLCanvasElement | null;
if (!canvas) throw new Error("unable to get canvas HTML element");
const ctx = canvas.getContext("2d") as CanvasRenderingContext2D | null;
if (!ctx) throw new Error("unable to get canvas 2D context");

View File

@ -1,4 +1,4 @@
const canvas = document.getElementById("game") as HTMLCanvasElement | null;
const canvas = document.getElementById("canvas") as HTMLCanvasElement | null;
if (!canvas) throw new Error("unable to get canvas HTML element");
const ctx = canvas.getContext("2d") as CanvasRenderingContext2D | null;
if (!ctx) throw new Error("unable to get canvas 2D context");

View File

@ -33,7 +33,7 @@ function draw(ctx: CanvasRenderingContext2D, points: Point[]) {
}
function init() {
const canvas = document.getElementById("game") as HTMLCanvasElement | null;
const canvas = document.getElementById("canvas") as HTMLCanvasElement | null;
if (!canvas) throw new Error("unable to get canvas HTML element");
const ctx = canvas.getContext("2d") as CanvasRenderingContext2D | null;

View File

@ -25,7 +25,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"module": "es6", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */