Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(check): include dts files in tsc roots #18026

Merged
merged 2 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/tests/integration/check_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ fn ts_no_recheck_on_redirect() {
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 {
args: "check main.ts",
output: "package_json/basic/main.check.out",
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ fn lsp_hover() {
"language": "typescript",
"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",
],
"range": {
Expand Down
2 changes: 2 additions & 0 deletions cli/tests/testdata/check/check_dts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// TS1039 [ERROR]: Initializers are not allowed in ambient contexts.
export const a: string = Deno.version.deno;
4 changes: 4 additions & 0 deletions cli/tests/testdata/check/check_dts.out
Original file line number Diff line number Diff line change
@@ -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 change: 0 additions & 1 deletion cli/tests/testdata/test/doc.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Check [WILDCARD]/doc.ts$2-5.ts
Check [WILDCARD]/doc.ts$6-9.js
Check [WILDCARD]/doc.ts$10-13.jsx
Check [WILDCARD]/doc.ts$14-17.ts
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/testdata/test/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/

/**
* ```
* ```ts
* import { check } from "./doc.ts";
*
* console.assert(check() == 42);
Expand Down
6 changes: 3 additions & 3 deletions cli/tools/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ fn get_tsc_roots(
| MediaType::Tsx
| MediaType::Mts
| MediaType::Cts
| MediaType::Dts
| MediaType::Dmts
| MediaType::Dcts
| MediaType::Jsx => Some((module.specifier.clone(), module.media_type)),
MediaType::JavaScript | MediaType::Mjs | MediaType::Cjs => {
if check_js || has_ts_check(module.media_type, &module.source) {
Expand All @@ -253,9 +256,6 @@ fn get_tsc_roots(
}
}
MediaType::Json
| MediaType::Dts
| MediaType::Dmts
| MediaType::Dcts
| MediaType::Wasm
| MediaType::TsBuildInfo
| MediaType::SourceMap
Expand Down
1 change: 0 additions & 1 deletion cli/tools/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,6 @@ fn extract_files_from_regex_blocks(
Some(&"mts") => MediaType::Mts,
Some(&"cts") => MediaType::Cts,
Some(&"tsx") => MediaType::Tsx,
Some(&"") => media_type,
_ => MediaType::Unknown,
}
} else {
Expand Down
12 changes: 6 additions & 6 deletions cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ declare namespace Deno {
* ```
*
* Requires `allow-sys` permission.
*
*
* On Windows there is no API available to retrieve this information and this method returns `[ 0, 0, 0 ]`.
*
* @tags allow-sys
Expand Down Expand Up @@ -3481,7 +3481,7 @@ declare namespace Deno {
*
* ### Truncate part of the file
*
* ```
* ```ts
* const file = await Deno.makeTempFile();
* await Deno.writeFile(file, new TextEncoder().encode("Hello World"));
* await Deno.truncate(file, 7);
Expand Down Expand Up @@ -4095,7 +4095,7 @@ declare namespace Deno {
unref(): void;
}

/**
/**
* Options which can be set when calling {@linkcode Deno.Command}.
*
* @category Sub Process
Expand Down Expand Up @@ -4159,7 +4159,7 @@ declare namespace Deno {
windowsRawArguments?: boolean;
}

/**
/**
* @category Sub Process
*/
export interface CommandStatus {
Expand All @@ -4172,7 +4172,7 @@ declare namespace Deno {
signal: Signal | null;
}

/**
/**
* The interface returned from calling {@linkcode Command.output} or
* {@linkcode Command.outputSync} which represents the result of spawning the
* child process.
Expand Down Expand Up @@ -4720,7 +4720,7 @@ declare namespace Deno {
*
* Then `Deno.args` will contain:
*
* ```
* ```ts
* [ "/etc/passwd" ]
* ```
*
Expand Down