From 7c16f20d16cb5cdb5d94e10ae89dd41e250b1f82 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 2 Oct 2019 23:06:53 +0700 Subject: [PATCH] Bundle the required DOM types (#93) Closes #92 --- source/index.ts | 43 ++++++++++++++++++++++++++++++++++++++++++- tsconfig.json | 3 +-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/source/index.ts b/source/index.ts index 9bb06dd..d1f3441 100644 --- a/source/index.ts +++ b/source/index.ts @@ -1,5 +1,46 @@ /// -/// + +/* -- Copy-pasted DOM types -- */ +// TODO: Remove these when https://github.com/microsoft/TypeScript/issues/33111 is fixed. +interface URLSearchParams { + append(name: string, value: string): void; + delete(name: string): void; + get(name: string): string | null; + getAll(name: string): string[]; + has(name: string): boolean; + set(name: string, value: string): void; + sort(): void; + forEach(callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any): void; +} + +declare var URLSearchParams: { // eslint-disable-line no-var + prototype: URLSearchParams; + new(init?: string[][] | Record | string | URLSearchParams): URLSearchParams; +}; + +interface URL { + hash: string; + host: string; + hostname: string; + href: string; + readonly origin: string; + password: string; + pathname: string; + port: string; + protocol: string; + search: string; + readonly searchParams: URLSearchParams; + username: string; + toJSON(): string; +} + +declare var URL: { // eslint-disable-line no-var + prototype: URL; + new(url: string, base?: string | URL): URL; + createObjectURL(object: any): string; + revokeObjectURL(url: string): void; +}; +/* ---- */ // TODO: Use the `URL` global when targeting Node.js 10 const URLGlobal = typeof URL === 'undefined' ? require('url').URL : URL; diff --git a/tsconfig.json b/tsconfig.json index 2acbd3e..7c5ead3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,8 +4,7 @@ "outDir": "dist", "target": "es2017", "lib": [ - "esnext", - "dom" + "esnext" ] }, "include": [