diff options
Diffstat (limited to 'tests/testdata/check')
49 files changed, 244 insertions, 0 deletions
diff --git a/tests/testdata/check/all/check_all.out b/tests/testdata/check/all/check_all.out new file mode 100644 index 000000000..344264634 --- /dev/null +++ b/tests/testdata/check/all/check_all.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type '12' is not assignable to type '"a"'. +export const a: "a" = 12; + ^ + at http://localhost:4545/subdir/type_error.ts:1:14 diff --git a/tests/testdata/check/all/check_all.ts b/tests/testdata/check/all/check_all.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/tests/testdata/check/all/check_all.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/tests/testdata/check/broadcast_channel.ts b/tests/testdata/check/broadcast_channel.ts new file mode 100644 index 000000000..6c75b4a8e --- /dev/null +++ b/tests/testdata/check/broadcast_channel.ts @@ -0,0 +1 @@ +const _channel = new BroadcastChannel("foo"); diff --git a/tests/testdata/check/cache_config_on_off/deno.json b/tests/testdata/check/cache_config_on_off/deno.json new file mode 100644 index 000000000..8ad9c9801 --- /dev/null +++ b/tests/testdata/check/cache_config_on_off/deno.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strict": false + } +} diff --git a/tests/testdata/check/cache_config_on_off/main.ts b/tests/testdata/check/cache_config_on_off/main.ts new file mode 100644 index 000000000..0f3785f91 --- /dev/null +++ b/tests/testdata/check/cache_config_on_off/main.ts @@ -0,0 +1 @@ +console.log(5); diff --git a/tests/testdata/check/declaration_header_file_with_no_exports.ts b/tests/testdata/check/declaration_header_file_with_no_exports.ts new file mode 100644 index 000000000..ef5da7a38 --- /dev/null +++ b/tests/testdata/check/declaration_header_file_with_no_exports.ts @@ -0,0 +1,2 @@ +import * as foo from "./declaration_header_file_with_no_exports_js.js"; +console.log(foo); diff --git a/tests/testdata/check/declaration_header_file_with_no_exports_js.d.ts b/tests/testdata/check/declaration_header_file_with_no_exports_js.d.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/testdata/check/declaration_header_file_with_no_exports_js.d.ts diff --git a/tests/testdata/check/declaration_header_file_with_no_exports_js.js b/tests/testdata/check/declaration_header_file_with_no_exports_js.js new file mode 100644 index 000000000..b8ae2bcef --- /dev/null +++ b/tests/testdata/check/declaration_header_file_with_no_exports_js.js @@ -0,0 +1 @@ +/// <reference types="./declaration_header_file_with_no_exports_js.d.ts" /> diff --git a/tests/testdata/check/deno_not_found/main.out b/tests/testdata/check/deno_not_found/main.out new file mode 100644 index 000000000..dc4a682c7 --- /dev/null +++ b/tests/testdata/check/deno_not_found/main.out @@ -0,0 +1,4 @@ +error: TS2304 [ERROR]: Cannot find name 'Deno'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'deno.ns' or add a triple-slash directive to the top of your entrypoint (main file): /// <reference lib="deno.ns" /> +Deno; +~~~~ + at file:///[WILDCARD]/check/deno_not_found/main.ts:4:1 diff --git a/tests/testdata/check/deno_not_found/main.ts b/tests/testdata/check/deno_not_found/main.ts new file mode 100644 index 000000000..3269f047a --- /dev/null +++ b/tests/testdata/check/deno_not_found/main.ts @@ -0,0 +1,4 @@ +/// <reference no-default-lib="true"/> +/// <reference lib="es5" /> + +Deno; diff --git a/tests/testdata/check/dts/check_dts.d.ts b/tests/testdata/check/dts/check_dts.d.ts new file mode 100644 index 000000000..9cf60f063 --- /dev/null +++ b/tests/testdata/check/dts/check_dts.d.ts @@ -0,0 +1,2 @@ +// TS1039 [ERROR]: Initializers are not allowed in ambient contexts. +export const a: string = Deno.version.deno; diff --git a/tests/testdata/check/dts/check_dts.out b/tests/testdata/check/dts/check_dts.out new file mode 100644 index 000000000..e7ff9a009 --- /dev/null +++ b/tests/testdata/check/dts/check_dts.out @@ -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 diff --git a/tests/testdata/check/exclude_option/deno.exclude_dir.json b/tests/testdata/check/exclude_option/deno.exclude_dir.json new file mode 100644 index 000000000..2019f8953 --- /dev/null +++ b/tests/testdata/check/exclude_option/deno.exclude_dir.json @@ -0,0 +1,5 @@ +{ + "exclude": [ + "ignored" + ] +} diff --git a/tests/testdata/check/exclude_option/deno.exclude_glob.json b/tests/testdata/check/exclude_option/deno.exclude_glob.json new file mode 100644 index 000000000..1d203ba08 --- /dev/null +++ b/tests/testdata/check/exclude_option/deno.exclude_glob.json @@ -0,0 +1,5 @@ +{ + "exclude": [ + "ignored/**/*" + ] +} diff --git a/tests/testdata/check/exclude_option/deno.json b/tests/testdata/check/exclude_option/deno.json new file mode 100644 index 000000000..a9eca74ca --- /dev/null +++ b/tests/testdata/check/exclude_option/deno.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} diff --git a/tests/testdata/check/exclude_option/exclude_option.ts.error.out b/tests/testdata/check/exclude_option/exclude_option.ts.error.out new file mode 100644 index 000000000..abd1c1258 --- /dev/null +++ b/tests/testdata/check/exclude_option/exclude_option.ts.error.out @@ -0,0 +1,4 @@ +error: TS2304 [ERROR]: Cannot find name 'nothing'. +export { nothing }; + ~~~~~~~ + at [WILDCARD] diff --git a/tests/testdata/check/exclude_option/ignored/index.ts b/tests/testdata/check/exclude_option/ignored/index.ts new file mode 100644 index 000000000..0419cf073 --- /dev/null +++ b/tests/testdata/check/exclude_option/ignored/index.ts @@ -0,0 +1 @@ +export { nothing }; diff --git a/tests/testdata/check/exclude_option/index.ts b/tests/testdata/check/exclude_option/index.ts new file mode 100644 index 000000000..8335ca3a2 --- /dev/null +++ b/tests/testdata/check/exclude_option/index.ts @@ -0,0 +1,5 @@ +import { nothing } from "./ignored/index.ts"; + +const foo = 1; + +export { foo, nothing }; diff --git a/tests/testdata/check/excluded_file_specified/check.out b/tests/testdata/check/excluded_file_specified/check.out new file mode 100644 index 000000000..2bc26aaaf --- /dev/null +++ b/tests/testdata/check/excluded_file_specified/check.out @@ -0,0 +1 @@ +Warning No matching files found. diff --git a/tests/testdata/check/excluded_file_specified/deno.json b/tests/testdata/check/excluded_file_specified/deno.json new file mode 100644 index 000000000..039be18df --- /dev/null +++ b/tests/testdata/check/excluded_file_specified/deno.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "types": ["./lib/types.d.ts"] + }, + "exclude": ["lib"] +} diff --git a/tests/testdata/check/excluded_file_specified/lib/types.d.ts b/tests/testdata/check/excluded_file_specified/lib/types.d.ts new file mode 100644 index 000000000..a02ad0cbe --- /dev/null +++ b/tests/testdata/check/excluded_file_specified/lib/types.d.ts @@ -0,0 +1,2 @@ +// deno-lint-ignore-file +declare var test: number; diff --git a/tests/testdata/check/export_equals_declaration_file/main.ts b/tests/testdata/check/export_equals_declaration_file/main.ts new file mode 100644 index 000000000..e20a735d5 --- /dev/null +++ b/tests/testdata/check/export_equals_declaration_file/main.ts @@ -0,0 +1,6 @@ +// @deno-types="./other.d.ts" +import Test, { type Attributes } from "./other.js"; + +const other: Attributes = {}; +console.log(Test()); +console.log(other); diff --git a/tests/testdata/check/export_equals_declaration_file/other.d.ts b/tests/testdata/check/export_equals_declaration_file/other.d.ts new file mode 100644 index 000000000..5e1274fa5 --- /dev/null +++ b/tests/testdata/check/export_equals_declaration_file/other.d.ts @@ -0,0 +1,9 @@ +export = other; + +declare function other(): string; + +declare namespace other { + interface Attributes { + [attr: string]: string; + } +} diff --git a/tests/testdata/check/export_equals_declaration_file/other.js b/tests/testdata/check/export_equals_declaration_file/other.js new file mode 100644 index 000000000..f66c03162 --- /dev/null +++ b/tests/testdata/check/export_equals_declaration_file/other.js @@ -0,0 +1,3 @@ +export default function other() { + return "test"; +} diff --git a/tests/testdata/check/jsx_not_checked/main.jsx b/tests/testdata/check/jsx_not_checked/main.jsx new file mode 100644 index 000000000..8de05f9f7 --- /dev/null +++ b/tests/testdata/check/jsx_not_checked/main.jsx @@ -0,0 +1,21 @@ +// should not error about jsx-runtime not being found in types here +/** @jsxImportSource npm:react@18.2.0 */ + +import "./other.ts"; + +export default ( + <> + <h1>Hello world</h1> + <p>This is a JSX page</p> + </> +); + +/** + * @param {number} a + * @param {number} b + */ +function add(a, b) { + return a + b; +} + +console.log(add("1", "2")); diff --git a/tests/testdata/check/jsx_not_checked/main.out b/tests/testdata/check/jsx_not_checked/main.out new file mode 100644 index 000000000..82c1c2358 --- /dev/null +++ b/tests/testdata/check/jsx_not_checked/main.out @@ -0,0 +1,13 @@ +[UNORDERED_START] +Download http://localhost:4545/npm/registry/react +Download http://localhost:4545/npm/registry/loose-envify +Download http://localhost:4545/npm/registry/js-tokens +Download http://localhost:4545/npm/registry/react/react-18.2.0.tgz +Download http://localhost:4545/npm/registry/loose-envify/loose-envify-1.4.0.tgz +Download http://localhost:4545/npm/registry/js-tokens/js-tokens-4.0.0.tgz +[UNORDERED_END] +Check file:///[WILDCARD]/jsx_not_checked/main.jsx +error: TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'number'. +console.log(add("1", "2")); + ~~~ + at file:///[WILDCARD]/other.ts:5:17 diff --git a/tests/testdata/check/jsx_not_checked/other.ts b/tests/testdata/check/jsx_not_checked/other.ts new file mode 100644 index 000000000..47995cb0f --- /dev/null +++ b/tests/testdata/check/jsx_not_checked/other.ts @@ -0,0 +1,5 @@ +function add(a: number, b: number) { + return a + b; +} + +console.log(add("1", "2")); diff --git a/tests/testdata/check/jsximportsource_importmap_config/deno.json b/tests/testdata/check/jsximportsource_importmap_config/deno.json new file mode 100644 index 000000000..6d837af7c --- /dev/null +++ b/tests/testdata/check/jsximportsource_importmap_config/deno.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + }, + "importMap": "./import_map.json" +} diff --git a/tests/testdata/check/jsximportsource_importmap_config/import_map.json b/tests/testdata/check/jsximportsource_importmap_config/import_map.json new file mode 100644 index 000000000..e926207af --- /dev/null +++ b/tests/testdata/check/jsximportsource_importmap_config/import_map.json @@ -0,0 +1,5 @@ +{ + "imports": { + "jsx/jsx-runtime": "./jsx_runtime.ts" + } +} diff --git a/tests/testdata/check/jsximportsource_importmap_config/jsx_runtime.ts b/tests/testdata/check/jsximportsource_importmap_config/jsx_runtime.ts new file mode 100644 index 000000000..33a07ca73 --- /dev/null +++ b/tests/testdata/check/jsximportsource_importmap_config/jsx_runtime.ts @@ -0,0 +1,4 @@ +// deno-lint-ignore no-namespace +export namespace JSX { + export type IntrinsicElements = { [key: string]: unknown }; +} diff --git a/tests/testdata/check/jsximportsource_importmap_config/main.bundle.js b/tests/testdata/check/jsximportsource_importmap_config/main.bundle.js new file mode 100644 index 000000000..6f39c876e --- /dev/null +++ b/tests/testdata/check/jsximportsource_importmap_config/main.bundle.js @@ -0,0 +1,9 @@ +// deno-fmt-ignore-file +// deno-lint-ignore-file +// This code was bundled using `deno bundle` and it's not recommended to edit it manually + +const makeParagraph = ()=>jsx("p", { + children: "A paragraph!" + }); +export { makeParagraph as makeParagraph }; + diff --git a/tests/testdata/check/jsximportsource_importmap_config/main.tsx b/tests/testdata/check/jsximportsource_importmap_config/main.tsx new file mode 100644 index 000000000..a1eb24f0b --- /dev/null +++ b/tests/testdata/check/jsximportsource_importmap_config/main.tsx @@ -0,0 +1 @@ +export const makeParagraph = () => <p>A paragraph!</p>; diff --git a/tests/testdata/check/module_detection_force.ts b/tests/testdata/check/module_detection_force.ts new file mode 100644 index 000000000..185ceb816 --- /dev/null +++ b/tests/testdata/check/module_detection_force.ts @@ -0,0 +1,3 @@ +const a = 1; +await import("./module_detection_force/import.ts"); +console.log(a); diff --git a/tests/testdata/check/module_detection_force/import.ts b/tests/testdata/check/module_detection_force/import.ts new file mode 100644 index 000000000..66b229870 --- /dev/null +++ b/tests/testdata/check/module_detection_force/import.ts @@ -0,0 +1,2 @@ +const a = 2; +console.log(a); diff --git a/tests/testdata/check/module_detection_force/main.ts b/tests/testdata/check/module_detection_force/main.ts new file mode 100644 index 000000000..a55c9962b --- /dev/null +++ b/tests/testdata/check/module_detection_force/main.ts @@ -0,0 +1,3 @@ +const a = 1; +await import("./import.ts"); +console.log(a); diff --git a/tests/testdata/check/no_error_truncation/deno.json b/tests/testdata/check/no_error_truncation/deno.json new file mode 100644 index 000000000..643707ccc --- /dev/null +++ b/tests/testdata/check/no_error_truncation/deno.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "noErrorTruncation": true + } +} diff --git a/tests/testdata/check/no_error_truncation/main.out b/tests/testdata/check/no_error_truncation/main.out new file mode 100644 index 000000000..13fd5aae4 --- /dev/null +++ b/tests/testdata/check/no_error_truncation/main.out @@ -0,0 +1,11 @@ +error: TS2322 [ERROR]: Type '{ propertyWithAnExceedinglyLongName1: string; propertyWithAnExceedinglyLongName2: string; propertyWithAnExceedinglyLongName3: string; propertyWithAnExceedinglyLongName4: string; propertyWithAnExceedinglyLongName5: string; propertyWithAnExceedinglyLongName6: string; propertyWithAnExceedinglyLongName7: string; propertyWithAnExceedinglyLongName8: string; }' is not assignable to type 'string'. +const _s: string = x; + ~~ + at file:///[WILDCARD]/no_error_truncation/main.ts:12:7 + +TS2454 [ERROR]: Variable 'x' is used before being assigned. +const _s: string = x; + ^ + at file:///[WILDCARD]/no_error_truncation/main.ts:12:20 + +Found 2 errors. diff --git a/tests/testdata/check/no_error_truncation/main.ts b/tests/testdata/check/no_error_truncation/main.ts new file mode 100644 index 000000000..bb1856602 --- /dev/null +++ b/tests/testdata/check/no_error_truncation/main.ts @@ -0,0 +1,12 @@ +let x: { + propertyWithAnExceedinglyLongName1: string; + propertyWithAnExceedinglyLongName2: string; + propertyWithAnExceedinglyLongName3: string; + propertyWithAnExceedinglyLongName4: string; + propertyWithAnExceedinglyLongName5: string; + propertyWithAnExceedinglyLongName6: string; + propertyWithAnExceedinglyLongName7: string; + propertyWithAnExceedinglyLongName8: string; +}; + +const _s: string = x; diff --git a/tests/testdata/check/node_builtin_modules/mod.js b/tests/testdata/check/node_builtin_modules/mod.js new file mode 100644 index 000000000..196fb9be9 --- /dev/null +++ b/tests/testdata/check/node_builtin_modules/mod.js @@ -0,0 +1,3 @@ +// @ts-check +import fs from "node:fs"; +const _data = fs.readFileSync("./node_builtin.js", 123); diff --git a/tests/testdata/check/node_builtin_modules/mod.js.out b/tests/testdata/check/node_builtin_modules/mod.js.out new file mode 100644 index 000000000..97786ebae --- /dev/null +++ b/tests/testdata/check/node_builtin_modules/mod.js.out @@ -0,0 +1,5 @@ +error: TS2769 [ERROR]: No overload matches this call. + [WILDCARD] +const _data = fs.readFileSync("./node_builtin.js", 123); + ~~~ + at file:///[WILDCARD]/node_builtin_modules/mod.js:3:52 diff --git a/tests/testdata/check/node_builtin_modules/mod.ts b/tests/testdata/check/node_builtin_modules/mod.ts new file mode 100644 index 000000000..0e62353fe --- /dev/null +++ b/tests/testdata/check/node_builtin_modules/mod.ts @@ -0,0 +1,9 @@ +import fs from "node:fs"; +const _data = fs.readFileSync("./node_builtin.js", 123); + +// check node:module specifically because for deno check it should +// resolve to the @types/node package, but at runtime it uses a different +// builtin object than deno_std +import { builtinModules } from "node:module"; +// should error about being string[] +const _testString: number[] = builtinModules; diff --git a/tests/testdata/check/node_builtin_modules/mod.ts.out b/tests/testdata/check/node_builtin_modules/mod.ts.out new file mode 100644 index 000000000..49b762cff --- /dev/null +++ b/tests/testdata/check/node_builtin_modules/mod.ts.out @@ -0,0 +1,13 @@ +error: TS2769 [ERROR]: No overload matches this call. + [WILDCARD] +const _data = fs.readFileSync("./node_builtin.js", 123); + ~~~ + at file:///[WILDCARD]/node_builtin_modules/mod.ts:2:52 + +TS2322 [ERROR]: Type 'string[]' is not assignable to type 'number[]'. + Type 'string' is not assignable to type 'number'. +const _testString: number[] = builtinModules; + ~~~~~~~~~~~ + at file:///[WILDCARD]/node_builtin_modules/mod.ts:9:7 + +Found 2 errors. diff --git a/tests/testdata/check/npm_install_diagnostics/main.out b/tests/testdata/check/npm_install_diagnostics/main.out new file mode 100644 index 000000000..fe46f0e42 --- /dev/null +++ b/tests/testdata/check/npm_install_diagnostics/main.out @@ -0,0 +1,11 @@ +error: TS2581 [ERROR]: Cannot find name '$'. Did you mean to import jQuery? Try adding `import $ from "npm:jquery";`. +$; +^ + at file:///[WILDCARD]/npm_install_diagnostics/main.ts:1:1 + +TS2580 [ERROR]: Cannot find name 'process'. +process; +~~~~~~~ + at file:///[WILDCARD]/npm_install_diagnostics/main.ts:2:1 + +Found 2 errors. diff --git a/tests/testdata/check/npm_install_diagnostics/main.ts b/tests/testdata/check/npm_install_diagnostics/main.ts new file mode 100644 index 000000000..62c0c5619 --- /dev/null +++ b/tests/testdata/check/npm_install_diagnostics/main.ts @@ -0,0 +1,2 @@ +$; +process; diff --git a/tests/testdata/check/response_json.ts b/tests/testdata/check/response_json.ts new file mode 100644 index 000000000..e936f7bff --- /dev/null +++ b/tests/testdata/check/response_json.ts @@ -0,0 +1,5 @@ +/// <reference no-default-lib="true" /> +/// <reference lib="dom" /> +/// <reference lib="esnext" /> + +Response.json({}); diff --git a/tests/testdata/check/types_dts/deno.json b/tests/testdata/check/types_dts/deno.json new file mode 100644 index 000000000..85f1549e0 --- /dev/null +++ b/tests/testdata/check/types_dts/deno.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "./types.d.ts" + ] + } +} diff --git a/tests/testdata/check/types_dts/main.out b/tests/testdata/check/types_dts/main.out new file mode 100644 index 000000000..c769989e3 --- /dev/null +++ b/tests/testdata/check/types_dts/main.out @@ -0,0 +1 @@ +Check file:///[WILDCARD]/check/types_dts/main.ts diff --git a/tests/testdata/check/types_dts/main.ts b/tests/testdata/check/types_dts/main.ts new file mode 100644 index 000000000..ca375a094 --- /dev/null +++ b/tests/testdata/check/types_dts/main.ts @@ -0,0 +1,3 @@ +console.log("Hello world!"); + +test.test(); diff --git a/tests/testdata/check/types_dts/types.d.ts b/tests/testdata/check/types_dts/types.d.ts new file mode 100644 index 000000000..141c2a3d3 --- /dev/null +++ b/tests/testdata/check/types_dts/types.d.ts @@ -0,0 +1,3 @@ +declare class test { + static test(): void; +} |
