Fix tough-cookie Cookie field typings

This commit is contained in:
Michael Cypher
2019-01-16 21:36:02 -08:00
parent 70fe269343
commit 8b6637b246
3 changed files with 11 additions and 13 deletions
+4 -3
View File
@@ -1,4 +1,4 @@
import { JSDOM, VirtualConsole, CookieJar, FromUrlOptions, FromFileOptions, DOMWindow, ResourceLoader, FetchOptions } from 'jsdom';
import { JSDOM, VirtualConsole, CookieJar, FromUrlOptions, FromFileOptions, DOMWindow, ResourceLoader, FetchOptions, ConstructorOptions } from 'jsdom';
import { CookieJar as ToughCookieJar, MemoryCookieStore } from 'tough-cookie';
import { Script } from 'vm';
@@ -56,8 +56,9 @@ function test_cookieJar() {
const store = {} as MemoryCookieStore;
const options = {} as ToughCookieJar.Options;
const cookieJar = new CookieJar(store, options);
const dom = new JSDOM(``, { cookieJar });
const cookieJar: CookieJar = new CookieJar(store, options);
const constructorOptions: ConstructorOptions = { cookieJar };
const dom = new JSDOM(``, constructorOptions);
}
function test_beforeParse() {
+2 -3
View File
@@ -14,7 +14,6 @@ let strOrTrueOrUndef: string | true | undefined;
const buffer: Buffer = new Buffer('foo');
let num = 0;
let bool: boolean;
let date: Date;
let obj: object;
const dest = 'foo';
@@ -58,8 +57,8 @@ obj = req.toJSON();
let cookie: request.Cookie = request.cookie('foo')!;
str = cookie.key;
str = cookie.value;
date = cookie.expires;
str = cookie.path;
const expires: Date | 'Infinity' = cookie.expires;
const cpath: string | null = cookie.path;
str = cookie.toString();
bool = cookie.httpOnly;
+5 -7
View File
@@ -73,18 +73,16 @@ export class Cookie {
constructor(properties?: Cookie.Properties);
// TODO: Some of the following properties might actually be nullable.
key: string;
value: string;
expires: Date;
expires: Date | 'Infinity';
maxAge: number | 'Infinity' | '-Infinity';
domain: string;
path: string;
domain: string | null;
path: string | null;
secure: boolean;
httpOnly: boolean;
extensions: string[];
creation: Date;
extensions: string[] | null;
creation: Date | null;
creationIndex: number;
hostOnly: boolean | null;