Fixes for early June TS3.6 DOM update (#36294)

* 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
This commit is contained in:
Nathan Shively-Sanders
2019-06-19 13:57:51 -07:00
committed by GitHub
parent 8a8bc934a5
commit 984e42db6f
5 changed files with 24 additions and 21 deletions

View File

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

View File

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

View File

@@ -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}*`;
@@ -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}\`)`;

View File

@@ -57,7 +57,7 @@ interface CMRequestInit {
* interface.
*/
interface Navigator {
credentials?: CredentialsContainer;
readonly credentials: CredentialsContainer;
}
/**
@@ -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.
@@ -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
@@ -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
@@ -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}
*/
@@ -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.

View File

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