S
SolidJS•17mo 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•17mo ago
What is the type of StoreState?
D0Z
D0Z•17mo 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•17mo ago
I don't seem to be able to reproduce the issue 🤔 https://playground.solidjs.com/anonymous/6b9a5fd8-a0ec-42c0-a49c-a4c67f90c525
D0Z
D0Z•17mo ago
huh so it might come from my ts config ? what version of solid is the playground in ?
D0Z
D0Z•17mo ago
D0Z
D0Z•17mo ago
here is the declaration of setState for version 1.6.9
Otonashi
Otonashi•17mo 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
D0Z•17mo ago
oh alright removing readonly worked, thanku 😄