feat: add TypeScriptProgram class with runtime transpilation#214
Merged
feat: add TypeScriptProgram class with runtime transpilation#214
Conversation
…init leak Add TypeScriptProgram class that transpiles TypeScript to JavaScript at runtime using Node.js 24+'s built-in stripTypeScriptTypes() API with transform mode, supporting type stripping, enums, namespaces, and all standard TS features. All JavaScriptProgram methods are inherited via vparent. Fix memory leak in QoreV8ProgramData::deref() where tracked V8 resources (namespace data, class data, etc.) were not cleaned up when a constructor failed, because deleteIntern() was only called via the QPP destructor path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds TypeScript support to the v8 module by introducing a new TypeScriptProgram class that transpiles TypeScript to JavaScript at runtime. The PR includes a critical memory leak fix and comprehensive test coverage.
Changes:
- Added
TypeScriptProgramclass with runtime transpilation using Node.js 24+'s built-instripTypeScriptTypes()API in transform mode - Fixed memory leak in
QoreV8ProgramData::deref()where V8 resources weren't cleaned up on constructor failure - Version bumped to 2.1.0 with extensive documentation and 37 test cases covering TypeScript features, integration, and error handling
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/typescript.qtest | Comprehensive test suite with 37 test cases (134 assertions) covering TypeScript language features, Qore interop, copy/lifecycle, and error conditions |
| src/v8-module.cpp | Adds TypeScriptProgram class initialization to the V8 namespace |
| src/QoreV8Program.h | Adds new constructor with transpile_ts parameter and fixes deref() to call deleteIntern() for proper resource cleanup |
| src/QoreV8Program.cpp | Implements TypeScript transpilation logic using stripTypeScriptTypes() with transform mode, includes Node.js 24+ version check |
| src/QC_TypeScriptProgram.qpp | New class implementation with constructor, destructor, and copy method; inherits from JavaScriptProgram via vparent |
| src/QC_TypeScriptProgram.h | Header file defining TypeScriptProgram class ID and initialization function |
| src/QC_JavaScriptProgram.h | Updates copyright year to 2024-2026 |
| docs/mainpage.dox.tmpl | Extensive documentation covering TypeScript support, requirements, supported features, examples, and Qore interop |
| CMakeLists.txt | Version bump to 2.1.0 and adds QC_TypeScriptProgram.qpp to build configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address PR review feedback: - Add memory leak fix entry to v8 2.1 release notes - Fix interface inheritance doc example to use Animal/Dog hierarchy instead of semantically incorrect Dog extends Person Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
TypeScriptProgramclass that transpiles TypeScript to JavaScript at runtime using Node.js 24+'s built-instripTypeScriptTypes()API (transformmode), supporting type stripping, enums, namespaces, typed classes, generics, and all standard TS featuresJavaScriptProgrammethods inherited viavparent(getGlobal, setSaveReferenceCallback, spinOnce, spinEventLoop, copy)QoreV8ProgramData::deref()where tracked V8 resources (namespace data, class data, etc.) were not cleaned up when a constructor failed, becausedeleteIntern()was only called via the QPP destructor pathTest plan
🤖 Generated with Claude Code