enum-method-name
An enum method (a member of M in Enum<V, M>) named like a method of a built-in type or of a library API safe-ts knows (get, next, map, update, send), like one every object has (toString, valueOf, constructor), or toJSON, then, impl, tag. On by default, as an error, where the method is declared.
Why: an enum's values have no methods of their own. The build turns each job.describe() into Job.describe(job), following the value through what the source declares, and refuses a call it can't follow (enum-method-receiver). That works only if the name tells the enum's calls apart from everything else's: x.get() on a new Map() field, on a URL's searchParams or on what a library returns is a call the checker can't follow either, and it isn't the enum's. toString and toJSON are also called by the language itself (${x}, JSON.stringify(x)), where no rewrite reaches. Guide: Methods on an enum.
The list is fixed, never read off your program: the ECMAScript built-ins and the node, browser, ws, vue-router and zod APIs the feature packs describe, plus the names above. The message says which types have the name.
✕ Rejectedenum-method-name
ts
import { constructors, type Enum, match } from "@evobug_com/safe-ts-std/enum";
export type Setting = Enum<{ Default: {}; Custom: { value: number } }, { readonly get: () => number }>;
export const Setting = constructors<Setting>().impl({
get: (setting) => match(setting, { Default: () => 0, Custom: ({ value }) => value }),
});✅ Accepted: a name that says what it does for this enum
✓ Accepted0 diagnostics
ts
import { constructors, type Enum, match } from "@evobug_com/safe-ts-std/enum";
export type Setting = Enum<{ Default: {}; Custom: { value: number } }, { readonly valueOrDefault: () => number }>;
export const Setting = constructors<Setting>().impl({
valueOrDefault: (setting) => match(setting, { Default: () => 0, Custom: ({ value }) => value }),
});
export const limit = Setting.Custom({ value: 3 }).valueOrDefault();ts
import type { Data as __EnumData } from "@evobug_com/safe-ts-std/enum"; import { constructors, type Enum, match } from "@evobug_com/safe-ts-std/enum";
export type Setting = Enum<{ Default: {}; Custom: { value: number } }, { readonly valueOrDefault: () => number }>;
export const Setting = constructors<Setting>().impl({
valueOrDefault: (setting): number => match(setting, { Default: () => 0, Custom: ({ value }) => value }),
});
export const limit = Setting.valueOrDefault(({ tag: "Custom", value: 3 } satisfies __EnumData<Setting> as Setting));toString, valueOf, toJSON and then don't compile as methods either: the type refuses them. For an enum's text, declare a method of your own (describe) and call it where the text is used (enum-as-text).