Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hand crafted types for text-encoding #6

Merged
merged 1 commit into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
- Fix v8_source_maps.ts so that we don't get random segfaults.

- Remove text-encoding.d.ts because TS2.8 includes the declarations.
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/24695

- Add os.statSync and os.tempDir- both are needed for the writeFileSync test in
tests.ts

Expand Down
1 change: 0 additions & 1 deletion fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { assert, log, createResolvable, Resolvable } from "./util";
import * as util from "./util";
import * as dispatch from "./dispatch";
import { main as pb } from "./msg.pb";
import { TextDecoder } from "text-encoding";

export function initFetch() {
dispatch.sub("fetch", (payload: Uint8Array) => {
Expand Down
71 changes: 4 additions & 67 deletions text-encoding.d.ts
Original file line number Diff line number Diff line change
@@ -1,69 +1,6 @@
// Type definitions for text-encoding
// Project: https://github.com/inexorabletash/text-encoding
// Definitions by: MIZUNE Pine <https://github.com/pine613>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare namespace TextEncoding {
interface TextDecoderOptions {
fatal?: boolean;
ignoreBOM?: boolean;
}

interface TextDecodeOptions {
stream?: boolean;
}

interface TextEncoderOptions {
NONSTANDARD_allowLegacyEncoding?: boolean;
}

interface TextDecoder {
encoding: string;
fatal: boolean;
ignoreBOM: boolean;
decode(
input?: ArrayBuffer | ArrayBufferView,
options?: TextDecodeOptions
): string;
}

interface TextEncoder {
encoding: string;
encode(input?: string, options?: TextEncodeOptions): Uint8Array;
}

interface TextEncodeOptions {
stream?: boolean;
}

interface TextEncoderStatic {
(utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
new (utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
}

interface TextDecoderStatic {
(label?: string, options?: TextDecoderOptions): TextDecoder;
new (label?: string, options?: TextDecoderOptions): TextDecoder;
}

interface TextEncodingStatic {
TextEncoder: TextEncoderStatic;
TextDecoder: TextDecoderStatic;
}
}

/* Removed following lines to workaround this bug:
text-encoding.d.ts:52:13 - error TS2403: Subsequent variable declarations
must have the same type. Variable 'TextDecoder' must be of type '{ new
(label?: string, options?: TextDecoderOptions): TextDecoder; prototype:
TextDecoder; }', but here has type 'TextDecoderStatic'.

52 declare var TextDecoder: TextEncoding.TextDecoderStatic;
*/
// declare var TextDecoder: TextEncoding.TextDecoderStatic;
// declare var TextEncoder: TextEncoding.TextEncoderStatic;
declare var TextEncoding: TextEncoding.TextEncodingStatic;

// Remove and depend on @types/text-encoding once this PR is merged
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26141
declare module "text-encoding" {
export = TextEncoding;
export const TextEncoder: TextEncoder;
export const TextDecoder: TextDecoder;
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"preserveConstEnums": true,
"declaration": true,
"target": "es2017",
"lib": ["es2017", "DOM"],
"lib": ["es2017", "dom"],
"noEmit": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
Expand Down