diff --git a/types/antlr4-autosuggest/antlr4-autosuggest-tests.ts b/types/antlr4-autosuggest/antlr4-autosuggest-tests.ts new file mode 100644 index 0000000000..bfb55cdfc1 --- /dev/null +++ b/types/antlr4-autosuggest/antlr4-autosuggest-tests.ts @@ -0,0 +1,19 @@ +import * as antlr4 from 'antlr4'; +import * as autosuggest from 'antlr4-autosuggest'; + +class Antlr4JSLexer extends antlr4.Lexer { + constructor(chars: antlr4.InputStream) { + super(); + } +} + +class Antlr4JSParser extends antlr4.Parser { + constructor(tokens: antlr4.CommonTokenStream) { + super(tokens); + } +} + +const autosuggester: autosuggest.AutoSuggester = autosuggest.autosuggester(Antlr4JSLexer, Antlr4JSParser); +const suggestions: string[] = autosuggester.autosuggest('ABC'); + +const lowercase = autosuggest.autosuggester(Antlr4JSLexer, Antlr4JSParser, 'LOWER'); diff --git a/types/antlr4-autosuggest/index.d.ts b/types/antlr4-autosuggest/index.d.ts new file mode 100644 index 0000000000..c050c25761 --- /dev/null +++ b/types/antlr4-autosuggest/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for antlr4-autosuggest 0.0 +// Project: https://github.com/oranoran/antlr4-autosuggest-js +// Definitions by: Jon Freedman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as antlr4 from 'antlr4'; + +export type CasePreference = 'LOWER' | 'UPPER' | 'BOTH'; + +export interface AutoSuggester { + autosuggest: (inputText: string) => string[]; +} + +export interface Constructor { + new (...args: any[]): T; +} + +export function autosuggester(lexerCtr: Constructor, parserCtr: Constructor, casePref?: CasePreference | null): AutoSuggester; diff --git a/types/antlr4-autosuggest/tsconfig.json b/types/antlr4-autosuggest/tsconfig.json new file mode 100644 index 0000000000..5e7898c616 --- /dev/null +++ b/types/antlr4-autosuggest/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", + "antlr4-autosuggest-tests.ts" + ] +} diff --git a/types/antlr4-autosuggest/tslint.json b/types/antlr4-autosuggest/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/antlr4-autosuggest/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }