Skip to content

Commit

Permalink
Fixes for early June TS3.6 DOM update (DefinitelyTyped#36294)
Browse files Browse the repository at this point in the history
* Fixes for early June TS3.6 DOM update

1. Apollo-link used GlobalFetch, which has been removed. Until my PR
goes in (apollographql/apollo-link#1095), I added a shim in
apollo-upload-client, which uses apollo-link-http-common.
2. dom-inputevent is updated to match the spec-standard InputEvent types that
will ship with Typescript 3.6.
3. Same for webappsec-credential-management
4. Fixed to-markdown's tests to work with the new, non-nullable
definition of node.style.fontStyle.

* Fix redundant `undefined` lint

* Make fetch shim work on more versions of Typescript

* Require TS 3.1 for apollo-upload-client fix
  • Loading branch information
sandersn authored and Konch Roman committed Aug 13, 2019
1 parent 9576daf commit 5fb3c75
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
8 changes: 7 additions & 1 deletion types/apollo-upload-client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
// Project: https://github.com/jaydenseric/apollo-upload-client#readme
// Definitions by: Edward Sammut Alessi <https://github.com/Slessi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
// TypeScript Version: 3.1

import { ApolloLink } from "apollo-link";
import { HttpOptions } from "apollo-link-http-common";

export { ReactNativeFile } from "extract-files";

declare global {
interface GlobalFetch {
fetch: WindowOrWorkerGlobalScope["fetch"];
}
}

/**
* `createUploadLink` options match `createHttpLink` options
* @param linkOptions `HttpOptions`
Expand Down
14 changes: 8 additions & 6 deletions types/dom-inputevent/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

interface InputEventInit extends UIEventInit {
data?: string;
isComposing: boolean;
data?: string | null;
isComposing?: boolean;
}

// tslint:disable-next-line no-empty-interface
interface InputEvent extends UIEvent {}
declare class InputEvent {
constructor(typeArg: 'input' | 'beforeinput', inputEventInit?: InputEventInit);
readonly data: string;
interface InputEvent extends UIEvent {
readonly data: string | null;
readonly isComposing: boolean;
}
declare var InputEvent: {
prototype: InputEvent;
new(type: string, eventInitDict?: InputEventInit): InputEvent;
};
4 changes: 2 additions & 2 deletions types/to-markdown/to-markdown-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ toMarkdown(`
{
filter(node) {
return node.nodeName === 'SPAN'
&& /italic/i.test(node.style.fontStyle!);
&& /italic/i.test(node.style.fontStyle || "");
},
replacement(innerHTML) {
return `*${innerHTML}*`;
Expand All @@ -43,7 +43,7 @@ toMarkdown(`
{
filter(node) {
return node.nodeName === 'SPAN'
&& /italic/i.test(node.style.fontStyle!);
&& /italic/i.test(node.style.fontStyle || "");
},
replacement(innerHTML, node) {
return `${innerHTML}(node: \`${node.nodeName}\`)`;
Expand Down
17 changes: 6 additions & 11 deletions types/webappsec-credential-management/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interface CMRequestInit {
* interface.
*/
interface Navigator {
credentials?: CredentialsContainer;
readonly credentials: CredentialsContainer;
}

/**
Expand All @@ -73,7 +73,7 @@ interface CredentialsContainer {
* return.
* @see {@link https://www.w3.org/TR/credential-management-1/#dom-credentialscontainer-get}
*/
get(options?: CredentialRequestOptions): Promise<Credential|null>;
get(options?: CredentialRequestOptions): Promise<CredentialType|null>;

/**
* Ask the credential manager to store a {@link Credential} for the user.
Expand All @@ -82,14 +82,14 @@ interface CredentialsContainer {
*
* @see {@link https://www.w3.org/TR/credential-management-1/#dom-credentialscontainer-store}
*/
store(credential: Credential): Promise<Credential>;
store(credential: CredentialType): Promise<CredentialType>;

/**
* Create a {@link Credential} asynchronously.
*
* @see {@link https://www.w3.org/TR/2017/WD-credential-management-1-20170804/#dom-credentialscontainer-create}
*/
create(options: CredentialCreationOptions): Promise<Credential|null>;
create(options: CredentialCreationOptions): Promise<CredentialType|null>;

/**
* Ask the credential manager to require user mediation before returning
Expand Down Expand Up @@ -126,7 +126,7 @@ interface CredentialData {
id: string;
}

type Credential = PasswordCredential|FederatedCredential|PublicKeyCredential;
type CredentialType = PasswordCredential|FederatedCredential|PublicKeyCredential;

/**
* A generic and extensible Credential interface from which all credentials
Expand Down Expand Up @@ -279,11 +279,6 @@ declare class FederatedCredential extends SiteBoundCredential {
readonly protocol: string|null;
}

/**
* @see {@link https://www.w3.org/TR/2017/WD-credential-management-1-20170804/#enumdef-credentialmediationrequirement}
*/
type CredentialMediationRequirement = 'silent'|'optional'|'required';

/**
* @see {@link https://www.w3.org/TR/credential-management-1/#dictdef-credentialrequestoptions}
*/
Expand Down Expand Up @@ -312,7 +307,7 @@ interface CredentialRequestOptions {
* This property specifies the mediation requirements for a given credential
* request.
*/
mediation?: CredentialMediationRequirement;
mediation?: 'silent' | 'optional' | 'required';

/**
* This property specifies options for requesting a public-key signature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function passwordPostSignInConfirmation() {
const c = new PasswordCredential(formElem);
fetch(formElem.action, { method: 'POST', credentials: c }).then(r => {
if (r.status === 200) {
navigator.credentials!.store(c);
navigator.credentials.store(c);
}
});
}
Expand Down

0 comments on commit 5fb3c75

Please sign in to comment.