Skip to content

Commit 87015be

Browse files
committed
Tighten typings.
1 parent 64f90c3 commit 87015be

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

Diff for: test/demo.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const lab = script({
1919
}
2020
});
2121

22-
global['leakedButOK'] = true;
22+
(global as any)['leakedButOK'] = true;
2323

2424
const debug = require('debug')('lab-transform-typescript:test');
2525

@@ -62,7 +62,7 @@ lab.experiment('experiment', () => {
6262
lab.test('promise', () => debugp('promise test'));
6363
});
6464

65-
function debugp(message): Promise<void> {
65+
function debugp(message: string): Promise<void> {
6666
return new Promise<void>(resolve => {
6767
setImmediate(() => {
6868
debug(message);

Diff for: tsconfig.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
"experimentalDecorators": true,
99
"module": "commonjs",
1010
"moduleResolution": "node",
11+
"noImplicitAny": true,
1112
"outDir": "dist",
1213
"sourceMap": true,
1314
"target": "es5",
14-
"typeRoots": [
15-
"typings-local"
16-
],
1715
"lib": [
1816
"es5",
1917
"es2015.promise"
2018
]
2119
},
2220
"include": [
23-
"test"
21+
"test",
22+
"typings-local"
2423
]
2524
}

Diff for: typings-local/code.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ declare module 'code' {
7575
instanceof<R>(type: Newable<R>): Expectation<T>;
7676
match: (regex: RegExp) => Expectation<T>
7777
matches: (regex: RegExp) => Expectation<T>
78-
satisfy: (validator: (T) => boolean) => Expectation<T>
79-
satisfies: (validator: any) => Expectation<T>
78+
satisfy: (validator: (value: T) => boolean) => Expectation<T>
79+
satisfies: (validator: (value: T) => boolean) => Expectation<T>
8080
throw: (type?: typeString, message?: string | RegExp) => Expectation<T>
8181
throws: (type?: typeString, message?: string | RegExp) => Expectation<T>
8282
}

Diff for: typings-local/lab.d.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
declare module 'lab' {
1+
declare module Lab {
22
type ScriptOptions = {
33
schedule?: boolean;
44
cli?: CommandLineSettings;
@@ -9,7 +9,7 @@ declare module 'lab' {
99
* `globals` split into an array, `id` moved to `ids`, and silence`
1010
* and `verbose` being flattened into `progress`.
1111
*/
12-
type CommandLineSettings = {
12+
interface CommandLineSettings {
1313
/** An assertion library module path to require and make available under `Lab.assertions` */
1414
assert?: string;
1515

@@ -110,12 +110,12 @@ declare module 'lab' {
110110
verbose?: boolean;
111111
}
112112

113-
export type ReporterType = 'clover' | 'console' | 'html' | 'json' | 'junit' | 'lcov' | 'tap';
113+
type ReporterType = 'clover' | 'console' | 'html' | 'json' | 'junit' | 'lcov' | 'tap';
114114

115115
/**
116116
* Progress reporting level
117117
*/
118-
export const enum ProgressReporting {
118+
const enum ProgressReporting {
119119
/** No dots or test names */
120120
Silence = 0,
121121

@@ -158,14 +158,16 @@ declare module 'lab' {
158158
*/
159159
type Hook = TakesCallback | ReturnsPromise;
160160

161-
export type Laboratory = {
161+
type Script = {
162162
experiment: (description: string, experiment: Experiment) => any;
163163
test: (description: string, test: Test) => any;
164164
before: (fn: Hook) => void;
165165
beforeEach: (fn: Hook) => void;
166166
after: (fn: Hook) => void;
167167
afterEach: (fn: Hook) => void;
168168
}
169+
}
169170

170-
export function script(options?: Lab.ScriptOptions): Laboratory;
171+
declare module 'lab' {
172+
export function script(options?: Lab.ScriptOptions): Lab.Script;
171173
}

0 commit comments

Comments
 (0)