Add types for node-abi (#37238)

This commit is contained in:
Florian Keller 2019-08-01 21:29:17 +02:00 committed by Jesse Trinity
parent bcbffb5c5c
commit 96f60f1a0e
4 changed files with 60 additions and 0 deletions

22
types/node-abi/index.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
// Type definitions for node-abi 2.10
// Project: https://github.com/lgeiger/node-abi#readme
// Definitions by: Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export type Runtime = 'electron' | 'node' | 'node-webkit';
export interface Target {
abi: string;
lts: boolean;
runtime: Runtime;
target: string;
}
export let additionalTargets: Target[];
export let allTargets: Target[];
export let deprecatedTargets: Target[];
export let futureTargets: Target[];
export let supportedTargets: Target[];
export function getAbi(target: string, runtime?: Runtime): string;
export function getTarget(abi?: string, runtime?: Runtime): string;
export function _getNextTarget(runtime: Runtime, targets?: Target[]): string | null;

View File

@ -0,0 +1,14 @@
import * as nodeAbi from 'node-abi';
nodeAbi.getAbi('7.2.0', 'electron'); // $ExpectType string
nodeAbi.getAbi('1.4.10'); // $ExpectType string
nodeAbi.getTarget('51', 'node'); // $ExpectType string
nodeAbi.getTarget('50'); // $ExpectType string
nodeAbi.getTarget(); // $ExpectType string
nodeAbi._getNextTarget('electron', nodeAbi.allTargets); // $ExpectType string | null
nodeAbi.allTargets; // $ExpectType Target[]
nodeAbi.deprecatedTargets; // $ExpectType Target[]
nodeAbi.supportedTargets; // $ExpectType Target[]
nodeAbi.additionalTargets; // $ExpectType Target[]
nodeAbi.futureTargets; // $ExpectType Target[]

View File

@ -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",
"node-abi-tests.ts"
]
}

View File

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