Typescript support?
mclean25 opened this issue · 4 comments
mclean25 commented
Perhaps I'm missing something obvious here, but I can't see anywhere in the docs where we can add the type declaration to the NextApiRequest
type to be able to do req.log
.
mclean25 commented
Did some digging into the source, and I've deduced my own type to get by for now. This definitely feels like something that should come out of box though.
interface AxiomNextApiRequest extends NextApiRequest {
log: AxiomLogger;
}
interface AxiomLogger {
info: (message: string, args?: any) => void;
debug: (message: string, args?: any) => void;
error: (message: string, args?: any) => void;
log: (message: string, args?: any) => void;
}
mclean25 commented
Oh, I found AxiomAPIRequest
. Probably a good idea to add this to the docs. I'll leave this open to remind myself to submit a PR.
bahlo commented
Closing, we changed our docs in the README.md to TypeScript 🙌