Skip to content

Commit

Permalink
Merge pull request #298 from VincentLanglet/fixTypes
Browse files Browse the repository at this point in the history
Fix types
  • Loading branch information
jamuhl committed Feb 18, 2019
2 parents 0759bc9 + 4ba6cdc commit 13b2bb8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 1 addition & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ declare namespace I18NextXhrBackend {
type LoadCallback = (error: any, result: string | false) => void;
}

declare class I18NextXhrBackend {
export default class I18NextXhrBackend {
constructor(services?: any, options?: I18NextXhrBackend.BackendOptions);
init(services?: any, options?: I18NextXhrBackend.BackendOptions): void;
readMulti(languages: string[], namespaces: string[], callback: I18NextXhrBackend.LoadCallback): void;
Expand All @@ -65,5 +65,3 @@ declare class I18NextXhrBackend {
services: any;
options: I18NextXhrBackend.BackendOptions;
}

export = I18NextXhrBackend;
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
module.exports = require('./dist/commonjs/index.js').default;
/* eslint no-var: 0 */
var main = require('./dist/commonjs/index.js').default;

module.exports = main;
module.exports.default = main;
8 changes: 4 additions & 4 deletions test/typescript/i18next-xhr-backend.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import * as XHR from "i18next-xhr-backend";
import XHR, { I18NextXhrBackend } from "i18next-xhr-backend";

const options: XHR.BackendOptions = {
const options: I18NextXhrBackend.BackendOptions = {
loadPath: "/locales/{{lng}}/{{ns}}.json",
addPath: "locales/add/{{lng}}/{{ns}}",
allowMultiLoading: false,
parse: (data: string) => data.replace(/a/g, ""),
crossDomain: false,
withCredentials: false,
ajax: (url: string, options: XHR.BackendOptions, callback: XHR.AjaxRequestCallback, data: {}) => { },
ajax: (url: string, options: I18NextXhrBackend.BackendOptions, callback: I18NextXhrBackend.AjaxRequestCallback, data: {}) => { },
queryStringParams: { v: "1.3.5" }
};

const xhr = new XHR();
xhr.init(options);
const xhr2 = new XHR(null, options);
const type: string = xhr.type;
const newOptions: XHR.BackendOptions = xhr.options;
const newOptions: I18NextXhrBackend.BackendOptions = xhr.options;
xhr.create("en", "ns", "key", "value");
xhr.create(["en", "us"], "ns", "key", "value");
xhr.read("en", "ns", (error: any, result: string | false) => { });
Expand Down

0 comments on commit 13b2bb8

Please sign in to comment.