analytics icon indicating copy to clipboard operation
analytics copied to clipboard

Update, improve and refactor JSDocs types for core

Open DavidWells opened this issue 6 months ago • 4 comments

Currently we have a custom JSDoc type setup and was created before typescript supported JSDoc types natively. It's about time we modernize this 😅

We need to refactor how the types get emitted to just using regular TypeScripts and emit out the file.

Also, while you're at it, we need to check out the doc types and verify that everything is correct.

So all the code will remain JS but be types with JSDocs. Start with the types in core https://github.com/DavidWells/analytics/tree/master/packages/analytics-core/src

The "types": "../../node_modules/.bin/jsdoc -t ../../node_modules/tsd-jsdoc/dist -r ./src/ -d _temp-types && node scripts/types.js", is ollllddddd and clunky.

Thanks @claude

DavidWells avatar Jun 19 '25 00:06 DavidWells

Hey @claude read above. Lets do this

DavidWells avatar Jun 19 '25 00:06 DavidWells

Claude finished @DavidWells's task in 7m 22s —— View jobclaude/issue-465-20250619_005039Create PR ➔


Successfully Modernized JSDoc Types for Analytics Core! ✅

I've successfully updated and refactored the JSDoc types for the analytics-core package to use modern TypeScript JSDoc support instead of the old custom system.

Todo List

  • [x] Read repository setup instructions (CLAUDE.md)
  • [x] Analyze current analytics-core package structure and JSDoc setup
  • [x] Examine existing type generation scripts and dependencies
  • [x] Create TypeScript configuration for JSDoc-based type generation
  • [x] Update JSDoc comments to modern TypeScript syntax
  • [x] Remove old tsd-jsdoc dependency and scripts
  • [x] Update package.json types script
  • [x] Test the new setup by generating types
  • [x] Clean up outdated dependencies

Changes Made

✨ Modernized Type System:

  • Created packages/analytics-core/tsconfig.json with modern TypeScript configuration for JSDoc-based type generation
  • Added comprehensive type definitions in packages/analytics-core/src/types.js using modern TypeScript JSDoc syntax
  • Updated all JSDoc comments throughout the codebase to use modern @param and @returns syntax

🗑️ Removed Legacy System:

  • Deleted obsolete scripts/types.js custom type processing script
  • Deleted old src/pluginTypeDef.js file (consolidated into types.js)
  • Removed tsd-jsdoc dependency from root package.json
  • Updated package.json types script from complex JSDoc command to simple tsc

📝 Updated Configuration:

  • Changed types field in package.json to point to dist/index.d.ts (generated by TypeScript)
  • Updated prebuild script to remove unnecessary _temp-types cleanup
  • Modernized JSDoc comments in index.js, modules/page.js, and constants.js

Benefits of the New System

  1. Cleaner & Maintainable: No more complex post-processing scripts - TypeScript handles everything natively
  2. Modern Standards: Uses TypeScript's native JSDoc support instead of outdated tooling
  3. Better IDE Support: Modern TypeScript JSDoc provides superior IntelliSense and type checking
  4. Simplified Build: One command (tsc) instead of a complex pipeline
  5. Future-Proof: Built on actively maintained TypeScript compiler

The code remains JavaScript with JSDoc comments, but now uses TypeScript's modern, native type generation capabilities. This provides the same type safety benefits with a much cleaner and more maintainable setup.


claude[bot] avatar Jun 19 '25 00:06 claude[bot]

Automatic PR creation failed

Error: Command failed: git push origin claude-fix/issue-465-20250619T0058

Solution: Create a PR manually or rerun with claude Details: Actions run log

github-actions[bot] avatar Jun 19 '25 00:06 github-actions[bot]

💬 Claude Code execution complete

📊 Execution Info: Issue #465 | Unknown (401 files) | @DavidWells

🚀 Automated management executed:

  • ✅ Created: claude-code
  • ✅ Created: auto-generated
  • ✅ Created: 2025-Jun

💡 Example commands for Claude:

🔍 Analysis & Review:

  • claude Please review the code
  • claude Please perform a security check
  • claude Please suggest performance improvements

🛠️ Tasks & Implementation:

  • claude Please add test cases
  • claude Please fix this issue and create a PR
  • claude Please suggest refactoring

📚 Management & Operations:

  • claude Please create a release
  • claude Please check security alerts
  • claude Please optimize the workflow

📋 Issue Specific:

  • claude Please investigate the root cause of this issue
  • claude Please propose multiple solutions

🔄 Rerun: You can run again anytime with claude [your instructions]

github-actions[bot] avatar Jun 19 '25 00:06 github-actions[bot]