Skip to content
Myr

fix(types): useState() has no type errors without arguments (#2548)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ryu · committed by GitHub · parent 28e597f · Browse files · 2 files+16 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−4 removed

  • other:+16 added−4 removed

2 files+16 added−4 removed

modified:deno_dist/jsx/hooks/index.ts+8 added-2 removed
136 unmodified lines
137 // eslint-disable-next-line @typescript-eslint/no-explicit-any138 ;(node as any).s?.forEach(setShadow)139}140141export const useState = <T>(initialState: T | (() => T)): [T, UpdateStateFunction<T>] => {141type UseStateType = {142 <T>(initialState: T | (() => T)): [T, UpdateStateFunction<T>]143 <T = undefined>(): [T | undefined, UpdateStateFunction<T | undefined>]144}145export const useState: UseStateType = <T>(146 initialState?: T | (() => T)147): [T, UpdateStateFunction<T>] => {148 const resolveInitialState = () =>143 typeof initialState === 'function' ? (initialState as () => T)() : initialState149 typeof initialState === 'function' ? (initialState as () => T)() : (initialState as T)150151 const buildData = buildDataStack.at(-1) as [unknown, NodeObject]152 if (!buildData) {153 return [resolveInitialState(), () => {}]
210 unmodified lines
modified:src/jsx/hooks/index.ts+8 added-2 removed
136 unmodified lines
137 // eslint-disable-next-line @typescript-eslint/no-explicit-any138 ;(node as any).s?.forEach(setShadow)139}140141export const useState = <T>(initialState: T | (() => T)): [T, UpdateStateFunction<T>] => {141type UseStateType = {142 <T>(initialState: T | (() => T)): [T, UpdateStateFunction<T>]143 <T = undefined>(): [T | undefined, UpdateStateFunction<T | undefined>]144}145export const useState: UseStateType = <T>(146 initialState?: T | (() => T)147): [T, UpdateStateFunction<T>] => {148 const resolveInitialState = () =>143 typeof initialState === 'function' ? (initialState as () => T)() : initialState149 typeof initialState === 'function' ? (initialState as () => T)() : (initialState as T)150151 const buildData = buildDataStack.at(-1) as [unknown, NodeObject]152 if (!buildData) {153 return [resolveInitialState(), () => {}]
210 unmodified lines