S
SolidJS•2y ago
D0Z

Argument of type 'string' is not assignable to parameter of type 'never'.

When using setState in a provider I get this error since the new update, is there any way to fix it ? Argument of type 'string' is not assignable to parameter of type 'never'.
8 Replies
foolswisdom
foolswisdom•2y ago
What is the type of StoreState?
D0Z
D0ZOP•2y ago
/**
* Store type
*/
type StoreState = {
readonly toolMode: ToolMode
readonly cursor: string
readonly drawColor: string
readonly drawWidth: number
}

/**
* Context type
*/
type ContextState = [
state: StoreState,
actions: {
/**
* Set Tool Mode
* @param toolMode
*/
setToolMode: (toolMode: ToolMode) => void
/**
* Set cursor
* @param cursor
*/
setCursor: (cursor: string) => void
/**
* Set Draw Color
* @param drawColor
*/
setDrawColor: (drawColor: string) => void
/**
* Set Draw Width
* @param drawWidth
*/
setDrawWidth: (drawWidth: number) => void
}
]

/**
* Initial state of the store
*/
const initialState: StoreState = {
toolMode: ToolMode.CURSOR,
cursor: 'inherit',
drawColor: '#000000',
drawWidth: 3
}

/**
* Context
*/
const UxContext = createContext<ContextState>()
/**
* Store type
*/
type StoreState = {
readonly toolMode: ToolMode
readonly cursor: string
readonly drawColor: string
readonly drawWidth: number
}

/**
* Context type
*/
type ContextState = [
state: StoreState,
actions: {
/**
* Set Tool Mode
* @param toolMode
*/
setToolMode: (toolMode: ToolMode) => void
/**
* Set cursor
* @param cursor
*/
setCursor: (cursor: string) => void
/**
* Set Draw Color
* @param drawColor
*/
setDrawColor: (drawColor: string) => void
/**
* Set Draw Width
* @param drawWidth
*/
setDrawWidth: (drawWidth: number) => void
}
]

/**
* Initial state of the store
*/
const initialState: StoreState = {
toolMode: ToolMode.CURSOR,
cursor: 'inherit',
drawColor: '#000000',
drawWidth: 3
}

/**
* Context
*/
const UxContext = createContext<ContextState>()
foolswisdom
foolswisdom•2y ago
I don't seem to be able to reproduce the issue 🤔 https://playground.solidjs.com/anonymous/6b9a5fd8-a0ec-42c0-a49c-a4c67f90c525
D0Z
D0ZOP•2y ago
huh so it might come from my ts config ? what version of solid is the playground in ?
D0Z
D0ZOP•2y ago
D0Z
D0ZOP•2y ago
here is the declaration of setState for version 1.6.9
Otonashi
Otonashi•2y ago
iirc it was changed so that readonly properties aren't settable by setStore since those are most commonly a result of using getter properties which cause a runtime error if you try to set them
D0Z
D0ZOP•2y ago
oh alright removing readonly worked, thanku 😄
Want results from more Discord servers?
Add your server