From d77e701618bda91b58bb454c40e2014a3f756462 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Fri, 11 Aug 2017 19:25:13 +0200 Subject: [PATCH] [detect-newline] add typings (#18861) --- types/detect-newline/detect-newline-tests.ts | 7 +++++++ types/detect-newline/index.d.ts | 12 +++++++++++ types/detect-newline/tsconfig.json | 22 ++++++++++++++++++++ types/detect-newline/tslint.json | 1 + 4 files changed, 42 insertions(+) create mode 100644 types/detect-newline/detect-newline-tests.ts create mode 100644 types/detect-newline/index.d.ts create mode 100644 types/detect-newline/tsconfig.json create mode 100644 types/detect-newline/tslint.json diff --git a/types/detect-newline/detect-newline-tests.ts b/types/detect-newline/detect-newline-tests.ts new file mode 100644 index 0000000000..b660d01ffc --- /dev/null +++ b/types/detect-newline/detect-newline-tests.ts @@ -0,0 +1,7 @@ +import detectNewline = require('detect-newline'); + +const res1 = detectNewline('foo\nbar\nbaz\r\n'); +res1; // $ExpectType "\r\n" | "\n" | null + +const res2 = detectNewline.graceful('foo\nbar\nbaz\r\n'); +res2; // $ExpectType "\r\n" | "\n" diff --git a/types/detect-newline/index.d.ts b/types/detect-newline/index.d.ts new file mode 100644 index 0000000000..4a7aaad673 --- /dev/null +++ b/types/detect-newline/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for detect-newline 2.1 +// Project: https://github.com/sindresorhus/detect-newline#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = detectNewline; + +declare function detectNewline(str: string): '\r\n' | '\n' | null; + +declare namespace detectNewline { + function graceful(str: string): '\r\n' | '\n'; +} diff --git a/types/detect-newline/tsconfig.json b/types/detect-newline/tsconfig.json new file mode 100644 index 0000000000..bbb57f1823 --- /dev/null +++ b/types/detect-newline/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "detect-newline-tests.ts" + ] +} diff --git a/types/detect-newline/tslint.json b/types/detect-newline/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/detect-newline/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }