rollbar.js icon indicating copy to clipboard operation
rollbar.js copied to clipboard

Add TypeScript support

Open matux opened this issue 8 months ago • 0 comments

$ npm run test_ci

> [email protected] test_ci
> ./node_modules/.bin/grunt test

Running "test-server" task

Running "vows:all" (vows) task
/Users/matux/code/rollbar/rollbar-js/src/utility/replace.ts:10
export default function replace(
^^^^^^

SyntaxError: Unexpected token 'export'
    at wrapSafe (node:internal/modules/cjs/loader:1378:20)
    at Module._compile (node:internal/modules/cjs/loader:1428:41)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/matux/code/rollbar/rollbar-js/src/server/telemetry.js:4:15)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)

Node.js v20.18.0
Warning: Task "vows:all" failed. Use --force to continue.

Aborted due to warnings.

Description of the change

This PR implements TypeScript support with minimal codebase changes to enable a mixed JS/TS environment.

  • Add @babel/preset-typescript and related dependencies
  • Configure webpack to process .ts files alongside .js files
  • Create tsconfig.json with appropriate settings for mixed JS/TS environment
  • Add TypeScript examples to demonstrate usage patterns
  • Update documentation in CLAUDE.md with TypeScript guidelines

Type of change

  • [ ] Bug fix (non-breaking change that fixes an issue)
  • [x] New feature (non-breaking change that adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [x] Maintenance
  • [ ] New release

Related

Checklists

Development

  • [x] Lint rules pass locally
  • [x] The code changed/added as part of this pull request has been covered with tests
  • [x] All tests related to the changed code pass in development

Code review

  • [x] This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • [x] Issue from task tracker has a link to this pull request
  • [ ] Changes have been reviewed by at least one other engineer

matux avatar Apr 14 '25 21:04 matux