Skip to content

Comments

feat: add TypeScriptProgram class with runtime transpilation#214

Merged
davidnich merged 2 commits intodevelopfrom
feature/qore_typescript_support
Feb 13, 2026
Merged

feat: add TypeScriptProgram class with runtime transpilation#214
davidnich merged 2 commits intodevelopfrom
feature/qore_typescript_support

Conversation

@davidnich
Copy link
Member

Summary

  • Add TypeScriptProgram class that transpiles TypeScript to JavaScript at runtime using Node.js 24+'s built-in stripTypeScriptTypes() API (transform mode), supporting type stripping, enums, namespaces, typed classes, generics, and all standard TS features
  • All JavaScriptProgram methods inherited via vparent (getGlobal, setSaveReferenceCallback, spinOnce, spinEventLoop, copy)
  • 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
  • Comprehensive documentation with subsections for supported TS features, Qore interop, async/await, requirements, and examples
  • Version bumped to 2.1.0

Test plan

  • 37 TypeScript test cases pass (134 assertions) covering language features, integration, copy/lifecycle, errors, and feature boundary validation
  • v8.qtest regression: 7/7 tests (113 assertions)
  • v8-qore-import.qtest regression: 23/23 tests (158 assertions)
  • Valgrind clean (0 definitely lost) across all three test suites — confirms the init leak fix

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings February 13, 2026 10:43
Copy link
Contributor

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 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 TypeScriptProgram class with runtime transpilation using Node.js 24+'s built-in stripTypeScriptTypes() 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>
@davidnich davidnich merged commit 7b43d53 into develop Feb 13, 2026
1 of 2 checks passed
@davidnich davidnich deleted the feature/qore_typescript_support branch February 13, 2026 11:06
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.

1 participant