mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(webidl‑conversions): Update to v6.0 (#43334)
This commit is contained in:
parent
021d90143c
commit
5c883834e3
15
types/webidl-conversions/index.d.ts
vendored
15
types/webidl-conversions/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for webidl-conversions 5.0
|
||||
// Type definitions for webidl-conversions 6.0
|
||||
// Project: https://github.com/jsdom/webidl-conversions#readme
|
||||
// Definitions by: ExE Boss <https://github.com/ExE-Boss>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@ -7,8 +7,17 @@
|
||||
type Parameters<T extends (...args: any[]) => any> = T extends (...args: infer P) => any ? P : never;
|
||||
|
||||
declare namespace WebIDLConversions {
|
||||
interface Globals {
|
||||
[key: string]: any;
|
||||
|
||||
Number: (value?: any) => number;
|
||||
String: (value?: any) => string;
|
||||
TypeError: new (message?: string) => TypeError;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
context?: string;
|
||||
globals?: Globals;
|
||||
}
|
||||
|
||||
interface IntegerOptions extends Options {
|
||||
@ -73,11 +82,11 @@ declare const WebIDLConversions: {
|
||||
|
||||
DOMTimeStamp(V: any, opts?: WebIDLConversions.Options): number;
|
||||
// tslint:disable:ban-types
|
||||
Function<V>(V: V, opts?: WebIDLConversions.Options): V extends ((...args: any[]) => any) ? V : Function;
|
||||
Function<V>(V: V, opts?: WebIDLConversions.Options): V extends (...args: any[]) => any ? V : Function;
|
||||
VoidFunction<V>(
|
||||
V: V,
|
||||
opts?: WebIDLConversions.Options,
|
||||
): V extends ((...args: any[]) => any) ? (...args: Parameters<V>) => void : Function;
|
||||
): V extends (...args: any[]) => any ? (...args: Parameters<V>) => void : Function;
|
||||
};
|
||||
|
||||
// This can't use ES6 style exports, as those can't have spaces in export names.
|
||||
|
||||
@ -1,23 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015"
|
||||
],
|
||||
"lib": ["es2015"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"webidl-conversions-tests.ts"
|
||||
"webidl-conversions-tests.ts",
|
||||
"index.d.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@ -7,6 +7,19 @@ const options: conversions.Options = ((): conversions.Options => {
|
||||
return {};
|
||||
})();
|
||||
|
||||
options.context; // $ExpectType string | undefined
|
||||
|
||||
const {
|
||||
globals, // $ExpectType Globals | undefined
|
||||
} = options;
|
||||
|
||||
if (globals) {
|
||||
globals; // $ExpectType Globals
|
||||
globals.Number; // $ExpectType (value?: any) => number
|
||||
globals.String; // $ExpectType (value?: any) => string
|
||||
globals.TypeError; // $ExpectType new (message?: string | undefined) => TypeError
|
||||
}
|
||||
|
||||
/**
|
||||
* The `expectType` function from https://www.npmjs.com/package/tsd,
|
||||
* except instead of returning `void`, it returns `T`.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user