From 5fd20f1695ba1899859d20eab920d82539d99f3a Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Fri, 14 Dec 2018 01:32:50 +0100 Subject: [PATCH] Add types for open-editor --- types/open-editor/index.d.ts | 25 +++++++++++++++ types/open-editor/open-editor-tests.ts | 43 ++++++++++++++++++++++++++ types/open-editor/tsconfig.json | 23 ++++++++++++++ types/open-editor/tslint.json | 1 + 4 files changed, 92 insertions(+) create mode 100644 types/open-editor/index.d.ts create mode 100644 types/open-editor/open-editor-tests.ts create mode 100644 types/open-editor/tsconfig.json create mode 100644 types/open-editor/tslint.json diff --git a/types/open-editor/index.d.ts b/types/open-editor/index.d.ts new file mode 100644 index 0000000000..60c81e3c26 --- /dev/null +++ b/types/open-editor/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for open-editor 1.2 +// Project: https://github.com/sindresorhus/open-editor#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { PathSpec } from 'line-column-path'; + +export = openEditor; + +declare function openEditor(files: PathSpec[], options?: openEditor.Options): void; + +declare namespace openEditor { + function make(files: PathSpec[], options?: Options): EditorRunConfig; + + interface Options { + editor?: string; + } + + interface EditorRunConfig { + bin: string; + args: string[]; + isTerminalEditor: boolean; + } +} diff --git a/types/open-editor/open-editor-tests.ts b/types/open-editor/open-editor-tests.ts new file mode 100644 index 0000000000..1ddb27e607 --- /dev/null +++ b/types/open-editor/open-editor-tests.ts @@ -0,0 +1,43 @@ +import openEditor = require('open-editor'); + +openEditor([ + 'unicorn.js:5:3', + { + file: 'readme.md', + line: 10, + column: 2, + }, +]); +openEditor( + [ + 'unicorn.js:5:3', + { + file: 'readme.md', + line: 10, + column: 2, + }, + ], + { editor: 'vi' } +); + +// $ExpectType EditorRunConfig +openEditor.make([ + 'unicorn.js:5:3', + { + file: 'readme.md', + line: 10, + column: 2, + }, +]); +// $ExpectType EditorRunConfig +openEditor.make( + [ + 'unicorn.js:5:3', + { + file: 'readme.md', + line: 10, + column: 2, + }, + ], + { editor: 'vi' } +); diff --git a/types/open-editor/tsconfig.json b/types/open-editor/tsconfig.json new file mode 100644 index 0000000000..7454846951 --- /dev/null +++ b/types/open-editor/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", + "open-editor-tests.ts" + ] +} diff --git a/types/open-editor/tslint.json b/types/open-editor/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/open-editor/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }