mobily / ts-belt

🔧 Fast, modern, and practical utility library for FP in TypeScript.
https://mobily.github.io/ts-belt
MIT License
1.08k stars 30 forks source link

Better S.startsWith #116

Open JUSTIVE opened 2 months ago

JUSTIVE commented 2 months ago

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}`