mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-17 17:48:06 +00:00
🤖 Merge PR #65785 default-gateway: upgrade to v7.2 by @yoursunny
This commit is contained in:
@@ -1,11 +1,29 @@
|
||||
import * as defaultGateway from 'default-gateway';
|
||||
import { gateway4async, gateway6async, gateway4sync, gateway6sync, type Result } from 'default-gateway';
|
||||
|
||||
defaultGateway.v4().then(result => {
|
||||
result; // $ExpectType Gateway
|
||||
});
|
||||
defaultGateway.v6().then(result => {
|
||||
result; // $ExpectType Gateway
|
||||
gateway4async().then((g) => {
|
||||
// $ExpectType Result<4>
|
||||
g;
|
||||
// $ExpectType string
|
||||
g.gateway;
|
||||
// $ExpectType 4
|
||||
g.version;
|
||||
// $ExpectType string | null
|
||||
g.int;
|
||||
});
|
||||
|
||||
defaultGateway.v4.sync(); // $ExpectType Gateway
|
||||
defaultGateway.v6.sync(); // $ExpectType Gateway
|
||||
// $ExpectType Result<4>
|
||||
gateway4sync();
|
||||
|
||||
gateway6async().then((g) => {
|
||||
// $ExpectType Result<6>
|
||||
g;
|
||||
// $ExpectType string
|
||||
g.gateway;
|
||||
// $ExpectType 6
|
||||
g.version;
|
||||
// $ExpectType string | null
|
||||
g.int;
|
||||
});
|
||||
|
||||
// $ExpectType Result<6>
|
||||
gateway6sync();
|
||||
|
||||
33
types/default-gateway/index.d.ts
vendored
33
types/default-gateway/index.d.ts
vendored
@@ -1,18 +1,31 @@
|
||||
// Type definitions for default-gateway 3.0
|
||||
// Type definitions for default-gateway 7.2
|
||||
// Project: https://github.com/silverwind/default-gateway#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Michele Della Mea <https://github.com/ArcaneDiver>
|
||||
// Junxiao Shi <https://github.com/yoursunny>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// Minimum TypeScript Version: 4.5
|
||||
|
||||
export const v4: DefaultGatewayFn;
|
||||
export const v6: DefaultGatewayFn;
|
||||
export function gateway4async(): Promise<Result<4>>;
|
||||
export function gateway6async(): Promise<Result<6>>;
|
||||
export function gateway4sync(): Result<4>;
|
||||
export function gateway6sync(): Result<6>;
|
||||
|
||||
export interface DefaultGatewayFn {
|
||||
(): Promise<Gateway>;
|
||||
sync(): Gateway;
|
||||
}
|
||||
|
||||
export interface Gateway {
|
||||
export interface Result<Family extends 4 | 6> {
|
||||
/**
|
||||
* The IP address of the default gateway.
|
||||
*/
|
||||
gateway: string;
|
||||
interface: string;
|
||||
|
||||
/**
|
||||
* The IP address version of `gateway`.
|
||||
*/
|
||||
version: Family;
|
||||
|
||||
/**
|
||||
* Name of the interface.
|
||||
* On Windows, this is the network adapter name.
|
||||
* This can be `null` if it cannot be determined.
|
||||
*/
|
||||
int: string | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user