Skip to content

CASSNODEJS-10: Proposal for TypeScript Migration#463

Open
SiyaoIsHiding wants to merge 5 commits into
apache:trunkfrom
SiyaoIsHiding:proposal-ts
Open

CASSNODEJS-10: Proposal for TypeScript Migration#463
SiyaoIsHiding wants to merge 5 commits into
apache:trunkfrom
SiyaoIsHiding:proposal-ts

Conversation

@SiyaoIsHiding
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Comment thread proposals/TypeScript_Migration.md Outdated

## 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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.


# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants