1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-29 16:30:56 -05:00

fix(test): typecheck blocks annotated with long js/ts notations (#13785)

This commit is contained in:
Geert-Jan Zwiers 2022-03-08 02:10:40 +01:00 committed by Yoshiya Hinosawa
parent a6d509934d
commit 8cab5d8062
No known key found for this signature in database
GPG key ID: 0E8BFAA8A5B4E92B
4 changed files with 33 additions and 0 deletions

View file

@ -97,6 +97,12 @@ itest!(markdown_windows {
output: "test/markdown_windows.out", output: "test/markdown_windows.out",
}); });
itest!(markdown_full_block_names {
args: "test --doc --allow-all test/markdown_full_block_names.md",
exit_code: 1,
output: "test/markdown_full_block_names.out",
});
itest!(text { itest!(text {
args: "test --doc --allow-all test/text.md", args: "test --doc --allow-all test/text.md",
exit_code: 0, exit_code: 0,

View file

@ -0,0 +1,19 @@
# Documentation
The following block should be given a js extension on extraction:
```javascript
console.log("js");
```
The following example contains the ignore attribute and will be ignored:
```typescript ignore
const value: Invalid = "ignored";
```
The following example will trigger the type-checker to fail:
```typescript
const a: string = 42;
```

View file

@ -0,0 +1,6 @@
Check [WILDCARD]/test/markdown_full_block_names.md$5-8.js
Check [WILDCARD]/test/markdown_full_block_names.md$17-20.ts
error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
const a: string = 42;
^
at [WILDCARD]/test/markdown_full_block_names.md$17-20.ts:1:7

View file

@ -554,10 +554,12 @@ fn extract_files_from_regex_blocks(
match attributes.get(0) { match attributes.get(0) {
Some(&"js") => MediaType::JavaScript, Some(&"js") => MediaType::JavaScript,
Some(&"javascript") => MediaType::JavaScript,
Some(&"mjs") => MediaType::Mjs, Some(&"mjs") => MediaType::Mjs,
Some(&"cjs") => MediaType::Cjs, Some(&"cjs") => MediaType::Cjs,
Some(&"jsx") => MediaType::Jsx, Some(&"jsx") => MediaType::Jsx,
Some(&"ts") => MediaType::TypeScript, Some(&"ts") => MediaType::TypeScript,
Some(&"typescript") => MediaType::TypeScript,
Some(&"mts") => MediaType::Mts, Some(&"mts") => MediaType::Mts,
Some(&"cts") => MediaType::Cts, Some(&"cts") => MediaType::Cts,
Some(&"tsx") => MediaType::Tsx, Some(&"tsx") => MediaType::Tsx,