ts-belt icon indicating copy to clipboard operation
ts-belt copied to clipboard

Better S.startsWith

Open JUSTIVE opened this issue 1 year ago • 0 comments

Currently, S.startsWith returns just a boolean. Which is not bad, but in typescript, we could give more information on the type by simply changing type signature with

export declare function startsWith<const SubStr extends string>(substr: SubStr): (str: string) => str is `${SubStr}${string}`
// for non-curried version
export declare function startsWith<const SubStr extends string>(str: string, substr: SubStr): str is `${SubStr}${string}`

JUSTIVE avatar Jun 22 '24 11:06 JUSTIVE