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" }