Skip to content

JSII does not respect lib/target specified in custom tsconfig #4706

@hakenmt

Description

@hakenmt

Describe the bug

JSII appears to be defaulting to es2020 and even specifying a different value in a custom tsconfig still produces an error.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The specified version is used to compile the library.

Current Behavior

👾 build » compile | jsii --project tsconfig.jsii.json --tsconfig tsconfig.jsii.json --silence-warnings=reserved-word
[2024-11-19T17:20:10.544] [ERROR] jsii/compiler - Compilation errors prevented the JSII assembly from being created
src/LambdaLogParser.ts:178:31 - error TS2550: Property 'replaceAll' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later.

178 let val: string = value.replaceAll("/", "-");
~~~~~~~~~~
👾 Task "build » compile" failed when executing "jsii --project tsconfig.jsii.json --tsconfig tsconfig.jsii.json --silence-warnings=reserved-word" (cwd: /Users/mhaken/source/alb-access-log-parsing)

Reproduction Steps

{ "compilerOptions": { "outDir": "lib", "rootDir": "src", "esModuleInterop": true, "declarationMap": false, "inlineSourceMap": true, "inlineSources": true, "alwaysStrict": true, "declaration": true, "experimentalDecorators": true, "incremental": true, "lib": [ "es2022" ], "module": "commonjs", "noEmitOnError": true, "noFallthroughCasesInSwitch": true, "noImplicitAny": true, "noImplicitReturns": true, "noImplicitThis": true, "noUnusedLocals": true, "noUnusedParameters": true, "resolveJsonModule": true, "skipLibCheck": true, "strict": true, "strictNullChecks": true, "strictPropertyInitialization": true, "stripInternal": false, "target": "es2022", "composite": false, "tsBuildInfoFile": "lib/tsconfig.tsbuildinfo" }, "include": [ "src/**/*.ts" ], "exclude": [ "node_modules", "lib/.types-compat" ] }

I've added this to my .projenrc.ts

project.tasks.tryFind("compile")?.updateStep(0, { exec: "jsii --project tsconfig.jsii.json --tsconfig tsconfig.jsii.json --silence-warnings=reserved-word" })

However, I still get the error.

Possible Solution

No response

Additional Information/Context

No response

SDK version used

5.5.0

Environment details (OS name and version, etc.)

darwin

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions