funktionswerk / hapi-i18n

Translation module for hapi based on mashpie's i18n module
MIT License
39 stars 22 forks source link

TypeScript Support? #45

Open deepak-illuminz opened 1 year ago

deepak-illuminz commented 1 year ago

I tried using i18n module on hapi-typescript setup, the Hapi.Request type doesn't load the i18n module, can someone suggest a workaround?

andriy-panchiy commented 5 months ago

@deepak-illuminz try this:

  1. Create environment.d.ts file:
    
    import "@hapi/hapi";
    import i18n from "hapi-i18n";

declare module "@hapi/hapi" { interface Request { i18n: i18n; } }

export {};


2. Add this file to your tsconfig.json:

... "include": ["environment.d.ts", "node_modules/@types"], ...