diff options
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/io.ts | 7 | ||||
-rw-r--r-- | cli/js/lib.deno_runtime.d.ts | 12 | ||||
-rw-r--r-- | cli/js/tls_test.ts | 9 |
3 files changed, 15 insertions, 13 deletions
diff --git a/cli/js/io.ts b/cli/js/io.ts index 1a7bf8c4c..15a4ad09b 100644 --- a/cli/js/io.ts +++ b/cli/js/io.ts @@ -3,11 +3,8 @@ // Documentation liberally lifted from them too. // Thank you! We love Go! -// TODO(kt3k): EOF should be `unique symbol` type. -// That might require some changes of ts_library_builder. -// See #2591 for more details. -export const EOF = null; -export type EOF = null; +export const EOF: unique symbol = Symbol("EOF"); +export type EOF = typeof EOF; // Seek whence values. // https://golang.org/pkg/io/#pkg-constants diff --git a/cli/js/lib.deno_runtime.d.ts b/cli/js/lib.deno_runtime.d.ts index c0bebf461..4331319bf 100644 --- a/cli/js/lib.deno_runtime.d.ts +++ b/cli/js/lib.deno_runtime.d.ts @@ -83,8 +83,8 @@ declare namespace Deno { // @url js/io.d.ts - export const EOF: null; - export type EOF = null; + export const EOF: unique symbol; + export type EOF = typeof EOF; export enum SeekMode { SEEK_START = 0, SEEK_CURRENT = 1, @@ -2283,8 +2283,6 @@ declare namespace eventTarget { declare namespace io { // @url js/io.d.ts - export const EOF: null; - export type EOF = null; export enum SeekMode { SEEK_START = 0, SEEK_CURRENT = 1, @@ -2308,10 +2306,10 @@ declare namespace io { * * Implementations must not retain `p`. */ - read(p: Uint8Array): Promise<number | EOF>; + read(p: Uint8Array): Promise<number | Deno.EOF>; } export interface SyncReader { - readSync(p: Uint8Array): number | EOF; + readSync(p: Uint8Array): number | Deno.EOF; } export interface Writer { /** Writes `p.byteLength` bytes from `p` to the underlying data @@ -2387,7 +2385,7 @@ declare namespace fetchTypes { formData(): Promise<domTypes.FormData>; json(): Promise<any>; text(): Promise<string>; - read(p: Uint8Array): Promise<number | io.EOF>; + read(p: Uint8Array): Promise<number | Deno.EOF>; close(): void; cancel(): Promise<void>; getReader(): domTypes.ReadableStreamReader; diff --git a/cli/js/tls_test.ts b/cli/js/tls_test.ts index 58cafd23e..6966a6911 100644 --- a/cli/js/tls_test.ts +++ b/cli/js/tls_test.ts @@ -184,7 +184,10 @@ testPerm({ read: true, net: true }, async function dialAndListenTLS(): Promise< await w.flush(); const tpr = new TextProtoReader(r); const statusLine = await tpr.readLine(); - assert(!!statusLine, "line must be read: " + statusLine); + assert(statusLine !== Deno.EOF, `line must be read: ${String(statusLine)}`); + if (statusLine === Deno.EOF) { + return; + } const m = statusLine.match(/^(.+?) (.+?) (.+?)$/); assert(m !== null, "must be matched"); const [_, proto, status, ok] = m; @@ -192,6 +195,10 @@ testPerm({ read: true, net: true }, async function dialAndListenTLS(): Promise< assertEquals(status, "200"); assertEquals(ok, "OK"); const headers = await tpr.readMIMEHeader(); + assert(headers !== Deno.EOF); + if (headers === Deno.EOF) { + return; + } const contentLength = parseInt(headers.get("content-length")); const bodyBuf = new Uint8Array(contentLength); await r.readFull(bodyBuf); |