Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update typings to export I18NextRequest instead of extending global express Request #211

Merged
merged 2 commits into from
Apr 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import * as express from 'express';
import * as i18next from 'i18next';

declare global {
namespace Express {
interface Request {
language: string;
languages: string[];
i18n:i18next.i18n;
t:i18next.TFunction
}
}
}

declare module 'i18next-express-middleware' {
type I18next = i18next.i18n;
type IgnoreRoutesFunction = (req: express.Request, res: express.Response, options: HandleOptions, i18next: I18next) => boolean;
type App = express.Application | express.Router;

type I18NextRequest = express.Request & {
language: string;
languages: string[];
i18n:i18next.i18n;
t:i18next.TFunction;
}

interface HandleOptions {
ignoreRoutes?: string[] | IgnoreRoutesFunction;
removeLngFromUrl?: boolean;
Expand Down