cdk init : tsconfig has DOM as bundled library
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When creating a cdk app by using the cli command: `cdk init sample-app --language=typescript` then a sample project is created with a tsconfig that looks as follows:
```ts
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["es2020", "DOM"],
...
},
...
}
```
DOM as declaration for lib is not needed. CDK will not executed in the DOM , so the DOM libraries should not be used when creating cdk apps.
Furthermore the package.json has as dev. dependency the `"@types/node": "20.10.4",` which is correct and can support the developer to use the typescript types defined for `node`.
### Expected Behavior
When creating a cdk app by using the cli command: `cdk init sample-app --language=typescript` then a sample project should be created with a tsconfig that does not have DOM as lib declaration as follows :
```ts
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["es2020"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": ["./node_modules/@types"]
},
"exclude": ["node_modules", "cdk.out"]
}
```
### Current Behavior
When creating a cdk app by using the cli command: `cdk init sample-app --language=typescript` then a sample project is created with a tsconfig that looks as follows:
NOTE : DOM as declaration for lib is defined. CDK will not executed in the DOM , so the DOM libraries should not be used when creating cdk apps.
```ts
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["es2020", "DOM"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": ["./node_modules/@types"]
},
"exclude": ["node_modules", "cdk.out"]
}
```
### Reproduction Steps
`cdk init sample-app --language=typescript`
### Possible Solution
When creating a cdk app by using the cli command: `cdk init sample-app --language=typescript` then a sample project should be created with a tsconfig that does not have DOM as lib declaration as follows :
```ts
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["es2020"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": ["./node_modules/@types"]
},
"exclude": ["node_modules", "cdk.out"]
}
```
### Additional Information/Context
package.json de. Dependencies should remain as is in current behavior:
```ts
"devDependencies": {
"@types/jest": "^29.5.11",
"@types/node": "20.10.4",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"aws-cdk": "2.115.0",
"ts-node": "^10.9.2",
"typescript": "~5.3.3"
},
```
### CDK CLI Version
2.115.0 (build 58027ee)
### Framework Version
_No response_
### Node.js Version
v20.10.0
### OS
Linux Ubuntu
### Language
TypeScript
### Language Version
typescript: 5.3.3
### Other information
_No response_
Contributor guide
Research direction
Start by reproducing `cdk init sample-app --language=typescript` and inspect the generated `tsconfig`. Confirm that the TypeScript sample configuration includes `"DOM"` in `compilerOptions.lib`; done means the generated configuration contains `"es2020"` without `"DOM"` while retaining the stated package dependencies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100