Skip to content

Conversation

@rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Dec 4, 2025

In order to support some other performance-related changes, I was planning to split the sets of source files inside aws-cdk-lib into 2 classes:

  • "Library" source files: all .ts files except those in test subdirectories.
  • "Test" source files: files in test subdirectories, consuming the library as a separately compiled subproject.

It turns out this does not work for 2 reasons:

  • stripInternal: true (TypeScript feature): there are some APIs that we strip out of the .d.ts files. If we put a discrete compilation step between the library and the tests, that means that tests can't use @internal APIs either, which we test in a number of cases.
  • --strip-deprecated (jsii feature): there are some legacy @deprecated APIs that we strip out of the .d.ts files as well, and the same applies: we have tests for a number of these that start failing once we separately compile the two source sets.

Instead, we're just absorbing the test suite into a single tsconfig.json for this project again.

The upshot of doing all this is: test files are now being type-checked by tsc and it turns out they had a ton of type errors in them!

In most cases we saw "unused variable" errors, but there were honest to goodness typing mistakes in there, that just happened to execute properly when runing through ts-jest (with type checking ignored).

I'm submitting this as a PR by itself to get those changes out of the way.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

In preparation for something else I want to do (compiling the test files
to `.js` again), I'm splitting the source filess inside `aws-cdk-lib`
into 2 classes:

- "Library" source files: all `.ts` files except those in `test`
  subdirectories.
- "Test" source files: files in `test` subdirectories.

In order to make this official, I'm making two `tsconfig.json` files
with project references between them:

- `tsconfig.lib.json`: addresses library source files.
- `tsconfig.tests.json`: addresses test source files, and has a project
  reference to `tsconfig.lib.json`.

Doing this introduces an additional problem: we now have two different
tsconfig files in the same directory, and how does your IDE know which
config to use based on which file you are currently looking at?  Turns
out the VSCode plugin will only look for `tsconfig.json` and nothing
else.

We're therefore also adding the following:

- `tsconfig.json`: addresses *all* source files in the subdirectory.
- `tsconfig.options.json`: all the other files `extend` this. Contains
  the TS compiler options in a single place so that we don't have to
  copy/paste them around.

The upshot of doing all this is: **test files are now being type-checked
by `tsc` and it turns out they had a ton of type errors in them!**

In most cases we saw "unused variable" errors, but there were honest to
goodness typing mistakes in there, that just happened to execute
properly when runing through `ts-jest` (with type checking ignored).

I'm submitting this as a PR by itself to get those changes out of the
way.
@rix0rrr rix0rrr requested a review from a team as a code owner December 4, 2025 11:17
@aws-cdk-automation aws-cdk-automation requested a review from a team December 4, 2025 11:18
@github-actions github-actions bot added the p2 label Dec 4, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Dec 4, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants