TypeScript
glyph build generates emojis/emojis.d.ts, which declares the glyph/emojis module:
emojis/emojis.d.ts
declare module 'glyph/emojis' {
export type Emojis = 'happy' | 'party' | 'sad' | 'thinking';
export type EmojisRecord = Record<Emojis, {id: string; name: string; animated: boolean}>;
}
glyph setup adds this file to the include of your tsconfig.json. Glyph's methods then expect a name of type Emojis: your editor suggests existing names, and a typo becomes a compile error.
import Glyph from '@fca.gg/glyph';
import type {Emojis} from 'glyph/emojis';
function react(name: Emojis) {
return Glyph.identifier(name); // emoji names autocomplete
}
Until the file is generated, Emojis is string: the project compiles, without autocompletion.
Without a bot token, glyph build still updates emojis.d.ts (when fileIndex is on), which is enough to work on the types locally.