mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 23:34:47 -05:00
fix(check): include dts files in tsc roots (#18026)
This commit is contained in:
parent
c9c782940e
commit
273777f7d9
9 changed files with 23 additions and 13 deletions
|
@ -232,6 +232,12 @@ fn ts_no_recheck_on_redirect() {
|
||||||
assert!(std::str::from_utf8(&output.stderr).unwrap().is_empty());
|
assert!(std::str::from_utf8(&output.stderr).unwrap().is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
itest!(check_dts {
|
||||||
|
args: "check --quiet check/check_dts.d.ts",
|
||||||
|
output: "check/check_dts.out",
|
||||||
|
exit_code: 1,
|
||||||
|
});
|
||||||
|
|
||||||
itest!(package_json_basic {
|
itest!(package_json_basic {
|
||||||
args: "check main.ts",
|
args: "check main.ts",
|
||||||
output: "package_json/basic/main.check.out",
|
output: "package_json/basic/main.check.out",
|
||||||
|
|
|
@ -1021,7 +1021,7 @@ fn lsp_hover() {
|
||||||
"language": "typescript",
|
"language": "typescript",
|
||||||
"value": "const Deno.args: string[]"
|
"value": "const Deno.args: string[]"
|
||||||
},
|
},
|
||||||
"Returns the script arguments to the program.\n\nGive the following command line invocation of Deno:\n\n```sh\ndeno run --allow-read https://deno.land/std/examples/cat.ts /etc/passwd\n```\n\nThen `Deno.args` will contain:\n\n```\n[ \"/etc/passwd\" ]\n```\n\nIf you are looking for a structured way to parse arguments, there is the\n[`std/flags`](https://deno.land/std/flags) module as part of the Deno\nstandard library.",
|
"Returns the script arguments to the program.\n\nGive the following command line invocation of Deno:\n\n```sh\ndeno run --allow-read https://deno.land/std/examples/cat.ts /etc/passwd\n```\n\nThen `Deno.args` will contain:\n\n```ts\n[ \"/etc/passwd\" ]\n```\n\nIf you are looking for a structured way to parse arguments, there is the\n[`std/flags`](https://deno.land/std/flags) module as part of the Deno\nstandard library.",
|
||||||
"\n\n*@category* - Runtime Environment",
|
"\n\n*@category* - Runtime Environment",
|
||||||
],
|
],
|
||||||
"range": {
|
"range": {
|
||||||
|
|
2
cli/tests/testdata/check/check_dts.d.ts
vendored
Normal file
2
cli/tests/testdata/check/check_dts.d.ts
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// TS1039 [ERROR]: Initializers are not allowed in ambient contexts.
|
||||||
|
export const a: string = Deno.version.deno;
|
4
cli/tests/testdata/check/check_dts.out
vendored
Normal file
4
cli/tests/testdata/check/check_dts.out
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
error: TS1039 [ERROR]: Initializers are not allowed in ambient contexts.
|
||||||
|
export const a: string = Deno.version.deno;
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
at file:///[WILDCARD]/check_dts.d.ts:2:26
|
1
cli/tests/testdata/test/doc.out
vendored
1
cli/tests/testdata/test/doc.out
vendored
|
@ -1,4 +1,3 @@
|
||||||
Check [WILDCARD]/doc.ts$2-5.ts
|
|
||||||
Check [WILDCARD]/doc.ts$6-9.js
|
Check [WILDCARD]/doc.ts$6-9.js
|
||||||
Check [WILDCARD]/doc.ts$10-13.jsx
|
Check [WILDCARD]/doc.ts$10-13.jsx
|
||||||
Check [WILDCARD]/doc.ts$14-17.ts
|
Check [WILDCARD]/doc.ts$14-17.ts
|
||||||
|
|
2
cli/tests/testdata/test/doc.ts
vendored
2
cli/tests/testdata/test/doc.ts
vendored
|
@ -27,7 +27,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ```
|
* ```ts
|
||||||
* import { check } from "./doc.ts";
|
* import { check } from "./doc.ts";
|
||||||
*
|
*
|
||||||
* console.assert(check() == 42);
|
* console.assert(check() == 42);
|
||||||
|
|
|
@ -244,6 +244,9 @@ fn get_tsc_roots(
|
||||||
| MediaType::Tsx
|
| MediaType::Tsx
|
||||||
| MediaType::Mts
|
| MediaType::Mts
|
||||||
| MediaType::Cts
|
| MediaType::Cts
|
||||||
|
| MediaType::Dts
|
||||||
|
| MediaType::Dmts
|
||||||
|
| MediaType::Dcts
|
||||||
| MediaType::Jsx => Some((module.specifier.clone(), module.media_type)),
|
| MediaType::Jsx => Some((module.specifier.clone(), module.media_type)),
|
||||||
MediaType::JavaScript | MediaType::Mjs | MediaType::Cjs => {
|
MediaType::JavaScript | MediaType::Mjs | MediaType::Cjs => {
|
||||||
if check_js || has_ts_check(module.media_type, &module.source) {
|
if check_js || has_ts_check(module.media_type, &module.source) {
|
||||||
|
@ -253,9 +256,6 @@ fn get_tsc_roots(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MediaType::Json
|
MediaType::Json
|
||||||
| MediaType::Dts
|
|
||||||
| MediaType::Dmts
|
|
||||||
| MediaType::Dcts
|
|
||||||
| MediaType::Wasm
|
| MediaType::Wasm
|
||||||
| MediaType::TsBuildInfo
|
| MediaType::TsBuildInfo
|
||||||
| MediaType::SourceMap
|
| MediaType::SourceMap
|
||||||
|
|
|
@ -775,7 +775,6 @@ fn extract_files_from_regex_blocks(
|
||||||
Some(&"mts") => MediaType::Mts,
|
Some(&"mts") => MediaType::Mts,
|
||||||
Some(&"cts") => MediaType::Cts,
|
Some(&"cts") => MediaType::Cts,
|
||||||
Some(&"tsx") => MediaType::Tsx,
|
Some(&"tsx") => MediaType::Tsx,
|
||||||
Some(&"") => media_type,
|
|
||||||
_ => MediaType::Unknown,
|
_ => MediaType::Unknown,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
4
cli/tsc/dts/lib.deno.ns.d.ts
vendored
4
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -3481,7 +3481,7 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* ### Truncate part of the file
|
* ### Truncate part of the file
|
||||||
*
|
*
|
||||||
* ```
|
* ```ts
|
||||||
* const file = await Deno.makeTempFile();
|
* const file = await Deno.makeTempFile();
|
||||||
* await Deno.writeFile(file, new TextEncoder().encode("Hello World"));
|
* await Deno.writeFile(file, new TextEncoder().encode("Hello World"));
|
||||||
* await Deno.truncate(file, 7);
|
* await Deno.truncate(file, 7);
|
||||||
|
@ -4720,7 +4720,7 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* Then `Deno.args` will contain:
|
* Then `Deno.args` will contain:
|
||||||
*
|
*
|
||||||
* ```
|
* ```ts
|
||||||
* [ "/etc/passwd" ]
|
* [ "/etc/passwd" ]
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue