Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validateTsConfig - strict definition options (typeRoots / emitDecoratorMetadata #1443

Open
taylorb-syd opened this issue Sep 10, 2024 · 1 comment
Labels
bug Something isn't working p2

Comments

@taylorb-syd
Copy link

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
-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:

"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

"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

@taylorb-syd taylorb-syd added the bug Something isn't working label Sep 10, 2024
@mrgrain mrgrain transferred this issue from aws/jsii Oct 28, 2024
@mrgrain mrgrain added the p2 label Oct 28, 2024
@mrgrain
Copy link
Contributor

mrgrain commented Oct 28, 2024

I agree, these two options should be safe to allow for jsii. Contributions are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2
Projects
None yet
Development

No branches or pull requests

2 participants