-
Notifications
You must be signed in to change notification settings - Fork 0
JavaScript vs TypeScript Boundaries
The RDCP SDK project has multiple contexts where JavaScript vs TypeScript requirements differ. This causes confusion and must be clearly documented to avoid hours of unnecessary conversion work.
WARP and developers often try to convert documentation examples to TypeScript when they should stay as JavaScript examples. The implementation guide's JS examples are intentionally generic - they're meant to be copied into any project type.
Location | Reason | Examples |
---|---|---|
Package.json and build configs | Node.js runtime files expect JavaScript |
package.json , jest.config.js , rollup.config.js
|
Documentation examples | Maximum compatibility across project types |
docs/rdcp-implementation-guide.md examples |
Legacy integration examples | Show integration with existing JS codebases | Integration snippets in docs |
Configuration files | Node.js tooling standard | ESLint, Prettier, build tool configs |
Template code | Meant to be copied by users | Code snippets in documentation |
Location | Reason | Examples |
---|---|---|
SDK core implementation | Full type safety for protocol compliance | All files in src/ directory |
Protocol type definitions | RDCP request/response schemas |
src/utils/types.ts , interface definitions |
Framework adapters | Proper typing for Express/Next.js/Fastify | src/server/adapters/*.ts |
Public API surface | Anything users import needs typing |
src/index.ts , exported functions |
Authentication modules | Security requires type safety | src/auth/*.ts |
Hours were spent converting FROM JavaScript TO TypeScript for the SDK core implementation. This was necessary because:
- Type Safety for Protocol Compliance - RDCP has specific JSON schemas
- Developer Experience - SDK users need autocompletion and compile-time checking
- Multi-Framework Support - TypeScript provides consistent interfaces
- Enterprise Adoption - Static analysis aligns with enterprise standards
- Protocol Evolution - Easier to manage breaking changes with types
- Files in
src/
directory - Protocol implementations
- API interfaces
- Framework adapters
- Files in
docs/
directory - Files in
examples/
directory (if they're templates) - Configuration files (
*.config.js
) - Build scripts
- Package.json
- Example files: Keep as JS if they're templates, convert to TS if they're SDK demos
- Test files: Usually TS for SDK tests, JS for integration examples
Is the file in src/?
ββ Yes β Use TypeScript
ββ No β Is it a config/build file?
ββ Yes β Use JavaScript
ββ No β Is it documentation/template?
ββ Yes β Use JavaScript
ββ No β Consider project context
The RDCP spec itself is language-agnostic. The confusion comes from mixing:
- SDK development (needs TypeScript for type safety)
- Documentation examples (should stay JavaScript for broader compatibility)
// src/endpoints/discovery.ts
export function debugSystemDiscovery(req: Request, res: Response): void {
const tenantContext = extractTenantContext(req)
// ... typed implementation
}
// docs/examples/basic-integration.js
const rdcp = require('@rdcp/server')
app.use('/rdcp', rdcp.middleware())
// docs/examples/basic-integration.ts β DON'T DO THIS
import rdcp from '@rdcp/server' // Too specific, limits compatibility
Documentation examples are templates, not implementation code. They should remain in JavaScript for maximum compatibility across different project types.
Getting Started: Installation β’ Basic Usage β’ Authentication
Migration: From Manual Implementation β’ Framework Examples β’ Publishing Guide
Protocol: RDCP v1.0 Specification β’ Implementation Guide β’ API Reference
π Home | π¦ NPM Package | π GitHub | π Issues
RDCP SDK v1.0.0 - Runtime Debug Control Protocol implementation for JavaScript/Node.js applications
- Implementation-Status
- JavaScript-vs-TypeScript-Boundaries
- Core-Package-Boundaries
- Publishing-Setup
- Contributing
- API-Reference
- Protocol Specification
- Implementation Guide
- RDCP-Primitive-Types
- Protocol-Schemas
- Protocol-Error-Codes
- API-Reference
Version: 1.0.0
Protocol: RDCP v1.0
License: Apache-2.0