new typedef

This commit is contained in:
jonfreedman
2018-09-01 10:54:33 +01:00
parent b3f56ef40c
commit 8329a4d6ab
4 changed files with 61 additions and 0 deletions
@@ -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');
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for antlr4-autosuggest 0.0
// Project: https://github.com/oranoran/antlr4-autosuggest-js
// Definitions by: Jon Freedman <https://github.com/jonfreedman>
// 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<T> {
new (...args: any[]): T;
}
export function autosuggester<Lexer extends antlr4.Lexer, Parser extends antlr4.Parser>(lexerCtr: Constructor<Lexer>, parserCtr: Constructor<Parser>, casePref?: CasePreference | null): AutoSuggester;
+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",
"antlr4-autosuggest-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }