🤖 Merge PR #65785 default-gateway: upgrade to v7.2 by @yoursunny

This commit is contained in:
Junxiao Shi
2023-06-15 18:52:49 -04:00
committed by GitHub
parent ae486dbeda
commit 3d647cc7d4
2 changed files with 49 additions and 18 deletions

View File

@@ -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();

View File

@@ -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;
}