فهرست منبع

chore: type checking in ci (#988)

* added typecheck script

* added typecheck to ci

* ts error fixes

* fixed import

* docs: added cientos next to docs to fix build

* merged lint and typecheck workflow

* added eol

* removed shit added by ai

* improved workflow dependencies

* lint fix

* made pkg.pr.new dependent on lint and typecheck

* added branch filters to workflow_run triggers in pkg.pr.new.yml and test.yml

* trying to get workflow to run

* merged workflows

* adjusted triggers for ci

* restored pkg.pr.new.yml

* trying again

* restored pkg.pr.new.yml again

---------

Co-authored-by: alvarosabu <alvaro.saburido@gmail.com>
Tino Koch 3 هفته پیش
والد
کامیت
dfeeabb148

+ 20 - 6
.github/workflows/lint.yml → .github/workflows/ci.yml

@@ -1,14 +1,24 @@
-name: Run linters
-on: [push]
+name: CI
+on:
+  push:
+    branches:
+      - main
+      - next
+
+  pull_request:
+    branches:
+      - main
+      - next
+
+  merge_group: {}
 
 env:
   PNPM_CACHE_FOLDER: .pnpm-store
   HUSKY: 0 # Bypass husky commit hook for CI
 
 jobs:
-  lint:
-    name: Lint
-    runs-on: ubuntu-24.04
+  ci:
+    runs-on: ubuntu-latest
     strategy:
       matrix:
         node-version: [20]
@@ -24,5 +34,9 @@ jobs:
           cache: pnpm
       - name: Install dependencies
         run: pnpm install
-      - name: Run Lint
+      - name: Typecheck
+        run: pnpm run typecheck
+      - name: Lint
         run: pnpm run lint
+      - name: Unit tests
+        run: pnpm run test

+ 2 - 2
.github/workflows/pkg.pr.new.yml

@@ -1,10 +1,10 @@
 name: Publish Any Commit
 on:
   push:
-    branches:
-      - '**'
     tags:
       - '!**'
+    branches:
+      - '**'
 
 env:
   PNPM_CACHE_FOLDER: .pnpm-store

+ 0 - 28
.github/workflows/test.yml

@@ -1,28 +0,0 @@
-name: Run Tests
-on: [push]
-
-env:
-  PNPM_CACHE_FOLDER: .pnpm-store
-  HUSKY: 0 # Bypass husky commit hook for CI
-
-jobs:
-  test:
-    name: Unit Test
-    runs-on: ubuntu-24.04
-    strategy:
-      matrix:
-        node-version: [20]
-    steps:
-      - name: Checkout
-        uses: actions/checkout@v4
-      - name: Setup pnpm
-        uses: pnpm/action-setup@v4
-      - name: Use Node.js ${{ matrix.node-version }}
-        uses: actions/setup-node@v4
-        with:
-          node-version: ${{ matrix.node-version }}
-          cache: pnpm
-      - name: Install dependencies
-        run: pnpm install
-      - name: Run Unit Tests
-        run: pnpm run test

+ 4 - 2
package.json

@@ -58,6 +58,7 @@
     "coverage": "vitest run --coverage",
     "lint": "eslint .",
     "lint:fix": "eslint . --fix",
+    "typecheck": "vue-tsc --noEmit",
     "docs:dev": "vitepress dev docs",
     "docs:build": "vitepress build docs",
     "docs:serve": "vitepress serve docs",
@@ -76,7 +77,7 @@
   "devDependencies": {
     "@release-it/conventional-changelog": "^10.0.0",
     "@stackblitz/sdk": "^1.11.0",
-    "@tresjs/cientos": "4.1.0",
+    "@tresjs/cientos": "https://pkg.pr.new/@tresjs/cientos@13943b0",
     "@tresjs/eslint-config": "^1.4.0",
     "@types/three": "^0.173.0",
     "@typescript-eslint/eslint-plugin": "^8.23.0",
@@ -112,6 +113,7 @@
     "vitepress": "1.6.3",
     "vitest": "3.0.5",
     "vue": "3.5.13",
-    "vue-demi": "^0.14.10"
+    "vue-demi": "^0.14.10",
+    "vue-tsc": "^2.2.0"
   }
 }

+ 15 - 11
pnpm-lock.yaml

@@ -25,8 +25,8 @@ importers:
         specifier: ^1.11.0
         version: 1.11.0
       '@tresjs/cientos':
-        specifier: 4.1.0
-        version: 4.1.0(@tresjs/core@4.3.3(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3)))(@types/three@0.173.0)(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))
+        specifier: https://pkg.pr.new/@tresjs/cientos@13943b0
+        version: https://pkg.pr.new/@tresjs/cientos@13943b0(@tresjs/core@5.0.0-next.0(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3)))(@types/three@0.173.0)(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))
       '@tresjs/eslint-config':
         specifier: ^1.4.0
         version: 1.4.0(@typescript-eslint/utils@8.24.1(eslint@9.21.0(jiti@2.4.2))(typescript@5.7.3))(@vue/compiler-sfc@3.5.13)(eslint@9.21.0(jiti@2.4.2))(typescript@5.7.3)(vitest@3.0.5)
@@ -135,6 +135,9 @@ importers:
       vue-demi:
         specifier: ^0.14.10
         version: 0.14.10(vue@3.5.13(typescript@5.7.3))
+      vue-tsc:
+        specifier: ^2.2.0
+        version: 2.2.2(typescript@5.7.3)
 
   docs:
     dependencies:
@@ -1656,8 +1659,9 @@ packages:
   '@tootallnate/quickjs-emscripten@0.23.0':
     resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==}
 
-  '@tresjs/cientos@4.1.0':
-    resolution: {integrity: sha512-vhYQ6HbcuswLngyHgHj+L6FAgtedhmbH83+xQbPgJmEGAUqu+91PQeH+Hujgk/6U444hObq1FwUZWClrrjXatQ==}
+  '@tresjs/cientos@https://pkg.pr.new/@tresjs/cientos@13943b0':
+    resolution: {tarball: https://pkg.pr.new/@tresjs/cientos@13943b0}
+    version: 4.2.0
     peerDependencies:
       '@tresjs/core': '>=4.2.1'
       three: '>=0.133'
@@ -1671,8 +1675,8 @@ packages:
       three: '>=0.133'
       vue: '>=3.3'
 
-  '@tresjs/core@4.3.3':
-    resolution: {integrity: sha512-AIFP0u5Hp/9LjifndcFEQWkucWYI72vpUAvJzeOArMdrGN/slKXf8XYP/GKm0BMbPQCu6/eg/LqghZO5tOQ81A==}
+  '@tresjs/core@5.0.0-next.0':
+    resolution: {integrity: sha512-AQom0UlFudxhlVpKaSjivF+8OpgZUdHsy/LxQ4VwUMJyGhqaVQfkb/og/5PLG45tdu8bNiklk8noQfEGL6ba9g==}
     peerDependencies:
       three: '>=0.133'
       vue: '>=3.4'
@@ -6952,10 +6956,10 @@ snapshots:
 
   '@tootallnate/quickjs-emscripten@0.23.0': {}
 
-  '@tresjs/cientos@4.1.0(@tresjs/core@4.3.3(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3)))(@types/three@0.173.0)(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))':
+  '@tresjs/cientos@https://pkg.pr.new/@tresjs/cientos@13943b0(@tresjs/core@5.0.0-next.0(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3)))(@types/three@0.173.0)(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))':
     dependencies:
-      '@tresjs/core': 4.3.3(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))
-      '@vueuse/core': 12.7.0(typescript@5.7.3)
+      '@tresjs/core': 5.0.0-next.0(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))
+      '@vueuse/core': 12.8.2(typescript@5.7.3)
       camera-controls: 2.10.0(three@0.173.0)
       stats-gl: 2.4.2(@types/three@0.173.0)(three@0.173.0)
       stats.js: 0.17.0
@@ -6986,10 +6990,10 @@ snapshots:
       - react
       - typescript
 
-  '@tresjs/core@4.3.3(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))':
+  '@tresjs/core@5.0.0-next.0(three@0.173.0)(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))':
     dependencies:
       '@alvarosabu/utils': 3.2.0
-      '@vue/devtools-api': 6.6.4
+      '@vue/devtools-api': 7.7.2
       '@vueuse/core': 12.8.2(typescript@5.7.3)
       three: 0.173.0
       vue: 3.5.13(typescript@5.7.3)

+ 1 - 2
src/composables/useLoader/index.ts

@@ -4,8 +4,7 @@ import type { Loader, LoadingManager } from 'three'
 import type { MaybeRef } from 'vue'
 import { onUnmounted, reactive, toValue, watch } from 'vue'
 
-import type { TresObject } from '../../../types'
-
+import type { TresObject } from '../../types'
 import { disposeObject3D } from '../../utils/'
 
 export interface LoaderMethods {

+ 1 - 1
src/composables/useTresReady/createReadyEventHook/index.ts

@@ -72,7 +72,7 @@ export function createReadyEventHook<T>(
       return hook.on(callback)
     }
     else {
-      triggerSingleCallback(callback, triggerParams)
+      triggerSingleCallback(callback as Callback<T>, triggerParams)
       return { off: () => {} }
     }
   }

+ 1 - 1
src/utils/createPriorityEventHook.ts

@@ -19,7 +19,7 @@ export type PriorityEventHookTrigger<T = any> = (param?: T) => void
 
 export interface PriorityEventHook<T = any> {
   on: PriorityEventHookOn<T>
-  off: EventHookOff<T>
+  off: (fn: Callback<T>) => void
   trigger: PriorityEventHookTrigger<T>
   dispose: () => void
   count: number