From dc37a4d04b9e13919c46ae388edb1eccca985078 Mon Sep 17 00:00:00 2001 From: Yehor <20585619+satelllte@users.noreply.github.com> Date: Wed, 8 May 2024 21:24:47 +0300 Subject: [PATCH 1/7] use @ts-expect-error instead of @ts-ignore --- example/src/demos/Lines.tsx | 8 ++--- packages/fiber/src/core/renderer.ts | 4 +-- packages/fiber/src/core/utils.ts | 4 +-- packages/fiber/src/native/polyfills.ts | 2 +- packages/fiber/src/three-types.ts | 32 ------------------- packages/fiber/tests/core/renderer.test.tsx | 8 ++--- .../test-renderer/src/createTestCanvas.ts | 4 +-- 7 files changed, 14 insertions(+), 48 deletions(-) diff --git a/example/src/demos/Lines.tsx b/example/src/demos/Lines.tsx index 0fe101a880..6eca9144ed 100644 --- a/example/src/demos/Lines.tsx +++ b/example/src/demos/Lines.tsx @@ -32,8 +32,8 @@ function useDrag(onDrag: any, onEnd: any) { setActive(true) toggle(false) event.stopPropagation() - // @ts-ignore - event.target.setPointerCapture(event.pointerId) + // @ts-expect-error + event.target?.setPointerCapture(event.pointerId) } const up = (event: ThreeEvent) => { @@ -41,8 +41,8 @@ function useDrag(onDrag: any, onEnd: any) { setActive(false) toggle(true) event.stopPropagation() - // @ts-ignore - event.target.releasePointerCapture(event.pointerId) + // @ts-expect-error + event.target?.releasePointerCapture(event.pointerId) if (onEnd) onEnd() } diff --git a/packages/fiber/src/core/renderer.ts b/packages/fiber/src/core/renderer.ts index 329036b04d..3149eae9d5 100644 --- a/packages/fiber/src/core/renderer.ts +++ b/packages/fiber/src/core/renderer.ts @@ -198,7 +198,7 @@ function createRenderer(_roots: Map, _getEventPriority?: detach(parentInstance, child, child.__r3f.attach) } else if (child.isObject3D && parentInstance.isObject3D) { parentInstance.remove(child) - // @ts-ignore + // @ts-expect-error // Remove interactivity on the initial root if (child.__r3f?.root) { removeInteractivity(findInitialRoot(child), child as unknown as THREE.Object3D) @@ -426,7 +426,7 @@ function createRenderer(_roots: Map, _getEventPriority?: hideTextInstance: handleTextInstance, unhideTextInstance: handleTextInstance, // https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874 - // @ts-ignore + // @ts-expect-error getCurrentEventPriority: () => (_getEventPriority ? _getEventPriority() : DefaultEventPriority), beforeActiveInstanceBlur: () => {}, afterActiveInstanceBlur: () => {}, diff --git a/packages/fiber/src/core/utils.ts b/packages/fiber/src/core/utils.ts index 35cc27617d..d662e6c81a 100644 --- a/packages/fiber/src/core/utils.ts +++ b/packages/fiber/src/core/utils.ts @@ -7,9 +7,7 @@ import { AttachType, catalogue, Instance, InstanceProps, LocalState } from './re import { Dpr, Renderer, RootState, Size } from './store' // < r141 shipped vendored types https://github.com/pmndrs/react-three-fiber/issues/2501 -/** @ts-ignore */ type _DeprecatedXRFrame = THREE.XRFrame -/** @ts-ignore */ export type _XRFrame = THREE.WebGLRenderTargetOptions extends { samples?: number } ? XRFrame : _DeprecatedXRFrame /** @@ -352,7 +350,7 @@ export function applyProps(instance: Instance, data: InstanceProps | DiffSet) { // create a blank slate of the instance and copy the particular parameter. let ctor = DEFAULTS.get(currentInstance.constructor) if (!ctor) { - // @ts-ignore + // @ts-expect-error ctor = new currentInstance.constructor() DEFAULTS.set(currentInstance.constructor, ctor) } diff --git a/packages/fiber/src/native/polyfills.ts b/packages/fiber/src/native/polyfills.ts index d3bade8317..b61b2d9fcb 100644 --- a/packages/fiber/src/native/polyfills.ts +++ b/packages/fiber/src/native/polyfills.ts @@ -141,7 +141,7 @@ export function polyfills() { texture.needsUpdate = true // Force non-DOM upload for EXGL texImage2D - // @ts-ignore + // @ts-expect-error texture.isDataTexture = true onLoad?.(texture) diff --git a/packages/fiber/src/three-types.ts b/packages/fiber/src/three-types.ts index 55e2533130..8f53fe3c6b 100644 --- a/packages/fiber/src/three-types.ts +++ b/packages/fiber/src/three-types.ts @@ -98,81 +98,53 @@ export type InstancedBufferGeometryProps = BufferGeometryNode< typeof THREE.InstancedBufferGeometry > export type BufferGeometryProps = BufferGeometryNode -/** @ts-ignore */ export type BoxBufferGeometryProps = BufferGeometryNode export type CircleBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.CircleBufferGeometry, - /** @ts-ignore */ typeof THREE.CircleBufferGeometry > -/** @ts-ignore */ export type ConeBufferGeometryProps = BufferGeometryNode export type CylinderBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.CylinderBufferGeometry, - /** @ts-ignore */ typeof THREE.CylinderBufferGeometry > export type DodecahedronBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.DodecahedronBufferGeometry, - /** @ts-ignore */ typeof THREE.DodecahedronBufferGeometry > export type ExtrudeBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.ExtrudeBufferGeometry, - /** @ts-ignore */ typeof THREE.ExtrudeBufferGeometry > export type IcosahedronBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.IcosahedronBufferGeometry, - /** @ts-ignore */ typeof THREE.IcosahedronBufferGeometry > -/** @ts-ignore */ export type LatheBufferGeometryProps = BufferGeometryNode export type OctahedronBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.OctahedronBufferGeometry, - /** @ts-ignore */ typeof THREE.OctahedronBufferGeometry > -/** @ts-ignore */ export type PlaneBufferGeometryProps = BufferGeometryNode export type PolyhedronBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.PolyhedronBufferGeometry, - /** @ts-ignore */ typeof THREE.PolyhedronBufferGeometry > -/** @ts-ignore */ export type RingBufferGeometryProps = BufferGeometryNode -/** @ts-ignore */ export type ShapeBufferGeometryProps = BufferGeometryNode export type SphereBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.SphereBufferGeometry, - /** @ts-ignore */ typeof THREE.SphereBufferGeometry > export type TetrahedronBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.TetrahedronBufferGeometry, - /** @ts-ignore */ typeof THREE.TetrahedronBufferGeometry > -/** @ts-ignore */ export type TorusBufferGeometryProps = BufferGeometryNode export type TorusKnotBufferGeometryProps = BufferGeometryNode< - /** @ts-ignore */ THREE.TorusKnotBufferGeometry, - /** @ts-ignore */ typeof THREE.TorusKnotBufferGeometry > -/** @ts-ignore */ export type TubeBufferGeometryProps = BufferGeometryNode export type WireframeGeometryProps = BufferGeometryNode export type TetrahedronGeometryProps = BufferGeometryNode @@ -230,9 +202,7 @@ export type DirectionalLightShadowProps = Node export type AmbientLightProps = LightNode export type LightShadowProps = Node -/** @ts-ignore */ export type AmbientLightProbeProps = LightNode -/** @ts-ignore */ export type HemisphereLightProbeProps = LightNode export type LightProbeProps = LightNode @@ -256,7 +226,6 @@ export type AxesHelperProps = Object3DNode export type VideoTextureProps = Node export type DataTextureProps = Node -/** @ts-ignore */ export type DataTexture3DProps = Node export type CompressedTextureProps = Node export type CubeTextureProps = Node @@ -274,7 +243,6 @@ export type QuaternionProps = Node export type BufferAttributeProps = Node export type Float16BufferAttributeProps = Node export type Float32BufferAttributeProps = Node -/** @ts-ignore */ export type Float64BufferAttributeProps = Node export type Int8BufferAttributeProps = Node export type Int16BufferAttributeProps = Node diff --git a/packages/fiber/tests/core/renderer.test.tsx b/packages/fiber/tests/core/renderer.test.tsx index 0ac0a83ed3..443ac9d531 100644 --- a/packages/fiber/tests/core/renderer.test.tsx +++ b/packages/fiber/tests/core/renderer.test.tsx @@ -746,9 +746,9 @@ describe('renderer', () => { expect(gl.toneMapping).toBe(THREE.ACESFilmicToneMapping) expect(texture.encoding).toBe(sRGBEncoding) - // @ts-ignore + // @ts-expect-error THREE.WebGLRenderer.prototype.outputColorSpace ??= '' - // @ts-ignore + // @ts-expect-error THREE.Texture.prototype.colorSpace ??= '' await act(async () => @@ -780,9 +780,9 @@ describe('renderer', () => { expect(gl.outputColorSpace).toBe(SRGBColorSpace) expect(texture.colorSpace).toBe(SRGBColorSpace) - // @ts-ignore + // @ts-expect-error delete THREE.WebGLRenderer.prototype.outputColorSpace - // @ts-ignore + // @ts-expect-error delete THREE.Texture.prototype.colorSpace }) diff --git a/packages/test-renderer/src/createTestCanvas.ts b/packages/test-renderer/src/createTestCanvas.ts index 1c8db1c89d..d70032af84 100644 --- a/packages/test-renderer/src/createTestCanvas.ts +++ b/packages/test-renderer/src/createTestCanvas.ts @@ -30,9 +30,9 @@ export const createCanvas = ({ beforeReturn, width = 1280, height = 800 }: Creat beforeReturn?.(canvas) class WebGLRenderingContext extends WebGL2RenderingContext {} - // @ts-ignore + // @ts-expect-error globalThis.WebGLRenderingContext ??= WebGLRenderingContext - // @ts-ignore + // @ts-expect-error globalThis.WebGL2RenderingContext ??= WebGL2RenderingContext return canvas From 2a277f39fb3118f311eeabc8f71b33cb2585e036 Mon Sep 17 00:00:00 2001 From: Yehor <20585619+satelllte@users.noreply.github.com> Date: Wed, 8 May 2024 21:27:10 +0300 Subject: [PATCH 2/7] revert ?. change for event.target calls --- example/src/demos/Lines.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/src/demos/Lines.tsx b/example/src/demos/Lines.tsx index 6eca9144ed..2ea176b747 100644 --- a/example/src/demos/Lines.tsx +++ b/example/src/demos/Lines.tsx @@ -33,7 +33,7 @@ function useDrag(onDrag: any, onEnd: any) { toggle(false) event.stopPropagation() // @ts-expect-error - event.target?.setPointerCapture(event.pointerId) + event.target.setPointerCapture(event.pointerId) } const up = (event: ThreeEvent) => { @@ -42,7 +42,7 @@ function useDrag(onDrag: any, onEnd: any) { toggle(true) event.stopPropagation() // @ts-expect-error - event.target?.releasePointerCapture(event.pointerId) + event.target.releasePointerCapture(event.pointerId) if (onEnd) onEnd() } From d115424a532c55d391c4a5eafff461cc1ffd214e Mon Sep 17 00:00:00 2001 From: Yehor <20585619+satelllte@users.noreply.github.com> Date: Wed, 8 May 2024 21:31:49 +0300 Subject: [PATCH 3/7] test: see if redundant @ts-expect-error fails in CI --- packages/fiber/src/core/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/fiber/src/core/utils.ts b/packages/fiber/src/core/utils.ts index d662e6c81a..c0fee83e56 100644 --- a/packages/fiber/src/core/utils.ts +++ b/packages/fiber/src/core/utils.ts @@ -7,6 +7,7 @@ import { AttachType, catalogue, Instance, InstanceProps, LocalState } from './re import { Dpr, Renderer, RootState, Size } from './store' // < r141 shipped vendored types https://github.com/pmndrs/react-three-fiber/issues/2501 +/** @ts-expect-error */ type _DeprecatedXRFrame = THREE.XRFrame export type _XRFrame = THREE.WebGLRenderTargetOptions extends { samples?: number } ? XRFrame : _DeprecatedXRFrame From 45433408053d72bde7545dbc2059b1589fdc6b47 Mon Sep 17 00:00:00 2001 From: Yehor <20585619+satelllte@users.noreply.github.com> Date: Wed, 8 May 2024 21:33:17 +0300 Subject: [PATCH 4/7] Revert "test: see if redundant @ts-expect-error fails in CI" This reverts commit d115424a532c55d391c4a5eafff461cc1ffd214e. --- packages/fiber/src/core/utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/fiber/src/core/utils.ts b/packages/fiber/src/core/utils.ts index c0fee83e56..d662e6c81a 100644 --- a/packages/fiber/src/core/utils.ts +++ b/packages/fiber/src/core/utils.ts @@ -7,7 +7,6 @@ import { AttachType, catalogue, Instance, InstanceProps, LocalState } from './re import { Dpr, Renderer, RootState, Size } from './store' // < r141 shipped vendored types https://github.com/pmndrs/react-three-fiber/issues/2501 -/** @ts-expect-error */ type _DeprecatedXRFrame = THREE.XRFrame export type _XRFrame = THREE.WebGLRenderTargetOptions extends { samples?: number } ? XRFrame : _DeprecatedXRFrame From 09df7720782ad518a0e492220469028da0089eda Mon Sep 17 00:00:00 2001 From: Yehor <20585619+satelllte@users.noreply.github.com> Date: Wed, 8 May 2024 21:49:53 +0300 Subject: [PATCH 5/7] Revert "revert ?. change for event.target calls" This reverts commit 2a277f39fb3118f311eeabc8f71b33cb2585e036. --- example/src/demos/Lines.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/src/demos/Lines.tsx b/example/src/demos/Lines.tsx index 2ea176b747..6eca9144ed 100644 --- a/example/src/demos/Lines.tsx +++ b/example/src/demos/Lines.tsx @@ -33,7 +33,7 @@ function useDrag(onDrag: any, onEnd: any) { toggle(false) event.stopPropagation() // @ts-expect-error - event.target.setPointerCapture(event.pointerId) + event.target?.setPointerCapture(event.pointerId) } const up = (event: ThreeEvent) => { @@ -42,7 +42,7 @@ function useDrag(onDrag: any, onEnd: any) { toggle(true) event.stopPropagation() // @ts-expect-error - event.target.releasePointerCapture(event.pointerId) + event.target?.releasePointerCapture(event.pointerId) if (onEnd) onEnd() } From a89e700ce8961c8b9eaf3ae033b827e3e37693ca Mon Sep 17 00:00:00 2001 From: Yehor <20585619+satelllte@users.noreply.github.com> Date: Wed, 8 May 2024 21:49:59 +0300 Subject: [PATCH 6/7] Revert "use @ts-expect-error instead of @ts-ignore" This reverts commit dc37a4d04b9e13919c46ae388edb1eccca985078. --- example/src/demos/Lines.tsx | 8 ++--- packages/fiber/src/core/renderer.ts | 4 +-- packages/fiber/src/core/utils.ts | 4 ++- packages/fiber/src/native/polyfills.ts | 2 +- packages/fiber/src/three-types.ts | 32 +++++++++++++++++++ packages/fiber/tests/core/renderer.test.tsx | 8 ++--- .../test-renderer/src/createTestCanvas.ts | 4 +-- 7 files changed, 48 insertions(+), 14 deletions(-) diff --git a/example/src/demos/Lines.tsx b/example/src/demos/Lines.tsx index 6eca9144ed..0fe101a880 100644 --- a/example/src/demos/Lines.tsx +++ b/example/src/demos/Lines.tsx @@ -32,8 +32,8 @@ function useDrag(onDrag: any, onEnd: any) { setActive(true) toggle(false) event.stopPropagation() - // @ts-expect-error - event.target?.setPointerCapture(event.pointerId) + // @ts-ignore + event.target.setPointerCapture(event.pointerId) } const up = (event: ThreeEvent) => { @@ -41,8 +41,8 @@ function useDrag(onDrag: any, onEnd: any) { setActive(false) toggle(true) event.stopPropagation() - // @ts-expect-error - event.target?.releasePointerCapture(event.pointerId) + // @ts-ignore + event.target.releasePointerCapture(event.pointerId) if (onEnd) onEnd() } diff --git a/packages/fiber/src/core/renderer.ts b/packages/fiber/src/core/renderer.ts index 3149eae9d5..329036b04d 100644 --- a/packages/fiber/src/core/renderer.ts +++ b/packages/fiber/src/core/renderer.ts @@ -198,7 +198,7 @@ function createRenderer(_roots: Map, _getEventPriority?: detach(parentInstance, child, child.__r3f.attach) } else if (child.isObject3D && parentInstance.isObject3D) { parentInstance.remove(child) - // @ts-expect-error + // @ts-ignore // Remove interactivity on the initial root if (child.__r3f?.root) { removeInteractivity(findInitialRoot(child), child as unknown as THREE.Object3D) @@ -426,7 +426,7 @@ function createRenderer(_roots: Map, _getEventPriority?: hideTextInstance: handleTextInstance, unhideTextInstance: handleTextInstance, // https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874 - // @ts-expect-error + // @ts-ignore getCurrentEventPriority: () => (_getEventPriority ? _getEventPriority() : DefaultEventPriority), beforeActiveInstanceBlur: () => {}, afterActiveInstanceBlur: () => {}, diff --git a/packages/fiber/src/core/utils.ts b/packages/fiber/src/core/utils.ts index d662e6c81a..35cc27617d 100644 --- a/packages/fiber/src/core/utils.ts +++ b/packages/fiber/src/core/utils.ts @@ -7,7 +7,9 @@ import { AttachType, catalogue, Instance, InstanceProps, LocalState } from './re import { Dpr, Renderer, RootState, Size } from './store' // < r141 shipped vendored types https://github.com/pmndrs/react-three-fiber/issues/2501 +/** @ts-ignore */ type _DeprecatedXRFrame = THREE.XRFrame +/** @ts-ignore */ export type _XRFrame = THREE.WebGLRenderTargetOptions extends { samples?: number } ? XRFrame : _DeprecatedXRFrame /** @@ -350,7 +352,7 @@ export function applyProps(instance: Instance, data: InstanceProps | DiffSet) { // create a blank slate of the instance and copy the particular parameter. let ctor = DEFAULTS.get(currentInstance.constructor) if (!ctor) { - // @ts-expect-error + // @ts-ignore ctor = new currentInstance.constructor() DEFAULTS.set(currentInstance.constructor, ctor) } diff --git a/packages/fiber/src/native/polyfills.ts b/packages/fiber/src/native/polyfills.ts index b61b2d9fcb..d3bade8317 100644 --- a/packages/fiber/src/native/polyfills.ts +++ b/packages/fiber/src/native/polyfills.ts @@ -141,7 +141,7 @@ export function polyfills() { texture.needsUpdate = true // Force non-DOM upload for EXGL texImage2D - // @ts-expect-error + // @ts-ignore texture.isDataTexture = true onLoad?.(texture) diff --git a/packages/fiber/src/three-types.ts b/packages/fiber/src/three-types.ts index 8f53fe3c6b..55e2533130 100644 --- a/packages/fiber/src/three-types.ts +++ b/packages/fiber/src/three-types.ts @@ -98,53 +98,81 @@ export type InstancedBufferGeometryProps = BufferGeometryNode< typeof THREE.InstancedBufferGeometry > export type BufferGeometryProps = BufferGeometryNode +/** @ts-ignore */ export type BoxBufferGeometryProps = BufferGeometryNode export type CircleBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.CircleBufferGeometry, + /** @ts-ignore */ typeof THREE.CircleBufferGeometry > +/** @ts-ignore */ export type ConeBufferGeometryProps = BufferGeometryNode export type CylinderBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.CylinderBufferGeometry, + /** @ts-ignore */ typeof THREE.CylinderBufferGeometry > export type DodecahedronBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.DodecahedronBufferGeometry, + /** @ts-ignore */ typeof THREE.DodecahedronBufferGeometry > export type ExtrudeBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.ExtrudeBufferGeometry, + /** @ts-ignore */ typeof THREE.ExtrudeBufferGeometry > export type IcosahedronBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.IcosahedronBufferGeometry, + /** @ts-ignore */ typeof THREE.IcosahedronBufferGeometry > +/** @ts-ignore */ export type LatheBufferGeometryProps = BufferGeometryNode export type OctahedronBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.OctahedronBufferGeometry, + /** @ts-ignore */ typeof THREE.OctahedronBufferGeometry > +/** @ts-ignore */ export type PlaneBufferGeometryProps = BufferGeometryNode export type PolyhedronBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.PolyhedronBufferGeometry, + /** @ts-ignore */ typeof THREE.PolyhedronBufferGeometry > +/** @ts-ignore */ export type RingBufferGeometryProps = BufferGeometryNode +/** @ts-ignore */ export type ShapeBufferGeometryProps = BufferGeometryNode export type SphereBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.SphereBufferGeometry, + /** @ts-ignore */ typeof THREE.SphereBufferGeometry > export type TetrahedronBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.TetrahedronBufferGeometry, + /** @ts-ignore */ typeof THREE.TetrahedronBufferGeometry > +/** @ts-ignore */ export type TorusBufferGeometryProps = BufferGeometryNode export type TorusKnotBufferGeometryProps = BufferGeometryNode< + /** @ts-ignore */ THREE.TorusKnotBufferGeometry, + /** @ts-ignore */ typeof THREE.TorusKnotBufferGeometry > +/** @ts-ignore */ export type TubeBufferGeometryProps = BufferGeometryNode export type WireframeGeometryProps = BufferGeometryNode export type TetrahedronGeometryProps = BufferGeometryNode @@ -202,7 +230,9 @@ export type DirectionalLightShadowProps = Node export type AmbientLightProps = LightNode export type LightShadowProps = Node +/** @ts-ignore */ export type AmbientLightProbeProps = LightNode +/** @ts-ignore */ export type HemisphereLightProbeProps = LightNode export type LightProbeProps = LightNode @@ -226,6 +256,7 @@ export type AxesHelperProps = Object3DNode export type VideoTextureProps = Node export type DataTextureProps = Node +/** @ts-ignore */ export type DataTexture3DProps = Node export type CompressedTextureProps = Node export type CubeTextureProps = Node @@ -243,6 +274,7 @@ export type QuaternionProps = Node export type BufferAttributeProps = Node export type Float16BufferAttributeProps = Node export type Float32BufferAttributeProps = Node +/** @ts-ignore */ export type Float64BufferAttributeProps = Node export type Int8BufferAttributeProps = Node export type Int16BufferAttributeProps = Node diff --git a/packages/fiber/tests/core/renderer.test.tsx b/packages/fiber/tests/core/renderer.test.tsx index 443ac9d531..0ac0a83ed3 100644 --- a/packages/fiber/tests/core/renderer.test.tsx +++ b/packages/fiber/tests/core/renderer.test.tsx @@ -746,9 +746,9 @@ describe('renderer', () => { expect(gl.toneMapping).toBe(THREE.ACESFilmicToneMapping) expect(texture.encoding).toBe(sRGBEncoding) - // @ts-expect-error + // @ts-ignore THREE.WebGLRenderer.prototype.outputColorSpace ??= '' - // @ts-expect-error + // @ts-ignore THREE.Texture.prototype.colorSpace ??= '' await act(async () => @@ -780,9 +780,9 @@ describe('renderer', () => { expect(gl.outputColorSpace).toBe(SRGBColorSpace) expect(texture.colorSpace).toBe(SRGBColorSpace) - // @ts-expect-error + // @ts-ignore delete THREE.WebGLRenderer.prototype.outputColorSpace - // @ts-expect-error + // @ts-ignore delete THREE.Texture.prototype.colorSpace }) diff --git a/packages/test-renderer/src/createTestCanvas.ts b/packages/test-renderer/src/createTestCanvas.ts index d70032af84..1c8db1c89d 100644 --- a/packages/test-renderer/src/createTestCanvas.ts +++ b/packages/test-renderer/src/createTestCanvas.ts @@ -30,9 +30,9 @@ export const createCanvas = ({ beforeReturn, width = 1280, height = 800 }: Creat beforeReturn?.(canvas) class WebGLRenderingContext extends WebGL2RenderingContext {} - // @ts-expect-error + // @ts-ignore globalThis.WebGLRenderingContext ??= WebGLRenderingContext - // @ts-expect-error + // @ts-ignore globalThis.WebGL2RenderingContext ??= WebGL2RenderingContext return canvas From 61480103dee0aab6838401287d8430a74839bff0 Mon Sep 17 00:00:00 2001 From: Yehor <20585619+satelllte@users.noreply.github.com> Date: Wed, 8 May 2024 21:51:47 +0300 Subject: [PATCH 7/7] replace to @ts-expect-error, but leave user-facing @ts-ignore pragmas --- example/src/demos/Lines.tsx | 4 ++-- packages/fiber/src/core/renderer.ts | 4 ++-- packages/fiber/src/core/utils.ts | 2 +- packages/fiber/src/native/polyfills.ts | 2 +- packages/fiber/tests/core/renderer.test.tsx | 8 ++++---- packages/test-renderer/src/createTestCanvas.ts | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/example/src/demos/Lines.tsx b/example/src/demos/Lines.tsx index 0fe101a880..2ea176b747 100644 --- a/example/src/demos/Lines.tsx +++ b/example/src/demos/Lines.tsx @@ -32,7 +32,7 @@ function useDrag(onDrag: any, onEnd: any) { setActive(true) toggle(false) event.stopPropagation() - // @ts-ignore + // @ts-expect-error event.target.setPointerCapture(event.pointerId) } @@ -41,7 +41,7 @@ function useDrag(onDrag: any, onEnd: any) { setActive(false) toggle(true) event.stopPropagation() - // @ts-ignore + // @ts-expect-error event.target.releasePointerCapture(event.pointerId) if (onEnd) onEnd() } diff --git a/packages/fiber/src/core/renderer.ts b/packages/fiber/src/core/renderer.ts index 329036b04d..3149eae9d5 100644 --- a/packages/fiber/src/core/renderer.ts +++ b/packages/fiber/src/core/renderer.ts @@ -198,7 +198,7 @@ function createRenderer(_roots: Map, _getEventPriority?: detach(parentInstance, child, child.__r3f.attach) } else if (child.isObject3D && parentInstance.isObject3D) { parentInstance.remove(child) - // @ts-ignore + // @ts-expect-error // Remove interactivity on the initial root if (child.__r3f?.root) { removeInteractivity(findInitialRoot(child), child as unknown as THREE.Object3D) @@ -426,7 +426,7 @@ function createRenderer(_roots: Map, _getEventPriority?: hideTextInstance: handleTextInstance, unhideTextInstance: handleTextInstance, // https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874 - // @ts-ignore + // @ts-expect-error getCurrentEventPriority: () => (_getEventPriority ? _getEventPriority() : DefaultEventPriority), beforeActiveInstanceBlur: () => {}, afterActiveInstanceBlur: () => {}, diff --git a/packages/fiber/src/core/utils.ts b/packages/fiber/src/core/utils.ts index 35cc27617d..45cdf58f71 100644 --- a/packages/fiber/src/core/utils.ts +++ b/packages/fiber/src/core/utils.ts @@ -352,7 +352,7 @@ export function applyProps(instance: Instance, data: InstanceProps | DiffSet) { // create a blank slate of the instance and copy the particular parameter. let ctor = DEFAULTS.get(currentInstance.constructor) if (!ctor) { - // @ts-ignore + // @ts-expect-error ctor = new currentInstance.constructor() DEFAULTS.set(currentInstance.constructor, ctor) } diff --git a/packages/fiber/src/native/polyfills.ts b/packages/fiber/src/native/polyfills.ts index d3bade8317..b61b2d9fcb 100644 --- a/packages/fiber/src/native/polyfills.ts +++ b/packages/fiber/src/native/polyfills.ts @@ -141,7 +141,7 @@ export function polyfills() { texture.needsUpdate = true // Force non-DOM upload for EXGL texImage2D - // @ts-ignore + // @ts-expect-error texture.isDataTexture = true onLoad?.(texture) diff --git a/packages/fiber/tests/core/renderer.test.tsx b/packages/fiber/tests/core/renderer.test.tsx index 0ac0a83ed3..443ac9d531 100644 --- a/packages/fiber/tests/core/renderer.test.tsx +++ b/packages/fiber/tests/core/renderer.test.tsx @@ -746,9 +746,9 @@ describe('renderer', () => { expect(gl.toneMapping).toBe(THREE.ACESFilmicToneMapping) expect(texture.encoding).toBe(sRGBEncoding) - // @ts-ignore + // @ts-expect-error THREE.WebGLRenderer.prototype.outputColorSpace ??= '' - // @ts-ignore + // @ts-expect-error THREE.Texture.prototype.colorSpace ??= '' await act(async () => @@ -780,9 +780,9 @@ describe('renderer', () => { expect(gl.outputColorSpace).toBe(SRGBColorSpace) expect(texture.colorSpace).toBe(SRGBColorSpace) - // @ts-ignore + // @ts-expect-error delete THREE.WebGLRenderer.prototype.outputColorSpace - // @ts-ignore + // @ts-expect-error delete THREE.Texture.prototype.colorSpace }) diff --git a/packages/test-renderer/src/createTestCanvas.ts b/packages/test-renderer/src/createTestCanvas.ts index 1c8db1c89d..d70032af84 100644 --- a/packages/test-renderer/src/createTestCanvas.ts +++ b/packages/test-renderer/src/createTestCanvas.ts @@ -30,9 +30,9 @@ export const createCanvas = ({ beforeReturn, width = 1280, height = 800 }: Creat beforeReturn?.(canvas) class WebGLRenderingContext extends WebGL2RenderingContext {} - // @ts-ignore + // @ts-expect-error globalThis.WebGLRenderingContext ??= WebGLRenderingContext - // @ts-ignore + // @ts-expect-error globalThis.WebGL2RenderingContext ??= WebGL2RenderingContext return canvas