Merge pull request #31381 from BendingBender/line-column-path

Add types for line-column-path
This commit is contained in:
Nathan Shively-Sanders
2018-12-17 10:02:40 -08:00
committed by GitHub
4 changed files with 67 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for line-column-path 1.0
// Project: https://github.com/sindresorhus/line-column-path#readme
// Definitions by: BendingBender <https://github.com/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<PathDescriptor>;
export interface StringifyOptions {
file?: boolean;
column?: boolean;
}
@@ -0,0 +1,20 @@
import lineColumnPath = require('line-column-path');
const parsed = lineColumnPath.parse('unicorn.js:8:14');
// $ExpectType Required<PathDescriptor>
parsed;
// $ExpectType Required<PathDescriptor>
lineColumnPath.parse({ file: 'unicorn.js' });
// $ExpectType Required<PathDescriptor>
lineColumnPath.parse({ file: 'unicorn.js', line: 1 });
// $ExpectType Required<PathDescriptor>
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 });
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }