From b8abc14c217813627bc4f9a481fd30370b1b1943 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 11 Jul 2019 10:51:38 -0700 Subject: [PATCH 1/4] Jquery, webappsec-credential-mangment, webgl2 1. `$(window)` will have a different type in TS 3.6, `JQuery`, so ExpectType assertions won't work anymore. I weakened the test to test assignability: ```ts const jqw: JQuery = $(window); ``` 2. webappsec-credential-management needs to avoid conflicts with the DOM version that 3.6 will include in order to keep compiling. I copied interfaces and inlined type aliases where needed. Inlining type aliases is not the ideal solution, but they don't merge, so I couldn't copy them like interfaces. And they are (1) used only once or twice (2) self-explanatory literal unions, so I think it's fine for a package that will see reduced use once 3.6 is released. 3. webgl2 is also now in the DOM, so the polyfill types need to match exactly. I deleted an extra property. Again, I expect this package to stop being used as much once 3.6 is released. --- types/jquery/jquery-tests.ts | 3 - .../test/jquery-slim-window-module-tests.ts | 3 +- .../jquery/test/jquery-window-module-tests.ts | 3 +- .../index.d.ts | 86 ++++++++----------- types/webgl2/index.d.ts | 1 - 5 files changed, 40 insertions(+), 56 deletions(-) diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 0acf6e0d24ec01..36f7c494b1ef01 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -190,9 +190,6 @@ function JQueryStatic() { target; }); const myDocForced: JQuery = $(document); - const myWindow = $(window); - // $ExpectType JQuery - myWindow; const myWindowForced: JQuery = $(window); // $ExpectType JQuery myWindowForced; diff --git a/types/jquery/test/jquery-slim-window-module-tests.ts b/types/jquery/test/jquery-slim-window-module-tests.ts index bf4331d824693b..dc0147f9da674c 100644 --- a/types/jquery/test/jquery-slim-window-module-tests.ts +++ b/types/jquery/test/jquery-slim-window-module-tests.ts @@ -1,5 +1,4 @@ import jq = require('jquery/dist/jquery.slim'); const $window = jq(window); -// $ExpectType JQuery -$window; +const forced: JQuery = $window; diff --git a/types/jquery/test/jquery-window-module-tests.ts b/types/jquery/test/jquery-window-module-tests.ts index 1d554f086121da..09686ef4fabaac 100644 --- a/types/jquery/test/jquery-window-module-tests.ts +++ b/types/jquery/test/jquery-window-module-tests.ts @@ -1,5 +1,4 @@ import jq = require('jquery'); const $window = jq(window); -// $ExpectType JQuery -$window; +const forced: JQuery = $window; diff --git a/types/webappsec-credential-management/index.d.ts b/types/webappsec-credential-management/index.d.ts index 998d1261001bdc..93ec7f877f1151 100644 --- a/types/webappsec-credential-management/index.d.ts +++ b/types/webappsec-credential-management/index.d.ts @@ -116,17 +116,6 @@ interface CredentialsContainer { preventSilentAccess(): Promise; } -/** - * @see {@link https://www.w3.org/TR/credential-management-1/#dictdef-credentialdata} - */ -interface CredentialData { - /** - * The credential’s identifier. This might be a GUID, username, or email - * address, for instance. - */ - id: string; -} - type CredentialType = PasswordCredential|FederatedCredential|PublicKeyCredential; /** @@ -150,7 +139,12 @@ declare abstract class CredentialBase { /** * @see {@link https://www.w3.org/TR/credential-management-1/#dictdef-siteboundcredentialdata} */ -interface SiteBoundCredentialData extends CredentialData { +interface SiteBoundCredentialData { + /** + * The credential’s identifier. This might be a GUID, username, or email + * address, for instance. + */ + id: string; /** * A name associated with the credential, intended as a human-understandable * public name. @@ -372,16 +366,21 @@ interface FederatedCredentialRequestOptions { // Type definitions for webauthn // Spec: https://w3c.github.io/webauthn/ +interface txAuthGenericArg { + content: ArrayBuffer; + contentType: string; +} -/** - * @see {@link https://w3c.github.io/webauthn/#enumdef-publickeycredentialtype} - */ -type PublicKeyCredentialType = "public-key"; - -/** - * @see {@link https://w3c.github.io/webauthn/#enumdef-userverificationrequirement} - */ -type UserVerificationRequirement = "required" | "preferred" | "discouraged"; +interface AuthenticationExtensionsClientInputs { + appid?: string; + authnSel?: Array; + exts?: boolean; + loc?: boolean; + txAuthGeneric?: txAuthGenericArg; + txAuthSimple?: string; + uvi?: boolean; + uvm?: boolean; +} /** * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialrequestoptions} @@ -391,8 +390,8 @@ interface PublicKeyCredentialRequestOptions { timeout?: number; rpId?: string; allowCredentials?: PublicKeyCredentialDescriptor[]; - userVerification?: UserVerificationRequirement; - extensions?: any; + userVerification?: "required" | "preferred" | "discouraged"; + extensions?: AuthenticationExtensionsClientInputs; } /** @@ -416,43 +415,28 @@ interface PublicKeyCredentialUserEntity { * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialparameters} */ interface PublicKeyCredentialParameters { - type: PublicKeyCredentialType; + type: "public-key"; alg: number; } -/** - * @see {@link https://w3c.github.io/webauthn/#transport} - */ -type AuthenticatorTransport = "usb" | "nfc" | "ble" | "internal"; - /** * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptor} */ interface PublicKeyCredentialDescriptor { - type: PublicKeyCredentialType; + type: "public-key"; id: BufferSource; - transports?: AuthenticatorTransport[]; + transports?: Array<"usb" | "nfc" | "ble" | "internal">; } -/** - * @see {@link https://w3c.github.io/webauthn/#attachment} - */ -type AuthenticatorAttachment = "platform" | "cross-platform"; - /** * @see {@link https://w3c.github.io/webauthn/#dictdef-authenticatorselectioncriteria} */ interface AuthenticatorSelectionCriteria { - authenticatorAttachment?: AuthenticatorAttachment; + authenticatorAttachment?: "platform" | "cross-platform"; requireResidentKey?: boolean; - userVerification?: UserVerificationRequirement; + userVerification?: "required" | "preferred" | "discouraged"; } -/** - * @see {@link https://w3c.github.io/webauthn/#attestation-convey} - */ -type AttestationConveyancePreference = "none" | "indirect" | "direct"; - /** * @see {@link https://w3c.github.io/webauthn/#dictdef-makepublickeycredentialoptions} */ @@ -466,8 +450,8 @@ interface PublicKeyCredentialCreationOptions { timeout?: number; excludeCredentials?: PublicKeyCredentialDescriptor[]; authenticatorSelection?: AuthenticatorSelectionCriteria; - attestation?: AttestationConveyancePreference; - extensions?: any; + attestation?: "none" | "indirect" | "direct"; + extensions?: AuthenticationExtensionsClientInputs; } /** @@ -496,8 +480,14 @@ interface AuthenticatorAssertionResponse extends AuthenticatorResponse { /** * @see {@link https://w3c.github.io/webauthn/#publickeycredential} */ -interface PublicKeyCredential extends CredentialData { - readonly type: PublicKeyCredentialType; +interface PublicKeyCredential { + /** + * The credential’s identifier. This might be a GUID, username, or email + * address, for instance. + */ + id: string; + + readonly type: "public-key"; readonly rawId: ArrayBuffer; - readonly response: AuthenticatorAttestationResponse|AuthenticatorAssertionResponse; + readonly response: AuthenticatorResponse; } diff --git a/types/webgl2/index.d.ts b/types/webgl2/index.d.ts index a18d509e99020c..8adf0da8073ac5 100644 --- a/types/webgl2/index.d.ts +++ b/types/webgl2/index.d.ts @@ -798,7 +798,6 @@ declare var WebGL2RenderingContext: { readonly STENCIL_CLEAR_VALUE: number; readonly STENCIL_FAIL: number; readonly STENCIL_FUNC: number; - readonly STENCIL_INDEX: number; readonly STENCIL_INDEX8: number; readonly STENCIL_PASS_DEPTH_FAIL: number; readonly STENCIL_PASS_DEPTH_PASS: number; From 46e9252f09790caa2f2e2d0e487cdf2fd06bf942 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 11 Jul 2019 11:02:22 -0700 Subject: [PATCH 2/4] Rename CredentialData instead of deleting it --- .../index.d.ts | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/types/webappsec-credential-management/index.d.ts b/types/webappsec-credential-management/index.d.ts index 93ec7f877f1151..bb6681383bc66d 100644 --- a/types/webappsec-credential-management/index.d.ts +++ b/types/webappsec-credential-management/index.d.ts @@ -116,6 +116,17 @@ interface CredentialsContainer { preventSilentAccess(): Promise; } +/** + * @see {@link https://www.w3.org/TR/credential-management-1/#dictdef-credentialdata} + */ +interface Credential { + /** + * The credential’s identifier. This might be a GUID, username, or email + * address, for instance. + */ + readonly id: string; +} + type CredentialType = PasswordCredential|FederatedCredential|PublicKeyCredential; /** @@ -139,12 +150,7 @@ declare abstract class CredentialBase { /** * @see {@link https://www.w3.org/TR/credential-management-1/#dictdef-siteboundcredentialdata} */ -interface SiteBoundCredentialData { - /** - * The credential’s identifier. This might be a GUID, username, or email - * address, for instance. - */ - id: string; +interface SiteBoundCredentialData extends Credential { /** * A name associated with the credential, intended as a human-understandable * public name. @@ -477,16 +483,18 @@ interface AuthenticatorAssertionResponse extends AuthenticatorResponse { readonly userHandle: ArrayBuffer | null; } -/** - * @see {@link https://w3c.github.io/webauthn/#publickeycredential} - */ -interface PublicKeyCredential { +interface Credential { /** * The credential’s identifier. This might be a GUID, username, or email * address, for instance. */ - id: string; + readonly id: string; +} +/** + * @see {@link https://w3c.github.io/webauthn/#publickeycredential} + */ +interface PublicKeyCredential extends Credential { readonly type: "public-key"; readonly rawId: ArrayBuffer; readonly response: AuthenticatorResponse; From c1662ebd1722becdad76cb7eb4a29d7c8003b814 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 11 Jul 2019 11:17:45 -0700 Subject: [PATCH 3/4] Re-add CredentialData, CredentialBase->Credential CredentialBase becomes an interface too, which more closely matches the code in TS 3.6. --- .../index.d.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/types/webappsec-credential-management/index.d.ts b/types/webappsec-credential-management/index.d.ts index bb6681383bc66d..d45d821ec74195 100644 --- a/types/webappsec-credential-management/index.d.ts +++ b/types/webappsec-credential-management/index.d.ts @@ -119,7 +119,7 @@ interface CredentialsContainer { /** * @see {@link https://www.w3.org/TR/credential-management-1/#dictdef-credentialdata} */ -interface Credential { +interface CredentialData { /** * The credential’s identifier. This might be a GUID, username, or email * address, for instance. @@ -134,13 +134,12 @@ type CredentialType = PasswordCredential|FederatedCredential|PublicKeyCredential * will inherit. * @see {@link https://www.w3.org/TR/credential-management-1/#credential} */ -declare abstract class CredentialBase { +interface Credential { /** * The credential’s identifier. This might be a GUID, username, or email * address, for instance. */ readonly id: string; - /** * The credential’s type. */ @@ -150,7 +149,7 @@ declare abstract class CredentialBase { /** * @see {@link https://www.w3.org/TR/credential-management-1/#dictdef-siteboundcredentialdata} */ -interface SiteBoundCredentialData extends Credential { +interface SiteBoundCredentialData extends CredentialData { /** * A name associated with the credential, intended as a human-understandable * public name. @@ -170,7 +169,9 @@ interface SiteBoundCredentialData extends Credential { * agent’s credential * store. */ -declare abstract class SiteBoundCredential extends CredentialBase { +// tslint:disable-next-line no-empty-interface +interface SiteBoundCredential extends Credential { } +declare abstract class SiteBoundCredential { /** * A name associated with the credential, intended as a human-understandable * public name. @@ -483,14 +484,6 @@ interface AuthenticatorAssertionResponse extends AuthenticatorResponse { readonly userHandle: ArrayBuffer | null; } -interface Credential { - /** - * The credential’s identifier. This might be a GUID, username, or email - * address, for instance. - */ - readonly id: string; -} - /** * @see {@link https://w3c.github.io/webauthn/#publickeycredential} */ From 11bb753d9a6cd6e4454ac1698334263789044990 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 11 Jul 2019 13:01:10 -0700 Subject: [PATCH 4/4] Bump version of webappsec-credential-management --- types/webappsec-credential-management/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/webappsec-credential-management/index.d.ts b/types/webappsec-credential-management/index.d.ts index d45d821ec74195..1af82962dd44e0 100644 --- a/types/webappsec-credential-management/index.d.ts +++ b/types/webappsec-credential-management/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for non-npm package W3C (WebAppSec) Credential Management API Level 1, 0.4 +// Type definitions for non-npm package W3C (WebAppSec) Credential Management API Level 1, 0.5 // Project: https://github.com/w3c/webappsec-credential-management // Definitions by: Iain McGinniss // Joao Peixoto