adds typings for the 'memdown' package (#28832)

This commit is contained in:
Daniel Byrne
2018-09-14 09:33:08 -07:00
committed by Ryan Cavanaugh
parent 211edbdab6
commit 6eafee412d
4 changed files with 62 additions and 0 deletions

20
types/memdown/index.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
// Type definitions for memdown 3.0
// Project: https://github.com/Level/memdown
// Definitions by: Meirion Hughes <https://github.com/MeirionHughes>
// Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { AbstractLevelDOWN } from 'abstract-leveldown';
export interface MemDown<K, V> extends AbstractLevelDOWN<K, V> {}
export interface MemDownConstructor {
// tslint:disable-next-line no-unnecessary-generics
new <K = any, V = any>(): MemDown<K, V>;
// tslint:disable-next-line no-unnecessary-generics
<K = any, V = any>(): MemDown<K, V>;
}
export const MemDown: MemDownConstructor;
export default MemDown;

View File

@@ -0,0 +1,16 @@
import MemDown from 'memdown';
const test = (db: MemDown<string, string>) => {
db.open(() => {
db.put("key", "value", (err?: Error) => { });
db.get("key", (err?: Error) => { });
db.get("key", (err: Error | undefined, value: string) => { });
db.close(() => {});
});
};
// doesn't need `new` and can be called as a function
test(new MemDown<string, string>());
test(new MemDown());
test(MemDown<string, string>());
test(MemDown());

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",
"memdown-tests.ts"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}