Add types for langmap (#37262)

* Add types for langmap

* Fixed export

* Lint
This commit is contained in:
Gábor Balogh 2019-08-02 00:46:03 +01:00 committed by Jesse Trinity
parent 6e53923406
commit 22b8545455
5 changed files with 58 additions and 0 deletions

11
types/langmap/index.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
// Type definitions for langmap 0.0
// Project: https://github.com/mozilla/language-mapping-list
// Definitions by: Gábor Balogh <https://github.com/grabofus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
import { LanguageMappingList } from './types';
declare const langmap: LanguageMappingList;
export = langmap;

View File

@ -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;

View File

@ -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"
]
}

View File

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

8
types/langmap/types.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
export interface Language {
englishName: string;
nativeName: string;
}
export interface LanguageMappingList {
[language: string]: Language;
}