diff --git a/types/line-column-path/index.d.ts b/types/line-column-path/index.d.ts new file mode 100644 index 0000000000..6a42de54b8 --- /dev/null +++ b/types/line-column-path/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for line-column-path 1.0 +// Project: https://github.com/sindresorhus/line-column-path#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +export function parse(input: PathSpec): ParsedPath; +export function stringify(input: PathDescriptor, options?: StringifyOptions): string; + +export type PathSpec = string | PathDescriptor; + +export interface PathDescriptor { + file: string; + line?: number; + column?: number; +} + +export type ParsedPath = Required; + +export interface StringifyOptions { + file?: boolean; + column?: boolean; +} diff --git a/types/line-column-path/line-column-path-tests.ts b/types/line-column-path/line-column-path-tests.ts new file mode 100644 index 0000000000..5a3861476d --- /dev/null +++ b/types/line-column-path/line-column-path-tests.ts @@ -0,0 +1,20 @@ +import lineColumnPath = require('line-column-path'); + +const parsed = lineColumnPath.parse('unicorn.js:8:14'); +// $ExpectType Required +parsed; +// $ExpectType Required +lineColumnPath.parse({ file: 'unicorn.js' }); +// $ExpectType Required +lineColumnPath.parse({ file: 'unicorn.js', line: 1 }); +// $ExpectType Required +lineColumnPath.parse({ file: 'unicorn.js', column: 1 }); + +// $ExpectType string +lineColumnPath.stringify(parsed); +// $ExpectType string +lineColumnPath.stringify({ file: 'unicorn.js' }); +// $ExpectType string +lineColumnPath.stringify({ file: 'unicorn.js', line: 1 }); +// $ExpectType string +lineColumnPath.stringify({ file: 'unicorn.js', column: 1 }); diff --git a/types/line-column-path/tsconfig.json b/types/line-column-path/tsconfig.json new file mode 100644 index 0000000000..179e1e2167 --- /dev/null +++ b/types/line-column-path/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "line-column-path-tests.ts" + ] +} diff --git a/types/line-column-path/tslint.json b/types/line-column-path/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/line-column-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }