mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[estimate] New types (#38904)
This commit is contained in:
parent
098cceb6d0
commit
ce338b4fd0
28
types/estimate/estimate-tests.ts
Normal file
28
types/estimate/estimate-tests.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { element, text } from 'estimate';
|
||||
|
||||
function assertType<T>(value: T): T {
|
||||
return value;
|
||||
}
|
||||
|
||||
element(document.body);
|
||||
element(document.createElement('article'));
|
||||
element(document.createElement('article'), {});
|
||||
const estimate = element(document.createElement('article'), {
|
||||
speed: 300,
|
||||
spaces: /\W+/g,
|
||||
});
|
||||
|
||||
assertType<number>(estimate.progress);
|
||||
assertType<number>(estimate.remaining);
|
||||
assertType<number>(estimate.total);
|
||||
estimate.update();
|
||||
estimate.initialize();
|
||||
|
||||
text('text');
|
||||
text('text', {});
|
||||
text('text', {
|
||||
speed: 300,
|
||||
spaces: /\W+/g,
|
||||
});
|
||||
|
||||
assertType<number>(text('text'));
|
||||
21
types/estimate/index.d.ts
vendored
Normal file
21
types/estimate/index.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Type definitions for estimate 1.0
|
||||
// Project: https://github.com/bevacqua/estimate
|
||||
// Definitions by: Luis Rodrigues <https://github.com/goblindegook>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Options {
|
||||
speed?: number;
|
||||
spaces?: RegExp;
|
||||
}
|
||||
|
||||
export interface Estimate {
|
||||
progress: number;
|
||||
remaining: number;
|
||||
total: number;
|
||||
update(): void;
|
||||
initialize(): void;
|
||||
}
|
||||
|
||||
export function element(element: HTMLElement, options?: Options): Estimate;
|
||||
|
||||
export function text(text: string, options?: Options): number;
|
||||
16
types/estimate/tsconfig.json
Normal file
16
types/estimate/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "estimate-tests.ts"]
|
||||
}
|
||||
1
types/estimate/tslint.json
Normal file
1
types/estimate/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user