[detect-newline] add typings (#18861)

This commit is contained in:
Dimitri Benin
2017-08-11 19:25:13 +02:00
committed by Mohamed Hegazy
parent 9f1b796ade
commit d77e701618
4 changed files with 42 additions and 0 deletions

View File

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

12
types/detect-newline/index.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
// Type definitions for detect-newline 2.1
// Project: https://github.com/sindresorhus/detect-newline#readme
// Definitions by: BendingBender <https://github.com/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';
}

View File

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

View File

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