fix(types): expose legacy "types" folder in export alias #15123
Merged
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.
Description Of Problem
Imports of things like 'sequelize/types/hooks' (which is used by sequelize-typescript) is broken when using Typescript's "nodenext" or "node16" module resolution strategies. One could update the imports to 'sequelize/lib/hooks', but doing so breaks the default Typescript module resolution. So projects like sequelize-typescript can't easily make that change.
Currently anyone using the newer module resolution strategies along with sequelize-typescript have no upgrade path to a version of sequelize without the vulnerability mentioned in #14519
Description Of Change
This is a different approach to #14719.
Instead of adding hooks to the exports in index.d.ts, we can just add a "/types/" alias to the exports in package.json. Doing so allows imports of 'sequelize/types/hooks' to properly resolve using both older and newer Typescript module resolution strategies. In essence, importing /types/* will work as it always has regardless of module resolution strategy.