From bf354048f8d4eb3553a6d7758137c988363ee703 Mon Sep 17 00:00:00 2001 From: maplerichie Date: Wed, 20 Jun 2018 01:19:54 +0800 Subject: [PATCH 1/2] Added type definitions for ex-react-native-i18n --- .../ex-react-native-i18n-tests.ts | 8 +++++++ types/ex-react-native-i18n/index.d.ts | 10 ++++++++ types/ex-react-native-i18n/tsconfig.json | 23 +++++++++++++++++++ types/ex-react-native-i18n/tslint.json | 1 + 4 files changed, 42 insertions(+) create mode 100644 types/ex-react-native-i18n/ex-react-native-i18n-tests.ts create mode 100644 types/ex-react-native-i18n/index.d.ts create mode 100644 types/ex-react-native-i18n/tsconfig.json create mode 100644 types/ex-react-native-i18n/tslint.json diff --git a/types/ex-react-native-i18n/ex-react-native-i18n-tests.ts b/types/ex-react-native-i18n/ex-react-native-i18n-tests.ts new file mode 100644 index 0000000000..c83c4b60d3 --- /dev/null +++ b/types/ex-react-native-i18n/ex-react-native-i18n-tests.ts @@ -0,0 +1,8 @@ +import I18n from 'ex-react-native-i18n'; + +I18n.defaultLocale = 'en'; +I18n.fallbacks = true; +I18n.translations = {}; +I18n.locale = 'zh'; + +const deviceLocale: string = I18n.locale; diff --git a/types/ex-react-native-i18n/index.d.ts b/types/ex-react-native-i18n/index.d.ts new file mode 100644 index 0000000000..a49ca4d4ad --- /dev/null +++ b/types/ex-react-native-i18n/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for ex-react-native-i18n 0.0.4 +// Project: https://github.com/xcarpentier/ex-react-native-i18n/ +// Definitions by: LikKee Richie +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import I18n = require("i18n-js"); +//import I18n from 'ex-react-native-i18n'; + +export default I18n; diff --git a/types/ex-react-native-i18n/tsconfig.json b/types/ex-react-native-i18n/tsconfig.json new file mode 100644 index 0000000000..8e6dd691bf --- /dev/null +++ b/types/ex-react-native-i18n/tsconfig.json @@ -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", + "ex-react-native-i18n-tests.ts" + ] +} diff --git a/types/ex-react-native-i18n/tslint.json b/types/ex-react-native-i18n/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ex-react-native-i18n/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 0b948e9c551c319f1bd57e8d73670045b05bd7f5 Mon Sep 17 00:00:00 2001 From: maplerichie Date: Wed, 20 Jun 2018 02:01:21 +0800 Subject: [PATCH 2/2] Fake index.d.ts version Actual version for ex-react-native-i18n is 0.0.4 but 'npm run lint' doesn't allow patch version to pass --- types/ex-react-native-i18n/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/ex-react-native-i18n/index.d.ts b/types/ex-react-native-i18n/index.d.ts index a49ca4d4ad..0b83b06a68 100644 --- a/types/ex-react-native-i18n/index.d.ts +++ b/types/ex-react-native-i18n/index.d.ts @@ -1,10 +1,11 @@ -// Type definitions for ex-react-native-i18n 0.0.4 +// Type definitions for ex-react-native-i18n 0.0 // Project: https://github.com/xcarpentier/ex-react-native-i18n/ // Definitions by: LikKee Richie // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 +// Actual version for ex-react-native-i18n is 0.0.4 but 'npm run lint' doesn't allow patch version to pass import I18n = require("i18n-js"); -//import I18n from 'ex-react-native-i18n'; +// import I18n from 'ex-react-native-i18n'; export default I18n;