1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

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.
This commit is contained in:
Muthu Kumar 2021-06-22 06:33:00 +05:30 committed by GitHub
parent 68c519d061
commit 388274e02e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 74 deletions

View file

@ -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");
}
}

View file

@ -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/ */

View file

@ -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<Response>): Promise<void>;

View file

@ -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",

View file

@ -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]

View file

@ -1 +0,0 @@
console.log(Deno.ppid);

View file

@ -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,