From 22b85454556f0ef4f13d84f80c29669f74b84b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Balogh?= <34451173+grabofus@users.noreply.github.com> Date: Fri, 2 Aug 2019 00:46:03 +0100 Subject: [PATCH] Add types for langmap (#37262) * Add types for langmap * Fixed export * Lint --- types/langmap/index.d.ts | 11 +++++++++++ types/langmap/langmap-tests.ts | 13 +++++++++++++ types/langmap/tsconfig.json | 25 +++++++++++++++++++++++++ types/langmap/tslint.json | 1 + types/langmap/types.d.ts | 8 ++++++++ 5 files changed, 58 insertions(+) create mode 100644 types/langmap/index.d.ts create mode 100644 types/langmap/langmap-tests.ts create mode 100644 types/langmap/tsconfig.json create mode 100644 types/langmap/tslint.json create mode 100644 types/langmap/types.d.ts diff --git a/types/langmap/index.d.ts b/types/langmap/index.d.ts new file mode 100644 index 0000000000..e89bf31f3f --- /dev/null +++ b/types/langmap/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for langmap 0.0 +// Project: https://github.com/mozilla/language-mapping-list +// Definitions by: Gábor Balogh +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.7 + +import { LanguageMappingList } from './types'; + +declare const langmap: LanguageMappingList; + +export = langmap; diff --git a/types/langmap/langmap-tests.ts b/types/langmap/langmap-tests.ts new file mode 100644 index 0000000000..76daf18956 --- /dev/null +++ b/types/langmap/langmap-tests.ts @@ -0,0 +1,13 @@ +// tslint:disable:no-duplicate-imports + +import langmap1 from 'langmap'; +import * as langmap2 from 'langmap'; + +const val1 = langmap1['en-US']; // { nativeName: string, englishName: string } +const val2 = langmap2['en-US']; // { nativeName: string, englishName: string } + +val1.englishName; +val1.nativeName; + +val2.englishName; +val2.nativeName; diff --git a/types/langmap/tsconfig.json b/types/langmap/tsconfig.json new file mode 100644 index 0000000000..3888dc0f24 --- /dev/null +++ b/types/langmap/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "esModuleInterop": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "langmap-tests.ts", + "types.d.ts" + ] +} diff --git a/types/langmap/tslint.json b/types/langmap/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/langmap/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/langmap/types.d.ts b/types/langmap/types.d.ts new file mode 100644 index 0000000000..3588199c49 --- /dev/null +++ b/types/langmap/types.d.ts @@ -0,0 +1,8 @@ +export interface Language { + englishName: string; + nativeName: string; +} + +export interface LanguageMappingList { + [language: string]: Language; +}