Skip to content

Signal passed as component prop gives error 'Type 'ReadonlySignal<number>' is not assignable to type 'number'.ts(2322)' #653

Discussion options

You must be logged in to vote

you can use this functions to unwrap the signals for consumption?

import { Signal } from '@preact/signals';
import type { JSX } from 'preact';

export function access<T extends unknown>(value: JSX.Signalish<T>): T {
	return value instanceof Signal ? value.value : value;
}

export function accessArray<T extends unknown>(list: ReadonlyArray<JSX.Signalish<T>>): Array<T> {
	return list.map((value) => access(value));
}

Replies: 2 comments 13 replies

Comment options

You must be logged in to vote
3 replies
@darioRandazzoAccedo
Comment options

@predaytor
Comment options

@rschristian
Comment options

Comment options

You must be logged in to vote
10 replies
@darioRandazzoAccedo
Comment options

@rschristian
Comment options

@darioRandazzoAccedo
Comment options

@rschristian
Comment options

@darioRandazzoAccedo
Comment options

Answer selected by JoviDeCroock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants