From 388274e02ea7e054f0bbbe4f863dc32447c5971d Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Tue, 22 Jun 2021 06:33:00 +0530 Subject: [PATCH] fix: move stable/unstable types/APIs to their correct places (#10880) - Moved ppid and memoryUsage types from deno.unstable to deno.ns. - Moved sleepSync to unstable object, shutdown to stable object. --- cli/diagnostics.rs | 41 -------------------------- cli/dts/lib.deno.ns.d.ts | 18 +++++++++++ cli/dts/lib.deno.unstable.d.ts | 14 --------- cli/tests/integration_tests.rs | 6 ---- cli/tests/unstable_disabled_ts2551.out | 10 ------- cli/tests/unstable_ts2551.ts | 1 - runtime/js/90_deno_ns.js | 4 +-- 7 files changed, 20 insertions(+), 74 deletions(-) delete mode 100644 cli/tests/unstable_disabled_ts2551.out delete mode 100644 cli/tests/unstable_ts2551.ts diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index 695330af32..da9a090c89 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -628,45 +628,4 @@ mod tests { let actual = diagnostics.to_string(); assert_eq!(strip_ansi_codes(&actual), "TS2552 [ERROR]: Cannot find name \'foo_Bar\'. Did you mean \'foo_bar\'?\nfoo_Bar();\n~~~~~~~\n at test.ts:8:1\n\n \'foo_bar\' is declared here.\n function foo_bar() {\n ~~~~~~~\n at test.ts:4:10"); } - - #[test] - fn test_unstable_suggestion() { - let value = json![ - { - "start": { - "line": 0, - "character": 17 - }, - "end": { - "line": 0, - "character": 21 - }, - "fileName": "file:///cli/tests/unstable_ts2551.ts", - "messageText": "Property 'ppid' does not exist on type 'typeof Deno'. Did you mean 'pid'?", - "sourceLine": "console.log(Deno.ppid);", - "relatedInformation": [ - { - "start": { - "line": 89, - "character": 15 - }, - "end": { - "line": 89, - "character": 18 - }, - "fileName": "asset:///lib.deno.ns.d.ts", - "messageText": "'pid' is declared here.", - "sourceLine": " export const pid: number;", - "category": 3, - "code": 2728 - } - ], - "category": 1, - "code": 2551 - } - ]; - let diagnostics: Diagnostic = serde_json::from_value(value).unwrap(); - let actual = diagnostics.to_string(); - assert_eq!(strip_ansi_codes(&actual), "TS2551 [ERROR]: Property \'ppid\' does not exist on type \'typeof Deno\'. \'Deno.ppid\' is an unstable API. Did you forget to run with the \'--unstable\' flag, or did you mean \'pid\'?\nconsole.log(Deno.ppid);\n ~~~~\n at file:///cli/tests/unstable_ts2551.ts:1:18\n\n \'pid\' is declared here.\n export const pid: number;\n ~~~\n at asset:///lib.deno.ns.d.ts:90:16"); - } } diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts index 2032757bb0..8ebf16150e 100644 --- a/cli/dts/lib.deno.ns.d.ts +++ b/cli/dts/lib.deno.ns.d.ts @@ -90,6 +90,24 @@ declare namespace Deno { /** The current process id of the runtime. */ export const pid: number; + /** + * The pid of the current process's parent. + */ + export const ppid: number; + + export interface MemoryUsage { + rss: number; + heapTotal: number; + heapUsed: number; + external: number; + } + + /** + * Returns an object describing the memory usage of the Deno process measured + * in bytes. + */ + export function memoryUsage(): MemoryUsage; + /** Reflects the `NO_COLOR` environment variable at program start. * * See: https://no-color.org/ */ diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 92858ba311..828211c5bb 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -1069,11 +1069,6 @@ declare namespace Deno { */ export function hostname(): string; - /** **UNSTABLE**: New API, yet to be vetted. - * The pid of the current process's parent. - */ - export const ppid: number; - /** **UNSTABLE**: New API, yet to be vetted. * A custom HttpClient for use with `fetch`. * @@ -1171,15 +1166,6 @@ declare namespace Deno { bytesReceived: number; } - export interface MemoryUsage { - rss: number; - heapTotal: number; - heapUsed: number; - external: number; - } - - export function memoryUsage(): MemoryUsage; - export interface RequestEvent { readonly request: Request; respondWith(r: Response | Promise): Promise; diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 2cad5a44ce..ce4c8d7d85 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -3976,12 +3976,6 @@ console.log("finish"); output: "unstable_enabled_js.out", }); - itest!(unstable_disabled_ts2551 { - args: "run --reload unstable_ts2551.ts", - exit_code: 1, - output: "unstable_disabled_ts2551.out", - }); - itest!(unstable_worker { args: "run --reload --unstable --quiet --allow-read unstable_worker.ts", output: "unstable_worker.ts.out", diff --git a/cli/tests/unstable_disabled_ts2551.out b/cli/tests/unstable_disabled_ts2551.out deleted file mode 100644 index bf8e6872b5..0000000000 --- a/cli/tests/unstable_disabled_ts2551.out +++ /dev/null @@ -1,10 +0,0 @@ -[WILDCARD] -error: TS2551 [ERROR]: Property 'ppid' does not exist on type 'typeof Deno'. 'Deno.ppid' is an unstable API. Did you forget to run with the '--unstable' flag, or did you mean 'pid'? -console.log(Deno.ppid); - ~~~~ - at [WILDCARD]cli/tests/unstable_ts2551.ts:1:18 - - 'pid' is declared here. - export const pid: number; - ~~~ - at asset:///lib.deno.ns.d.ts:[WILDCARD] diff --git a/cli/tests/unstable_ts2551.ts b/cli/tests/unstable_ts2551.ts deleted file mode 100644 index c9016c56cd..0000000000 --- a/cli/tests/unstable_ts2551.ts +++ /dev/null @@ -1 +0,0 @@ -console.log(Deno.ppid); diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index f563a20fe2..9d05908787 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -85,7 +85,7 @@ listen: __bootstrap.net.listen, connectTls: __bootstrap.tls.connectTls, listenTls: __bootstrap.tls.listenTls, - sleepSync: __bootstrap.timers.sleepSync, + shutdown: __bootstrap.net.shutdown, fstatSync: __bootstrap.fs.fstatSync, fstat: __bootstrap.fs.fstat, fsyncSync: __bootstrap.fs.fsyncSync, @@ -119,7 +119,7 @@ systemCpuInfo: __bootstrap.os.systemCpuInfo, applySourceMap: __bootstrap.errorStack.opApplySourceMap, formatDiagnostics: __bootstrap.errorStack.opFormatDiagnostics, - shutdown: __bootstrap.net.shutdown, + sleepSync: __bootstrap.timers.sleepSync, resolveDns: __bootstrap.net.resolveDns, listen: __bootstrap.netUnstable.listen, connect: __bootstrap.netUnstable.connect,