From b77d6cb29e4437f4783368aaa3b1d5c972470ad0 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Mon, 7 Dec 2020 10:49:58 +0000 Subject: [PATCH] chore(std): Remove tsconfig_test.json (#8629) Ref #8050 --- cli/tests/integration_tests.rs | 3 --- docs/getting_started/typescript.md | 31 ++++++++++++++---------------- std/tsconfig_test.json | 5 ----- 3 files changed, 14 insertions(+), 25 deletions(-) delete mode 100644 std/tsconfig_test.json diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 42172a7718..cb1bb27a34 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -10,7 +10,6 @@ use test_util as util; #[test] fn std_tests() { let dir = TempDir::new().expect("tempdir fail"); - let std_config = util::root_path().join("std/tsconfig_test.json"); let status = util::deno_cmd() .env("DENO_DIR", dir.path()) .current_dir(util::root_path()) @@ -18,8 +17,6 @@ fn std_tests() { .arg("--unstable") .arg("--seed=86") // Some tests rely on specific random numbers. .arg("-A") - .arg("--config") - .arg(std_config.to_str().unwrap()) // .arg("-Ldebug") .arg("std/") .spawn() diff --git a/docs/getting_started/typescript.md b/docs/getting_started/typescript.md index 972d42713d..6aa738c883 100644 --- a/docs/getting_started/typescript.md +++ b/docs/getting_started/typescript.md @@ -23,23 +23,20 @@ useful when type checking is provided by your editor and you want startup time to be as fast as possible (for example when restarting the program automatically with a file watcher). -Because `--no-check` does not do TypeScript type checking we can not -automatically remove type only imports and exports as this would require type -information. For this purpose TypeScript provides the -[`import type` and `export type` syntax](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-exports). -To export a type in a different file use -`export type { AnInterface } from "./mod.ts";`. To import a type use -`import type { AnInterface } from "./mod.ts";`. You can check that you are using -`import type` and `export type` where necessary by setting the `isolatedModules` -TypeScript compiler option to `true`, and the `importsNotUsedAsValues` to -`error`. You can see an example `tsconfig.json` with this option -[in the standard library](https://github.com/denoland/deno/blob/$CLI_VERSION/std/tsconfig_test.json). -These settings will be enabled by default in the future. They are already the -default in Deno 1.4 or above when using `--unstable`. +To make the most of skipping type checks, `--no-check` transpiles each module in +isolation without using information from imported modules. This maximizes +potential for concurrency and incremental rebuilds. On the other hand, the +transpiler cannot know if `export { Foo } from "./foo.ts"` should be preserved +(in case `Foo` is a value) or removed (in case `Foo` is strictly a type). To +resolve such ambiguities, Deno enforces +[`isolatedModules`](https://www.typescriptlang.org/tsconfig#isolatedModules) on +all TS code. This means that `Foo` in the above example must be a value, and the +[`export type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-exports) +syntax must be used instead if `Foo` is a type. -Because there is no type information when using `--no-check`, `const enum` is -not supported because it is type-directed. `--no-check` also does not support -the legacy `import =` and `export =` syntax. +Another consequence of `isolatedModules` is that the type-directed `const enum` +is treated like `enum`. The legacy `import =` and `export =` syntaxes are also +not supported by `--no-check`. ### Using external type definitions @@ -90,7 +87,7 @@ definition which happens to be alongside that file, your JavaScript module named export const foo = "foo"; ``` -Deno will see this, and the compiler will use `foo.d.ts` when type checking the +Deno will see this, and the compiler will use `foo.d.ts` when type-checking the file, though `foo.js` will be loaded at runtime. The resolution of the value of the directive follows the same resolution logic as importing a module, meaning the file needs to have an extension and is relative to the current file. Remote diff --git a/std/tsconfig_test.json b/std/tsconfig_test.json deleted file mode 100644 index 8dee5fa2a4..0000000000 --- a/std/tsconfig_test.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "isolatedModules": true - } -}