Skip to content

Fix TypeScript Build Errors in Node-Renderer Package #2104

@justin808

Description

@justin808

Summary

The packages/react-on-rails-pro-node-renderer package has pre-existing TypeScript build errors that prevent it from building and being published via yalc.

Status: Blocks full yalc workflow for all 3 workspace packages

Background

PR #2069 successfully moved the node-renderer package to the workspace structure, but the package has TypeScript errors that existed before the move. These errors prevent:

  • yarn workspace react-on-rails-pro-node-renderer run build - fails
  • yarn yalc:publish - fails for node-renderer package
  • yarn workspace react-on-rails run build - works
  • yarn workspace react-on-rails-pro run build - works

TypeScript Errors to Fix

1. Missing .js Extensions in ESM Imports (~30+ files)

TypeScript ESM requires .js extensions in relative imports:

// ❌ Current
import { foo } from './bar'

// ✅ Required
import { foo } from './bar.js'

Files affected: Most source files in packages/react-on-rails-pro-node-renderer/src/

2. Missing Type Declarations

Need to install missing dependencies:

  • @types/fastify - for Fastify types
  • @sentry/node - Sentry Node.js SDK (if not installed)
  • @honeybadger-io/js - Honeybadger error reporting (if not installed)

Update package.json:

{
  "dependencies": {
    "@sentry/node": "^x.x.x",
    "@honeybadger-io/js": "^x.x.x"
  },
  "devDependencies": {
    "@types/fastify": "^x.x.x"
  }
}

3. Module Export Format Issues

Some files use CommonJS export = which doesn't work with ESM:

// ❌ Current (CommonJS)
export = MyFunction;

// ✅ Required (ESM)
export default MyFunction;

4. Implicit Any Types

Various parameters lack type annotations. Add proper TypeScript types where needed.

Tasks

  • Add .js extensions to all relative imports

    • Run search/replace: from './([^']+)'from './$1.js'
    • Run search/replace: from "../([^"]+)"from "../$1.js"
    • Verify no broken imports
  • Install missing dependencies

    • Add @types/fastify to devDependencies
    • Add @sentry/node if missing
    • Add @honeybadger-io/js if missing
    • Run yarn install
  • Convert export = to export default

    • Find all export = statements
    • Convert to export default
    • Update corresponding imports
  • Add type annotations for implicit any

    • Run yarn workspace react-on-rails-pro-node-renderer run type-check
    • Add types for flagged parameters
    • Ensure strict TypeScript compliance
  • Update tsconfig.json if needed

    • Verify ESM compatibility settings
    • Ensure module: "ES2020" or similar
    • Check moduleResolution: "node16" or "bundler"
  • Verify build passes

    • yarn workspace react-on-rails-pro-node-renderer run build
    • Check packages/react-on-rails-pro-node-renderer/lib/ for output
  • Verify tests pass

    • yarn workspace react-on-rails-pro-node-renderer run test
  • Verify yalc publish works

    • yarn run yalc:publish
    • Should publish all 3 packages successfully

Testing

# Clean build
rm -rf packages/react-on-rails-pro-node-renderer/lib
yarn workspace react-on-rails-pro-node-renderer run build

# Type check
yarn workspace react-on-rails-pro-node-renderer run type-check

# Run tests
yarn workspace react-on-rails-pro-node-renderer run test

# Test yalc publish
yarn run yalc:publish

Success Criteria

  • yarn workspace react-on-rails-pro-node-renderer run build succeeds
  • No TypeScript errors
  • All tests pass
  • yarn yalc:publish publishes all 3 packages

Related

Priority

High - Blocks local development workflow with yalc

Estimated Effort

4-6 hours (bulk find/replace + dependency updates + testing)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions