diff --git a/types/direction/direction-tests.ts b/types/direction/direction-tests.ts new file mode 100644 index 0000000000..d0bc044acb --- /dev/null +++ b/types/direction/direction-tests.ts @@ -0,0 +1,5 @@ +import direction = require('direction'); + +direction('anglais'); // $ExpectType Direction +direction('بسيطة'); // $ExpectType Direction +direction('?'); // $ExpectType Direction diff --git a/types/direction/index.d.ts b/types/direction/index.d.ts new file mode 100644 index 0000000000..1903cad282 --- /dev/null +++ b/types/direction/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for direction 1.0 +// Project: https://github.com/wooorm/direction#readme +// Definitions by: Andrey Romanov +// 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; diff --git a/types/direction/tsconfig.json b/types/direction/tsconfig.json new file mode 100644 index 0000000000..1a99f0a001 --- /dev/null +++ b/types/direction/tsconfig.json @@ -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" + ] +} diff --git a/types/direction/tslint.json b/types/direction/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/direction/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }