feat(webidl‑conversions): Update to v6.0 (#43334)

This commit is contained in:
ExE Boss 2020-03-27 16:59:51 +01:00 committed by GitHub
parent 021d90143c
commit 5c883834e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 11 deletions

View File

@ -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.

View File

@ -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"
]
}

View File

@ -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`.