Skip to content

Commit b2827a2

Browse files
committed
chore: painfully trying to fix TS
1 parent c9788b3 commit b2827a2

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChromaticAberrationEffect } from 'postprocessing'
22
import { type EffectProps, wrapEffect } from '../util'
33

4-
export type ChromaticAberrationProps = EffectProps<typeof ChromaticAberrationEffect>
4+
export type ChromaticAberrationProps = EffectProps<ChromaticAberrationEffect>
55
export const ChromaticAberration = wrapEffect(ChromaticAberrationEffect)

src/effects/LensFlare.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ export const LensFlare = ({
540540
const [projectedPosition] = useState(() => new THREE.Vector3())
541541
const [mouse2d] = useState(() => new THREE.Vector2())
542542

543-
const ref = useRef<LensFlareEffect>(null!)
543+
const ref = useRef<LensFlareEffect>(null)
544544

545545
useFrame((_, delta) => {
546546
if (!ref?.current) return

src/util.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ import type { Effect, BlendFunction } from 'postprocessing'
77
export const resolveRef = <T,>(ref: T | React.MutableRefObject<T>) =>
88
typeof ref === 'object' && ref != null && 'current' in ref ? ref.current : ref
99

10-
export type EffectConstructor = new (...args: any[]) => Effect
10+
type Constructor<T = {}> = new (...args: any[]) => T
1111

12-
export type EffectProps<T extends EffectConstructor> = ReactThreeFiber.Node<
13-
T extends Function ? T['prototype'] : InstanceType<T>,
12+
export type EffectProps<T extends Effect> = ReactThreeFiber.Node<
13+
T extends Function ? T['prototype'] : InstanceType<Constructor<T>>,
1414
T
1515
> &
16-
ConstructorParameters<T>[0] & {
16+
ConstructorParameters<Constructor<T>>[0] & {
1717
blendFunction?: BlendFunction
1818
opacity?: number
1919
}
2020

2121
let i = 0
22-
const components = new WeakMap<EffectConstructor, React.ExoticComponent<any> | string>()
22+
const components = new WeakMap<Constructor, React.ExoticComponent<any> | string>()
2323

24-
export const wrapEffect = <T extends EffectConstructor>(effect: T, defaults?: EffectProps<T>) =>
24+
export const wrapEffect = <T extends Effect>(effect: Constructor<T>, defaults?: EffectProps<T>) =>
2525
/* @__PURE__ */ React.forwardRef<T, EffectProps<T>>(function Effect(
2626
{ blendFunction = defaults?.blendFunction, opacity = defaults?.opacity, ...props },
2727
ref

0 commit comments

Comments
 (0)