🤖 Merge PR #47014 Enhance langmap types by @remcohaszing

- Types are exported in the index, as `types.d.ts` doesn’t map to an existing JavaScript file.
- `esModuleInterop` was removed from `tsconfig.json` for correctness.
- Tests were changed not to use `esModuleInterop` and to use `$ExpectType` annotations.
This commit is contained in:
Remco Haszing 2020-08-26 21:39:13 +02:00 committed by GitHub
parent 05cb7a136f
commit 2c8e8d096a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 21 deletions

View File

@ -1,11 +1,21 @@
// Type definitions for langmap 0.0
// Project: https://github.com/mozilla/language-mapping-list
// Definitions by: Gábor Balogh <https://github.com/grabofus>
// Remco Haszing <https://github.com/remcohaszing>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
import { LanguageMappingList } from './types';
declare const langmap: langmap.LanguageMappingList;
declare const langmap: LanguageMappingList;
declare namespace langmap {
interface Language {
englishName: string;
nativeName: string;
}
interface LanguageMappingList {
[language: string]: Language;
}
}
export = langmap;

View File

@ -1,13 +1,12 @@
// tslint:disable:no-duplicate-imports
import * as langmap from 'langmap';
import langmap1 from 'langmap';
import * as langmap2 from 'langmap';
// $ExpectType LanguageMappingList
langmap;
const val1 = langmap1['en-US']; // { nativeName: string, englishName: string }
const val2 = langmap2['en-US']; // { nativeName: string, englishName: string }
// $ExpectType Language
const value = langmap['en-US'];
val1.englishName;
val1.nativeName;
val2.englishName;
val2.nativeName;
// $ExpectType string
value.englishName;
// $ExpectType string
value.nativeName;

View File

@ -4,7 +4,6 @@
"lib": [
"es6"
],
"esModuleInterop": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,

View File

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