microsoft / microsoft/TypeScript

Module value in TSConfig does not enforce ModuleResolution value

Open
#63,671 0 comments 0 reactions 1 assignee Claimed by @andrewbranch View on GitHub
Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### 🔎 Search Terms

moduleresolution enforce

### 🕗 Version & Regression Information

I tested also on typescript 5 and the behavior was the same

### ⏯ Playground Link

_No response_

### 💻 Code

According to docs certain `module` values imply and _**enforce**_ certain `moduleResolution` values as decribed at https://www.typescriptlang.org/docs/handbook/modules/reference.html#implied-and-enforced-options

However the following `tsconfig` works without any issue:
```json
{
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "node16", // this should not be allowed
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"types": ["*"]
}
}
```
even when according to docs `--module nodenext` should enforce `--moduleResolution nodenext`

### 🙁 Actual behavior

the `tsc` compilation works with option that should fail according to docs

### 🙂 Expected behavior

fix the behavior or the docs

### Additional information about the issue

typescript version: 6.0.3

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.