mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
test(cli/dts): typecheck examples in declaration files (#10707)
This commits adds two integration tests that typecheck examples in the docstrings in Deno declaration files.
This commit is contained in:
parent
c5f700ca63
commit
3df9f41dfd
3 changed files with 35 additions and 5 deletions
5
cli/dts/lib.deno.unstable.d.ts
vendored
5
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -139,10 +139,7 @@ declare namespace Deno {
|
|||
* // The Deno.core namespace is needed to interact with plugins, but this is
|
||||
* // internal so we use ts-ignore to skip type checking these calls.
|
||||
* // @ts-ignore
|
||||
* const {
|
||||
* op_test_sync,
|
||||
* op_test_async,
|
||||
* } = Deno.core.ops();
|
||||
* const { op_test_sync, op_test_async } = Deno.core.ops();
|
||||
*
|
||||
* assert(op_test_sync);
|
||||
* assert(op_test_async);
|
||||
|
|
|
@ -18,6 +18,39 @@ use tempfile::TempDir;
|
|||
use test_util as util;
|
||||
use tokio::task::LocalSet;
|
||||
|
||||
// TODO(caspervonb): investiate why this fails on Windows.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn typecheck_declarations_ns() {
|
||||
let status = util::deno_cmd()
|
||||
.arg("test")
|
||||
.arg("--allow-all")
|
||||
.arg("--doc")
|
||||
.arg(util::root_path().join("cli/dts/lib.deno.ns.d.ts"))
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
// TODO(caspervonb): investiate why this fails on Windows.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn typecheck_declarations_unstable() {
|
||||
let status = util::deno_cmd()
|
||||
.arg("test")
|
||||
.arg("--doc")
|
||||
.arg("--allow-all")
|
||||
.arg("--unstable")
|
||||
.arg(util::root_path().join("cli/dts/lib.deno.unstable.d.ts"))
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn js_unit_tests_lint() {
|
||||
let status = util::deno_cmd()
|
||||
|
|
|
@ -318,7 +318,7 @@ fn lsp_hover_unstable_enabled() {
|
|||
"language":"typescript",
|
||||
"value":"function Deno.openPlugin(filename: string): number"
|
||||
},
|
||||
"**UNSTABLE**: new API, yet to be vetted.\n\nOpen and initialize a plugin.\n\n```ts\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nconst rid = Deno.openPlugin(\"./path/to/some/plugin.so\");\n\n// The Deno.core namespace is needed to interact with plugins, but this is\n// internal so we use ts-ignore to skip type checking these calls.\n// @ts-ignore\nconst {\n op_test_sync,\n op_test_async,\n} = Deno.core.ops();\n\nassert(op_test_sync);\nassert(op_test_async);\n\n// @ts-ignore\nconst result = Deno.core.opSync(\"op_test_sync\");\n\n// @ts-ignore\nconst result = await Deno.core.opAsync(\"op_test_sync\");\n```\n\nRequires `allow-plugin` permission.\n\nThe plugin system is not stable and will change in the future, hence the\nlack of docs. For now take a look at the example\nhttps://github.com/denoland/deno/tree/main/test_plugin"
|
||||
"**UNSTABLE**: new API, yet to be vetted.\n\nOpen and initialize a plugin.\n\n```ts\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nconst rid = Deno.openPlugin(\"./path/to/some/plugin.so\");\n\n// The Deno.core namespace is needed to interact with plugins, but this is\n// internal so we use ts-ignore to skip type checking these calls.\n// @ts-ignore\nconst { op_test_sync, op_test_async } = Deno.core.ops();\n\nassert(op_test_sync);\nassert(op_test_async);\n\n// @ts-ignore\nconst result = Deno.core.opSync(\"op_test_sync\");\n\n// @ts-ignore\nconst result = await Deno.core.opAsync(\"op_test_sync\");\n```\n\nRequires `allow-plugin` permission.\n\nThe plugin system is not stable and will change in the future, hence the\nlack of docs. For now take a look at the example\nhttps://github.com/denoland/deno/tree/main/test_plugin"
|
||||
],
|
||||
"range":{
|
||||
"start":{
|
||||
|
|
Loading…
Reference in a new issue