mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
add types for lucene (#40074)
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
b09b89241b
commit
2f8b27fdb0
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
// Type definitions for lucene 2.1
|
||||
// Project: https://github.com/bripkens/lucene#readme
|
||||
// Definitions by: Ben Grynhaus <https://github.com/bengry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface TermLocation {
|
||||
column: number;
|
||||
line: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
export interface Node {
|
||||
boost: null | number;
|
||||
field: string | '<implicit>';
|
||||
fieldLocation: null;
|
||||
prefix: null | string;
|
||||
quoted: boolean;
|
||||
regex: boolean;
|
||||
similarity: null;
|
||||
term: string;
|
||||
termLocation: TermLocation;
|
||||
}
|
||||
|
||||
export type Operator = '<implicit>' | 'NOT' | 'OR' | 'AND' | 'AND NOT' | 'OR NOT';
|
||||
|
||||
export interface LeftOnlyAST {
|
||||
left: Node;
|
||||
start?: Operator;
|
||||
}
|
||||
|
||||
export interface BinaryAST {
|
||||
left: AST | Node;
|
||||
operator: Operator;
|
||||
right: AST | Node;
|
||||
}
|
||||
|
||||
export type AST = LeftOnlyAST | BinaryAST;
|
||||
|
||||
export function parse(query: string): AST;
|
||||
|
||||
export function toString(ast: AST): string;
|
||||
|
||||
export interface Parser {
|
||||
escape(str: string): string;
|
||||
unescape(str: string): string;
|
||||
}
|
||||
|
||||
export const term: Parser;
|
||||
export const phrase: Parser;
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as lucene from 'lucene';
|
||||
|
||||
const ast = lucene.parse('query'); // $ExpectType AST
|
||||
lucene.parse(1); // $ExpectError
|
||||
|
||||
lucene.toString(ast); // $ExpectType string
|
||||
|
||||
lucene.phrase.escape(''); // $ExpectType string
|
||||
lucene.phrase.escape(1); // $ExpectError
|
||||
|
||||
lucene.phrase.unescape(''); // $ExpectType string
|
||||
lucene.phrase.unescape(1); // $ExpectError
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "lucene-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user