Repository: deno
Issue: Type-checking fails when enabling the compiler option `isolatedDeclarations`
Labels: bug,lsp,tsc

According to the Deno CLI [config file schema](https://deno.land/x/deno@v2.0.2/cli/schemas/config-file.v1.json?source=#:~:text=isolatedDeclarations), the compiler option [`isolatedDeclarations`](https://www.typescriptlang.org/tsconfig/#isolatedDeclarations) is supported. However, type-checking fails when enabling this option because it requires enabling either [`declaration`](https://www.typescriptlang.org/tsconfig/#declaration) or [`composite`](https://www.typescriptlang.org/tsconfig/#composite), which are both not currently supported by Deno. Type-checking also appears to fail because Deno implicitly enables [`allowJs`](https://www.typescriptlang.org/tsconfig/#allowJs) in this scenario.

According to the TypeScript [release notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#using-isolateddeclarations):

> ### Using `isolatedDeclarations`
>
> `isolatedDeclarations` requires that either the `declaration` or `composite` flags are also set.

---

Minimal reproducible example:

```txt
% deno --version
deno 2.0.2 (stable, release, aarch64-apple-darwin)
v8 12.9.202.13-rusty
typescript 5.6.2

% ls -AF
deno.json	mod.ts
```

`./deno.json`
```json
{
  "compilerOptions": {
    "isolatedDeclarations": true
  }
}

```

`./mod.ts`
```ts
export function add(a: number, b: number) {
  return a + b;
}

```

Type-checking:
```txt
% deno check mod.ts
Check file:///Users/deno/example/mod.ts
error: TS5053 [ERROR]: Option 'allowJs' cannot be specified with option 'isolatedDeclarations'.

TS5069 [ERROR]: Option 'isolatedDeclarations' cannot be specified without specifying option 'declaration' or option 'composite'.

Found 2 errors.
```

Disabling `allowJs` and enabling `declaration` seems to have no effect — Deno appears to ignore these changes:

`./deno.json`
```json
{
  "compilerOptions": {
    "allowJs": false,
    "declaration": true,
    "isolatedDeclarations": true
  }
}

```

```txt
% deno check mod.ts
Check file:///Users/deno/example/mod.ts
error: TS5053 [ERROR]: Option 'allowJs' cannot be specified with option 'isolatedDeclarations'.

TS5069 [ERROR]: Option 'isolatedDeclarations' cannot be specified without specifying option 'declaration' or option 'composite'.

Found 2 errors.
```

---

Here is a juxtaposition of the expected behavior — of what happens when type-checking with `tsc` directly — checking **completes** but a diagnostic error is produced because of the elision of an explicit return type:

```txt
% ./node_modules/typescript/bin/tsc --version
Version 5.6.3

% ls -AF 
mod.ts			package-lock.json	tsconfig.json
node_modules/		package.json
```

`./package.json`
```json
{
  "name": "example",
  "version": "0.1.0",
  "type": "module",
  "license": "MIT",
  "devDependencies": {
    "typescript": "^5.6.3"
  }
}

```

`./tsconfig.json`
```json
{
  "compilerOptions": {
    "declaration": true,
    "isolatedDeclarations": true,
    "noEmit": true
  }
}

```

```txt
% ./node_modules/typescript/bin/tsc
mod.ts:1:17 - error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations.

1 export function add(a: number, b: number) {
                  ~~~

  mod.ts:1:17
    1 export function add(a: number, b: number) {
                      ~~~
    Add a return type to the function declaration.


Found 1 error in mod.ts:1
```

---

I think Deno should continue to support this compiler option and make the necessary changes to the CLI/LSP in order to support compatibility.