CASSNODEJS-10: Proposal for TypeScript Migration#463
Open
SiyaoIsHiding wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new design proposal for migrating the Cassandra Node.js driver to TypeScript, ES6 classes, and ESM while preserving backward compatibility.
Changes:
- Adds rationale for TypeScript migration and generated declarations.
- Describes ES6 class and ESM migration benefits.
- Outlines backward-compatibility approaches for namespaces, CommonJS imports, and static factory misuse.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| 2\. ES Modules – ESM is now the official JavaScript module standard, and the ecosystem has largely settled on it. Supporting it opens the driver to tree-shaking and modern bundler workflows, bringing performance gain. | ||
|
|
||
| 3\. ES6 classes – The driver's class style is split across ES5 and ES6 conventions. ES5 class is deprecated by Node.js, and is not recognized by modern tools like IDE intellisense. |
|
|
||
| ## 6.2 Default Export vs. Named Export | ||
|
|
||
| The driver currently uses a default export, while the TypeScript ecosystem has standardized on named exports. To support both styles during the transition, each submodule's `index.ts` must export its public API twice, once as named exports and once as the default object: |
|
|
||
| # 7\. Conclusion | ||
|
|
||
| The cassandra-driver already pays the cost of manually maintained declaration files. This migration will eliminate such cost while deliver the full benefit while maintaing backward compatibility: |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
|
||
| # 1\. Type Safety: Catching a Class of Bugs Earlier | ||
|
|
||
| The driver pays the cost of types (someone writes index.d.ts) without the benefit (nothing checks it against the implementation). |
|
|
||
| 2\. ES Modules – ESM is now the official JavaScript module standard, and the ecosystem has largely settled on it. Supporting it opens the driver to tree-shaking and modern bundler workflows, bringing performance gain. | ||
|
|
||
| 3\. ES6 classes – The driver's class style is split across ES5 and ES6 conventions. ES5 class is deprecated by Node.js, and is not recognized by modern tools like IDE intellisense. |
|
|
||
| ## 6.2 Default Export vs. Named Export | ||
|
|
||
| The driver currently uses a default export, while the TypeScript ecosystem has standardized on named exports. To support both styles during the transition, each submodule's `index.ts` must export its public API twice, once as named exports and once as the default object: |
|
|
||
| # 7\. Conclusion | ||
|
|
||
| The cassandra-driver already pays the cost of manually maintained declaration files. This migration will eliminate such cost while deliver the full benefit while maintaing backward compatibility: |
|
|
||
| 1. A compiler that validates the implementation against its own types | ||
| 2. ESM support that brings significant performance gain | ||
| 3. IDE Intellisense that actually recognize our classes and types, providing better developer experience for maintainers and contributors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.