Add types for direction (#41512)

This commit is contained in:
Andrey Romanov 2020-01-11 03:38:25 +03:00 committed by Armando Aguirre
parent bd90367295
commit d3c0fd9415
4 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import direction = require('direction');
direction('anglais'); // $ExpectType Direction
direction('بسيطة'); // $ExpectType Direction
direction('?'); // $ExpectType Direction

21
types/direction/index.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
// Type definitions for direction 1.0
// Project: https://github.com/wooorm/direction#readme
// Definitions by: Andrey Romanov <https://github.com/andrew--r>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace direction {
type Direction = 'ltr' | 'rtl' | 'neutral';
}
/**
* Detect direction: left-to-right, right-to-left, or neutral.
*
* @example
* ```
* direction('anglais') // => 'ltr'
* direction('بسيطة') // => 'rtl'
* direction('?') // => 'neutral'
* ```
*/
declare function direction(value: string): direction.Direction;
export = direction;

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",
"direction-tests.ts"
]
}

View File

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