Repository navigation
refactor(typescript): add foundation for incremential TS migration - #13569
Conversation
Converts the logger interface to TypeScript. Adds eslint rules and TypeScript configuration to allow for a gradual migration to TS. Adds a build script to transpile both TS and JS code while keeping the same API for package usage. Changes imports from test files to use "absolute" paths that point to the directory of the compiled code.
b646976 to
cd5b4f1
Compare
sdepold
left a comment
There was a problem hiding this comment.
Is this changing the way I can import / user Sequelize in a TS based application?
|
Soooo. Can we just merge this or do we have to double check or prepare anything else? |
Should be good to go! We'll have to resolve any merge conflicts (which will probably be any test file due to the change in relative paths into |
f73810f to
88a1d34
Compare
Ok. And there is no change whatsoever to the release and require / import flow, right? |
For the release flow, There shouldn't be any from a user's perspective, though where |
once merged, we could try to release an alpha version to npm :) |
|
@allawesome497 Are you going to enable the test compilation too? |
| * | ||
| * @default 'sequelize' | ||
| */ | ||
| context?: string; |
Yep! just did. Tests now run with a require hook (transpiles imports to I also added a |
|
That last commit is a tribute to @tj: test.js -> test.[tj]s 😂👋 |
|
Nice stuff. I'd say let's release a new version of main, merge this guy and attempt another release afterwards. |
|
I guess you need to fix the merge conflicts |
185952e to
94493b7
Compare
|
🎉 This PR is included in version 6.12.0-alpha.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 6.12.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 6.12.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…equelize#13569) * refactor(typescript): add foundation for incremential TS migration Converts the logger interface to TypeScript. Adds eslint rules and TypeScript configuration to allow for a gradual migration to TS. Adds a build script to transpile both TS and JS code while keeping the same API for package usage. Changes imports from test files to use "absolute" paths that point to the directory of the compiled code. * use || instead of ?? * fix source maps breaking tests * fix build script for older versions of node * make some small fixes + add better docs to logger.ts * add ts support to tests * update yarn.lock * disable no-loss-of-percesion rule * fix & cleanup a lil * test.js -> test.[tj]s Co-authored-by: Sascha Depold <[email protected]>

Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Adds a foundation for a migration to TypeScript (not just .d.ts files). This is intended to be for a gradual migration, and getting this in sooner makes it easier to start converting files to TypeScript once we're ready.
The primary changes are:
.js,.js.map, and.d.tsfiles via esbuild and typescript.The following (dev) dependencies were added:
@types/debug- Types for the builtin debug package, used by the logger.@typescript-eslint/eslint-plugin- TypeScript plugin for eslint.@typescript-eslint/parser- TypeScript parser for eslint.copyfiles- Used inbuild.jsto copy type declaration files fromtypes/todist/.esbuild- Used inbuild.jsto transpile the sequelize source code into minified code.fast-glob- Used inbuild.jsto locate files that need to be copied / transpiled.module-alias- Used for testing to alias imports tosequelize/to thedistdirectory.Additionally, the
strictrule which requireduse strictat the start of every file was removed. This is because esbuild will add this in the transpiled files, so it doesn't make sense to require it anymore.As for why I went with esbuild - 2 primary reasons:
Note that this does not add support for
.test.tsfiles yet - I wanted to limit the complexity of this PR, so I opted to leave that out of this one. I'll put up a PR with that if this gets approved.