Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
noUncheckedIndexedAccess
ruleThis ensured type safety related to accessing unknown object properties and array members.
moduleResolution
tobundler
Makes TypeScript resolve files in a way similar to how Vite and other bundlers resolve files. Documentation: microsoft/TypeScript#51669 Evan You (creator of Vite) explicitly recommends using this for Vite apps: https://twitter.com/youyuxi/status/1636551895002255362
"moduleResolution": "bundler"
makes module resolution respect package.jsonexports
field. One implication of this is that you can't import from internal file structure unless it's allowed in the package'sexports
conditions.Disallowing this is a feature, since the internal file structure can change any time, and it's not been specified as allowed import path in package.json
exports
. There are often ways of solving it in other ways, as inferring types instead of importing:If something needs to be imported and can't be inferred or solve in another way, it should be officially exported instead.
Another problem is that
cypress.config.ts
is not being resolved correctly when switchingmoduleResolution
tobundler
. This is a known problem that Cypress is working on: cypress-io/cypress#26308 Until it's solved upstream, a possible workaround it to rename the file tocypress.config.mjs
, which removes the need for Cypress to transpile the config file to JavaScript. Another workaround is to explicitly set thatts-node
should be using"moduleResolution": "node"
: cypress-io/cypress#26308 (comment)Required for
"moduleResolution": "bundler"
.