From cc7375aeea8e03c760878c257e1a1180fce18272 Mon Sep 17 00:00:00 2001 From: Artur Sianiuk Date: Wed, 7 Feb 2018 19:25:55 +0300 Subject: [PATCH 1/5] added definition for autosuggest-highlight --- .../autosuggest-highlight-tests.ts | 11 +++++++++ types/autosuggest-highlight/index.d.ts | 7 ++++++ types/autosuggest-highlight/match/index.d.ts | 1 + types/autosuggest-highlight/parse/index.d.ts | 1 + types/autosuggest-highlight/tsconfig.json | 23 +++++++++++++++++++ types/autosuggest-highlight/tslint.json | 1 + 6 files changed, 44 insertions(+) create mode 100644 types/autosuggest-highlight/autosuggest-highlight-tests.ts create mode 100644 types/autosuggest-highlight/index.d.ts create mode 100644 types/autosuggest-highlight/match/index.d.ts create mode 100644 types/autosuggest-highlight/parse/index.d.ts create mode 100644 types/autosuggest-highlight/tsconfig.json create mode 100644 types/autosuggest-highlight/tslint.json diff --git a/types/autosuggest-highlight/autosuggest-highlight-tests.ts b/types/autosuggest-highlight/autosuggest-highlight-tests.ts new file mode 100644 index 0000000000..01cc135baf --- /dev/null +++ b/types/autosuggest-highlight/autosuggest-highlight-tests.ts @@ -0,0 +1,11 @@ +import match from 'autosuggest-highlight/match'; +import parse from 'autosuggest-highlight/parse'; + +function matchTest() { + let matches = match('some text', 'te'); // $ExpectType number[] | number[][] + matches = match('some sweet text', 's s'); // $ExpectType number[] | number[][] +} + +function parseTest() { + const parts = parse('Pretty cool text', [[7, 9], [12, 13]]); // $ExpectType { text: string; highlight: boolean; }[] +} diff --git a/types/autosuggest-highlight/index.d.ts b/types/autosuggest-highlight/index.d.ts new file mode 100644 index 0000000000..60f862c458 --- /dev/null +++ b/types/autosuggest-highlight/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for autosuggest-highlight 3.1 +// Project: https://github.com/moroshko/autosuggest-highlight#readme +// Definitions by: Artur Sianiuk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export { default as match } from './match'; +export { default as parse } from './parse'; diff --git a/types/autosuggest-highlight/match/index.d.ts b/types/autosuggest-highlight/match/index.d.ts new file mode 100644 index 0000000000..16060877a5 --- /dev/null +++ b/types/autosuggest-highlight/match/index.d.ts @@ -0,0 +1 @@ +export default function match(text: string, query: string): number[] | number[][]; diff --git a/types/autosuggest-highlight/parse/index.d.ts b/types/autosuggest-highlight/parse/index.d.ts new file mode 100644 index 0000000000..3544b5be7f --- /dev/null +++ b/types/autosuggest-highlight/parse/index.d.ts @@ -0,0 +1 @@ +export default function parse(text: string, matches: number[] | number[][]): { text: string; highlight: boolean; }[]; diff --git a/types/autosuggest-highlight/tsconfig.json b/types/autosuggest-highlight/tsconfig.json new file mode 100644 index 0000000000..d7f8b02cb7 --- /dev/null +++ b/types/autosuggest-highlight/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", + "autosuggest-highlight-tests.ts" + ] +} diff --git a/types/autosuggest-highlight/tslint.json b/types/autosuggest-highlight/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/autosuggest-highlight/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From d74751dfb11ae643574c1d5fd311ab45375e8cb1 Mon Sep 17 00:00:00 2001 From: Artur Sianiuk Date: Wed, 7 Feb 2018 19:41:44 +0300 Subject: [PATCH 2/5] fixed issues --- types/autosuggest-highlight/index.d.ts | 1 + types/autosuggest-highlight/tsconfig.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/autosuggest-highlight/index.d.ts b/types/autosuggest-highlight/index.d.ts index 60f862c458..1a06173632 100644 --- a/types/autosuggest-highlight/index.d.ts +++ b/types/autosuggest-highlight/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/moroshko/autosuggest-highlight#readme // Definitions by: Artur Sianiuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 export { default as match } from './match'; export { default as parse } from './parse'; diff --git a/types/autosuggest-highlight/tsconfig.json b/types/autosuggest-highlight/tsconfig.json index d7f8b02cb7..2ce549d53c 100644 --- a/types/autosuggest-highlight/tsconfig.json +++ b/types/autosuggest-highlight/tsconfig.json @@ -14,7 +14,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true }, "files": [ "index.d.ts", From 62fe0cdf8656c914223f27060b1d85d0c8b7b093 Mon Sep 17 00:00:00 2001 From: Artur Sianiuk Date: Thu, 15 Feb 2018 14:00:59 +0300 Subject: [PATCH 3/5] fixes according to code review --- types/autosuggest-highlight/autosuggest-highlight-tests.ts | 4 ++-- types/autosuggest-highlight/index.d.ts | 3 --- types/autosuggest-highlight/match/index.d.ts | 4 +++- types/autosuggest-highlight/parse/index.d.ts | 4 +++- types/autosuggest-highlight/tslint.json | 7 ++++++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/types/autosuggest-highlight/autosuggest-highlight-tests.ts b/types/autosuggest-highlight/autosuggest-highlight-tests.ts index 01cc135baf..50283a24bd 100644 --- a/types/autosuggest-highlight/autosuggest-highlight-tests.ts +++ b/types/autosuggest-highlight/autosuggest-highlight-tests.ts @@ -1,5 +1,5 @@ -import match from 'autosuggest-highlight/match'; -import parse from 'autosuggest-highlight/parse'; +import match = require('autosuggest-highlight/match'); +import parse = require('autosuggest-highlight/parse'); function matchTest() { let matches = match('some text', 'te'); // $ExpectType number[] | number[][] diff --git a/types/autosuggest-highlight/index.d.ts b/types/autosuggest-highlight/index.d.ts index 1a06173632..e05c30d608 100644 --- a/types/autosuggest-highlight/index.d.ts +++ b/types/autosuggest-highlight/index.d.ts @@ -3,6 +3,3 @@ // Definitions by: Artur Sianiuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 - -export { default as match } from './match'; -export { default as parse } from './parse'; diff --git a/types/autosuggest-highlight/match/index.d.ts b/types/autosuggest-highlight/match/index.d.ts index 16060877a5..19d18c48b3 100644 --- a/types/autosuggest-highlight/match/index.d.ts +++ b/types/autosuggest-highlight/match/index.d.ts @@ -1 +1,3 @@ -export default function match(text: string, query: string): number[] | number[][]; +declare function match(text: string, query: string): number[] | number[][]; + +export = match; diff --git a/types/autosuggest-highlight/parse/index.d.ts b/types/autosuggest-highlight/parse/index.d.ts index 3544b5be7f..ab458aebb1 100644 --- a/types/autosuggest-highlight/parse/index.d.ts +++ b/types/autosuggest-highlight/parse/index.d.ts @@ -1 +1,3 @@ -export default function parse(text: string, matches: number[] | number[][]): { text: string; highlight: boolean; }[]; +declare function parse(text: string, matches: number[] | number[][]): { text: string; highlight: boolean; }[]; + +export = parse; diff --git a/types/autosuggest-highlight/tslint.json b/types/autosuggest-highlight/tslint.json index 3db14f85ea..946997cb87 100644 --- a/types/autosuggest-highlight/tslint.json +++ b/types/autosuggest-highlight/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-useless-files": false + } +} From d3d669de1f85263a5a16d9bfd5139cb33cc69601 Mon Sep 17 00:00:00 2001 From: Artur Sianiuk Date: Thu, 15 Feb 2018 14:51:05 +0300 Subject: [PATCH 4/5] fixed test failure --- types/autosuggest-highlight/tsconfig.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/autosuggest-highlight/tsconfig.json b/types/autosuggest-highlight/tsconfig.json index 2ce549d53c..8201d360ec 100644 --- a/types/autosuggest-highlight/tsconfig.json +++ b/types/autosuggest-highlight/tsconfig.json @@ -19,6 +19,8 @@ }, "files": [ "index.d.ts", - "autosuggest-highlight-tests.ts" + "autosuggest-highlight-tests.ts", + "match/index.d.ts", + "parse/index.d.ts" ] } From 8ab60f4f010c125d960d27a0d20efa7cfacd7bb1 Mon Sep 17 00:00:00 2001 From: Artur Sianiuk Date: Thu, 15 Feb 2018 15:48:46 +0300 Subject: [PATCH 5/5] fixed test failure --- types/autosuggest-highlight/parse/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/autosuggest-highlight/parse/index.d.ts b/types/autosuggest-highlight/parse/index.d.ts index ab458aebb1..01038cd116 100644 --- a/types/autosuggest-highlight/parse/index.d.ts +++ b/types/autosuggest-highlight/parse/index.d.ts @@ -1,3 +1,3 @@ -declare function parse(text: string, matches: number[] | number[][]): { text: string; highlight: boolean; }[]; +declare function parse(text: string, matches: number[] | number[][]): Array<{ text: string; highlight: boolean; }>; export = parse;