From 10c27461dbbe742882453a29104f4ad05d746a54 Mon Sep 17 00:00:00 2001 From: Cody Bennett Date: Mon, 27 May 2024 08:47:25 -0500 Subject: [PATCH] fix: harden vector type --- packages/fiber/src/three-types.ts | 9 ++++----- packages/fiber/tests/__snapshots__/index.test.tsx.snap | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/fiber/src/three-types.ts b/packages/fiber/src/three-types.ts index ede2fe761a..6b0a56405c 100644 --- a/packages/fiber/src/three-types.ts +++ b/packages/fiber/src/three-types.ts @@ -6,22 +6,21 @@ import type { Args, EventHandlers, InstanceProps, ConstructorRepresentation } fr import type { Overwrite, Mutable } from './core/utils' export interface MathRepresentation { - set(...args: any[]): any + set(...args: number[]): any } export interface VectorRepresentation extends MathRepresentation { setScalar(value: number): any } +export type MathTypes = MathRepresentation | THREE.Euler | THREE.Color -export type MathType = T extends THREE.Color +export type MathType = T extends THREE.Color ? Args | THREE.ColorRepresentation : T extends VectorRepresentation | THREE.Layers | THREE.Euler ? T | Parameters | number : T | Parameters export type MathProps

= { - [K in keyof P as P[K] extends MathRepresentation ? K : never]: P[K] extends MathRepresentation - ? MathType - : never + [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType : never } export type Vector2 = MathType diff --git a/packages/fiber/tests/__snapshots__/index.test.tsx.snap b/packages/fiber/tests/__snapshots__/index.test.tsx.snap index 946c1613f4..13d237b30a 100644 --- a/packages/fiber/tests/__snapshots__/index.test.tsx.snap +++ b/packages/fiber/tests/__snapshots__/index.test.tsx.snap @@ -40,6 +40,7 @@ Array [ "MathProps", "MathRepresentation", "MathType", + "MathTypes", "Matrix3", "Matrix4", "ObjectMap",