mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-27 00:15:09 +08:00
[lockfile] add typings for v1, enable strict null checks & linting (#18929)
This commit is contained in:
committed by
Mohamed Hegazy
parent
d31ee1e675
commit
8464387069
21
types/lockfile/index.d.ts
vendored
21
types/lockfile/index.d.ts
vendored
@@ -1,23 +1,24 @@
|
||||
// Type definitions for lockfile v0.4.2
|
||||
// Type definitions for lockfile 1.0
|
||||
// Project: https://github.com/isaacs/lockfile
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
export interface Options {
|
||||
wait?: number;
|
||||
pollPeriod?: number;
|
||||
stale?: number;
|
||||
retries?: number;
|
||||
retryWait?: number;
|
||||
}
|
||||
|
||||
export declare function lock(path: string, opts: Options, callback: (err: Error) => void): void;
|
||||
export declare function lock(path: string, callback: (err: Error) => void): void;
|
||||
export declare function lockSync(path: string, opts: Options): void;
|
||||
export function lock(path: string, opts: Options, callback: (err: Error | null) => void): void;
|
||||
export function lock(path: string, callback: (err: Error | null) => void): void;
|
||||
export function lockSync(path: string, opts?: Options): void;
|
||||
|
||||
export declare function unlock(path: string, callback: (err: Error) => void): void;
|
||||
export declare function unlockSync(path: string): void;
|
||||
export function unlock(path: string, callback: (err: Error | null) => void): void;
|
||||
export function unlockSync(path: string): void;
|
||||
|
||||
export declare function check(path: string, opts: Options, callback: (err: Error, isLocked: boolean) => void): void;
|
||||
export declare function check(path: string, callback: (err: Error, isLocked: boolean) => void): void;
|
||||
export declare function checkSync(path: string, opts: Options): boolean;
|
||||
export function check(path: string, opts: Options, callback: (err: Error | null, isLocked: boolean) => void): void;
|
||||
export function check(path: string, callback: (err: Error | null, isLocked: boolean) => void): void;
|
||||
export function checkSync(path: string, opts?: Options): boolean;
|
||||
|
||||
@@ -1,33 +1,47 @@
|
||||
|
||||
import lockfile = require('lockfile');
|
||||
|
||||
var bool: boolean;
|
||||
var num: number;
|
||||
var path: string;
|
||||
let bool: boolean;
|
||||
const num = 1;
|
||||
const path = '';
|
||||
|
||||
var opts: lockfile.Options;
|
||||
var callback: (err: Error) => {
|
||||
let opts: lockfile.Options;
|
||||
const callback = (err: Error) => {};
|
||||
|
||||
};
|
||||
var callback2: (err: Error, isLocked: boolean) => {
|
||||
|
||||
};
|
||||
lockfile.lock(path, {wait: num}, callback);
|
||||
lockfile.lock(path, {pollPeriod: num}, callback);
|
||||
lockfile.lock(path, {stale: num}, callback);
|
||||
lockfile.lock(path, {retries: num}, callback);
|
||||
lockfile.lock(path, {retryWait: num}, callback);
|
||||
|
||||
opts = {
|
||||
wait: num,
|
||||
stale: num,
|
||||
retries: num,
|
||||
retryWait: num
|
||||
wait: num,
|
||||
pollPeriod: num,
|
||||
stale: num,
|
||||
retries: num,
|
||||
retryWait: num
|
||||
};
|
||||
|
||||
lockfile.lock(path, opts, callback);
|
||||
lockfile.lock(path, callback);
|
||||
lockfile.lock(path, opts, (err) => {
|
||||
err; // $ExpectType Error | null
|
||||
});
|
||||
lockfile.lock(path, (err) => {
|
||||
err; // $ExpectType Error | null
|
||||
});
|
||||
lockfile.lockSync(path, opts);
|
||||
lockfile.lockSync(path);
|
||||
|
||||
lockfile.unlock(path, callback);;
|
||||
lockfile.unlock(path, (err) => {
|
||||
err; // $ExpectType Error | null
|
||||
});
|
||||
lockfile.unlockSync(path);
|
||||
|
||||
lockfile.check(path, opts, callback2);
|
||||
lockfile.check(path, callback2);
|
||||
|
||||
lockfile.check(path, opts, (err, isLocked) => {
|
||||
err; // $ExpectType Error | null
|
||||
isLocked; // $ExpectType boolean
|
||||
});
|
||||
lockfile.check(path, (err, isLocked) => {
|
||||
err; // $ExpectType Error | null
|
||||
isLocked; // $ExpectType boolean
|
||||
});
|
||||
bool = lockfile.checkSync(path, opts);
|
||||
bool = lockfile.checkSync(path);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -19,4 +19,4 @@
|
||||
"index.d.ts",
|
||||
"lockfile-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
1
types/lockfile/tslint.json
Normal file
1
types/lockfile/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
22
types/lockfile/v0/index.d.ts
vendored
Normal file
22
types/lockfile/v0/index.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Type definitions for lockfile 0.4
|
||||
// Project: https://github.com/isaacs/lockfile
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Options {
|
||||
wait?: number;
|
||||
stale?: number;
|
||||
retries?: number;
|
||||
retryWait?: number;
|
||||
}
|
||||
|
||||
export function lock(path: string, opts: Options, callback: (err: Error) => void): void;
|
||||
export function lock(path: string, callback: (err: Error) => void): void;
|
||||
export function lockSync(path: string, opts: Options): void;
|
||||
|
||||
export function unlock(path: string, callback: (err: Error) => void): void;
|
||||
export function unlockSync(path: string): void;
|
||||
|
||||
export function check(path: string, opts: Options, callback: (err: Error, isLocked: boolean) => void): void;
|
||||
export function check(path: string, callback: (err: Error, isLocked: boolean) => void): void;
|
||||
export function checkSync(path: string, opts: Options): boolean;
|
||||
30
types/lockfile/v0/lockfile-tests.ts
Normal file
30
types/lockfile/v0/lockfile-tests.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import lockfile = require('lockfile');
|
||||
|
||||
let bool: boolean;
|
||||
const num = 1;
|
||||
const path = '';
|
||||
|
||||
let opts: lockfile.Options;
|
||||
const callback = (err: Error) => {
|
||||
};
|
||||
const callback2 = (err: Error, isLocked: boolean) => {
|
||||
};
|
||||
|
||||
opts = {
|
||||
wait: num,
|
||||
stale: num,
|
||||
retries: num,
|
||||
retryWait: num
|
||||
};
|
||||
|
||||
lockfile.lock(path, opts, callback);
|
||||
lockfile.lock(path, callback);
|
||||
lockfile.lockSync(path, opts);
|
||||
|
||||
lockfile.unlock(path, callback);
|
||||
lockfile.unlockSync(path);
|
||||
|
||||
lockfile.check(path, opts, callback2);
|
||||
lockfile.check(path, callback2);
|
||||
|
||||
bool = lockfile.checkSync(path, opts);
|
||||
25
types/lockfile/v0/tsconfig.json
Normal file
25
types/lockfile/v0/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"lockfile": ["lockfile/v0"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"lockfile-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/lockfile/v0/tslint.json
Normal file
1
types/lockfile/v0/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user