Loading...
Loading...
Core TypeScript conventions for type safety, inference, and clean code. Use when writing TypeScript, reviewing TypeScript code, creating interfaces/types, or when the user asks about TypeScript patterns, conventions, or best practices.
npx skill4agent add grahamcrackers/skills typescript-best-practicesstrict: truetsconfig.jsonunknownanyanysatisfiesconst config = {
endpoint: "/api/users",
timeout: 3000,
} satisfies Config;ininstanceofas// Redundant
const name: string = "Graham";
// Let it infer
const name = "Graham";export function getUser(id: string): User | undefined {
return users.get(id);
}typeinterfaceas constenumconst Status = {
Active: "active",
Inactive: "inactive",
} as const;
type Status = (typeof Status)[keyof typeof Status];| undefined?.??!TInputTOutputTUextendsfunction merge<T extends Record<string, unknown>>(a: T, b: Partial<T>): T {
return { ...a, ...b };
}PartialRequiredPickOmitRecordReadonlyReadonly<T>PickOmitcatch (e)anytry {
await fetchData();
} catch (error) {
if (error instanceof ApiError) {
handleApiError(error);
}
throw error;
}types.tsimport typeexport typeIT