validateTsConfig - strict definition options (typeRoots / emitDecoratorMetadata
- Dominant language
- TypeScript
- Stars
- 50
- Forks
- 26
- Avg merge
- 7h 10m
- Merged PRs (30d)
- 37
Description
### Describe the bug
For my project I have had to use the `tsconfig` option and I have tried to use `strict` mode, however two of the options I use in my configuration appear to be unknown/unsupported.
Here are the options that I am trying to use:
-[ `emitDecoratorMetadata`](https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata)
-[`typeRoots`](https://www.typescriptlang.org/tsconfig/#typeRoots)
I will switch to `minimal` for now, and report any compatibility issues should I encounter them.
That being said, how these options work seems to likely have little effect on the ability for JSII to operate. `emitDecoratorMetadata` adds additional metadata to the reflected classes which does not effect code execution, and `typeRoots` just allows TSC to be made aware of where typing information can be found if it isn't discoverable, which as far as I can tell will not affect runtime execution.
### Expected Behavior
Configuration containing `emitDecoratorMetadata` and `typeRoots` passes `strict` validation.
### Current Behavior
We get the following error:
```
error JSII4000: Typescript compiler options in "tsconfig.json" are not passing validation against rule set "strict", found the following rule violations:
- outDir: Unexpected field, got: outDir
- emitDecoratorMetadata: Unexpected field, got: emitDecoratorMetadata
- typeRoots: Unexpected field, got: typeRoots
```
### Reproduction Steps
Use the following `tsconfig.json` file `compilerOptions`:
```json
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022"],
"module": "node16",
"moduleResolution": "node16",
"declaration": true,
"inlineSourceMap": true,
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"stripInternal": false,
"composite": false,
"typeRoots": ["./node_modules/@types"],
"skipLibCheck": true,
"noEmitOnError": true
}
```
With the following settings in `package.json`
```json
"jsii": {
"tsconfig": "tsconfig.json",
"validateTsConfig": "strict",
}
```
### Possible Solution
Validate these settings are compatible with JSII and then add them to rules supported by the validator.
### Additional Information/Context
_No response_
### SDK version used
5.5.2
### Environment details (OS name and version, etc.)
Linux/5.15.153.1-microsoft-standard-WSL2/SMP/x86_64
Contributor guide
Research direction
Start with the reproduced tsconfig.json compilerOptions and the package.json jsii.validateTsConfig setting. Locate the strict validation rule set that reports JSII4000 for outDir, emitDecoratorMetadata, and typeRoots, then check the TypeScript compiler options it permits. Done means compatible options pass strict validation, with tests covering the reported configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100