Add types for bcp-47-match (#41196)

This commit is contained in:
Chris Barth
2019-12-27 10:14:25 -05:00
committed by Andrew Branch
parent a7f75df583
commit d7a5f44d73
4 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import bcp47Match = require('bcp-47-match');
const basic = bcp47Match.basicFilter;
const extended = bcp47Match.extendedFilter;
const lookup = bcp47Match.lookup;
const tags = ['en', 'es'];
const ranges = ['en-US', 'es-US'];
const basicResult1: string[] = basic(tags, ranges);
const basicResult2: string[] = basic(tags[0], ranges[0]);
const extendedResult1: string[] = extended(tags, ranges);
const extendedResult2: string[] = extended(tags[0], ranges[0]);
const lookupResult1: string | undefined = lookup(tags, ranges);
const lookupResult2: string | undefined = lookup(tags[0], ranges[0]);

8
types/bcp-47-match/index.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
// Type definitions for bcp-47-match 1.0
// Project: https://github.com/wooorm/bcp-47-match#readme
// Definitions by: Chris Barth <https://github.com/cjbarth>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function basicFilter(tags: string | string[], ranges: string | string[]): string[];
export function extendedFilter(tags: string | string[], ranges: string | string[]): string[];
export function lookup(tags: string | string[], ranges: string | string[]): string | undefined;

View File

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

View File

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