diff --git a/.drone.yml b/.drone.yml index 37f0429..96efd7d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -36,10 +36,10 @@ steps: depends_on: - build-game - build-pwa - - name: check + - name: type-check image: node commands: - - yarn check + - yarn type-check depends_on: - build-game - build-pwa @@ -53,7 +53,7 @@ steps: depends_on: - prettier - eslint - - check + - type-check - name: deploy (preview) image: dockette/vercel commands: @@ -65,4 +65,4 @@ steps: depends_on: - prettier - eslint - - check + - type-check diff --git a/package.json b/package.json index 2f74e74..4555ec6 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,9 @@ "dev:pwa": "yarn build:pwa -w", "start": "sirv public --no-clear", "preview": "yarn build && yarn start", - "check": "yarn check:game && yarn check:pwa", - "check:game": "svelte-check --tsconfig ./tsconfig.json", - "check:pwa": "svelte-check --tsconfig ./src/pwa/tsconfig.json", + "type-check": "yarn type-check:game && yarn type-check:pwa", + "type-check:game": "svelte-check --tsconfig ./tsconfig.json", + "type-check:pwa": "svelte-check --tsconfig ./src/pwa/tsconfig.json", "lint": "yarn lint:prettier && yarn lint:eslint", "lint:prettier": "pretty-quick --ignore-path .gitignore --check --plugin-search-dir=. .", "lint:prettier:all": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .", @@ -24,7 +24,7 @@ "fix:prettier": "pretty-quick --ignore-path .gitignore --write --plugin-search-dir=. .", "fix:prettier:all": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .", "fix:eslint": "eslint --fix --ignore-path .gitignore ./src/", - "test": "yarn lint:prettier:all && yarn lint:eslint --max-warnings=0 && yarn check" + "test": "yarn lint:prettier:all && yarn lint:eslint --max-warnings=0 && yarn type-check" }, "devDependencies": { "@rollup/plugin-node-resolve": "^13.0.5", diff --git a/src/pwa/service-worker.ts b/src/pwa/service-worker.ts index 2703c97..cfc4f6d 100644 --- a/src/pwa/service-worker.ts +++ b/src/pwa/service-worker.ts @@ -5,7 +5,7 @@ const STATIC_CACHE_NAME = CACHE_NAME + "-" + CACHE_VERSION; const INITIAL_FILES_TO_CACHE = ["/", "/index.html", "/build/bundle.js", "/build/bundle.css", "/favicon.png"]; const CACHE_DENYLIST = ["/manifest.json", "/service-worker.js", "livereload.js"]; -const globalScope = self as WorkerGlobalScope as ServiceWorkerGlobalScope; +const globalScope = self as unknown /* as WorkerGlobalScope */ as ServiceWorkerGlobalScope; globalScope.addEventListener("install", (event) => { console.debug("[ServiceWorker] Install"); @@ -41,13 +41,12 @@ globalScope.addEventListener("fetch", (event) => { const path = new URL(event.request.url).pathname; console.debug("[ServiceWorker] Fetch", event.request.url, "==", path); - function getFromFetch(cache: Cache) { - return fetch(event.request).then((response) => { - if (!CACHE_DENYLIST.includes(path)) { - cache.put(path, response.clone()); - } - return response; - }); + async function getFromFetch(cache: Cache) { + const response = await fetch(event.request); + if (!CACHE_DENYLIST.includes(path)) { + cache.put(path, response.clone()); + } + return response; } async function getFromCache() { diff --git a/tsconfig.json b/tsconfig.json index 4e10601..af7da68 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,9 +2,10 @@ "extends": "@tsconfig/svelte/tsconfig.json", "target": "es2021", "include": ["src/**/*"], - "exclude": ["src/service-worker.ts"], + "exclude": ["src/pwa/**"], "compilerOptions": { "strict": true, - "isolatedModules": false + "isolatedModules": false, + "useDefineForClassFields": true } }