aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

fix: Typescript errors #14037

Open stocaaro opened 5 hours ago

stocaaro commented 5 hours ago

Description of changes

Upgrading typescript isn't possible without breaking the api-graphql and datastore builds.

For this change, I upgraded the entire amplify-js library to "typescript": "5.4.2" (by finding/replacing this dependency where it appears in the repo), then reviewing the build errors and fixing them,

Using a type subset where the problem comes up, this type refinement issue shows up between typescript 5.3.5 and 5.4.5.

5.4.0 came with a bunch of changes that may be causing this, the one that catches my attention is the more aggressive intersection reduction. It appears that repeated generic execution is retaining type narrowing now where before the superset type was kept, if I'm reading these errors correctly.

Description of how you validated changes

I have run/rerun yarn && yarn build && yarn test for both the upgraded and unupgraded versions of this fix.

Checklist

Checklist for repo maintainers

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