[react-native-i18n] Add type for react-native-i18n module (#24790)

* Add type for react-native-i18n

* Fix tests with correct typescript version
This commit is contained in:
Vincent Langlet
2018-04-09 18:59:36 +02:00
committed by Mohamed Hegazy
parent d4cb87d64d
commit 13a7c42013
4 changed files with 45 additions and 0 deletions

11
types/react-native-i18n/index.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
// Type definitions for react-native-i18n 2.0
// Project: https://github.com/AlexanderZaytsev/react-native-i18n
// Definitions by: Vincent Langlet <https://github.com/VincentLanglet>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import I18n = require("i18n-js");
export function getLanguages(): Promise<string[]>;
export default I18n;

View File

@@ -0,0 +1,10 @@
import I18n, { getLanguages } from 'react-native-i18n';
getLanguages().then(languages => languages[0]);
I18n.defaultLocale = 'en';
I18n.fallbacks = true;
I18n.translations = {};
I18n.locale = 'fr';
const currentLocale: string = I18n.currentLocale();

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-native-i18n-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }