Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
declare module 'reverso-api' {
global {
export interface ReversoResponse {
ok: boolean,
text: string,
source: string,
target: string,
translation: string[],
examples: {
id: number,
source: string,
target: string,
}[]
}

export interface ReversoErrorResponse {
ok: boolean,
message: string,
}
}

type CallbackFunction = (error: ReversoErrorResponse, response: ReversoResponse) => void;

export default class Reverso {
constructor({ insecureHTTPParser = false }?: { insecureHTTPParser: boolean });
getContext(text: string, source: string, target: string, callback?: CallbackFunction): ReversoResponse;
}
}
12 changes: 12 additions & 0 deletions @types/reverso-api-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Reverso from 'reverso-api';

const reverso = new Reverso();

export async function getContext(text: string, source: string, target: string): Promise<ReversoResponse> {
try {
const response = await reverso.getContext(text, source, target);
return response;
} catch (error) {
throw error;
}
}
23 changes: 23 additions & 0 deletions @types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"./"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"reverso-api-tests.ts"
]
}
1 change: 1 addition & 0 deletions @types/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.22.3",
"description": "Unofficial Reverso API",
"main": "index.js",
"types": "@types/index.d.ts",
"homepage": "https://github.com/s0ftik3/reverso-api#readme",
"repository": "https://github.com/s0ftik3/reverso-api",
"scripts": {
Expand Down