Skip to content

Conversation

@dirkwa
Copy link
Contributor

@dirkwa dirkwa commented Jan 18, 2026

Summary

Enable TypeScript strict mode in packages/server-api and replace any types with unknown or properly typed interfaces. This is the first package in the strict mode migration effort.

Breaking Changes

Type-level breaking changes for TypeScript consumers:

This PR tightens type definitions which may cause compilation errors in existing TypeScript code that made unsafe type assumptions. While runtime behavior is unchanged and JavaScript plugins work exactly as before, TypeScript consumers may need to add type guards or assertions.

Examples:

  • getSelfPath() / getPath() now return unknown instead of any - requires type validation before use
  • PropertyValue.value is now unknown - requires runtime type checking
  • Source fields are deprecated in favor of SourceRef (string-based)

These changes make implicit assumptions explicit through the type system without changing runtime behavior.

Changes

TypeScript Configuration

  • Upgrade from @tsconfig/node20 to @tsconfig/node22
  • Enable strict mode settings: strict, noImplicitAny, strictNullChecks, noUncheckedIndexedAccess, noUnusedLocals, noUnusedParameters

Type Improvements

  • getSelfPath() / getPath(): return unknown instead of any (Signal K data model is dynamic and requires runtime validation)
  • PropertyValue.value: unknown instead of any
  • ResourcesApi: use Record<string, unknown> for query params and resource data
  • RadarApi: use unknown for dynamic control values
  • Source type: keep as simple any type (maintainer prefers deprecating Source in favor of SourceRef)
  • Add @deprecated markers to source fields, guiding developers toward $source (SourceRef)
  • DataRow: use [Timestamp, ...unknown[]] to accommodate object values like navigation.position
  • Improve type guards (isRadarProvider, isWeatherProvider) with proper unknown parameter types
  • debug() method: intentionally uses any for unrestricted logging input

Documentation

  • Update radar_api.md to reflect correct response format for /signalk/v2/api/vessels/self/radars (returns RadarInfo[], not string[])
  • Update type examples in radar API docs to match source code
  • Fix PUT method documentation to clarify they "call the PUT handler" rather than "update values"
  • Fix ActionHandler documentation to specify "path specified in the PUT request"

Code Quality

  • Remove exported type-check variables, use void operator to satisfy noUnusedLocals without polluting public API
  • Revert mmsi/mid.ts to original reduce pattern with inline destructuring

Enable explicit strict settings in packages/server-api and replace
`any` types with `unknown` or proper typed interfaces throughout.

Changes:
- Upgrade @tsconfig/node20 to @tsconfig/node22
- Add explicit strict, noImplicitAny, strictNullChecks, and
  noUncheckedIndexedAccess to server-api tsconfig
- Replace `any` with `unknown` for dynamic Signal K data model paths
  (getSelfPath, getPath, putSelfPath, putPath)
- Add Source interface based on Signal K specification
- Change PropertyValue.value from any to unknown
- Update ResourcesApi to use Record<string, unknown>
- Update RadarApi control types to use unknown
- Improve type guards with proper unknown parameter types
- Fix noUncheckedIndexedAccess errors in mmsi/mid.ts
- Update radar_api.md documentation to match type changes
Add stricter TypeScript settings to catch unused code:
- noUnusedLocals: true
- noUnusedParameters: true

Fix unused variable errors by exporting type-check examples
with @ignore JSDoc to exclude from documentation while
satisfying the compiler.
@tkurki
Copy link
Member

tkurki commented Jan 22, 2026

This is misleading: Breaking Changes None - you tighten the types, code that used to work may very well break.

@tkurki tkurki added the feature label Jan 22, 2026
…sion

Changes:
- Remove exported type-check variables (_typeCheckMetaDelta, _typeCheckValuesDelta, _typeCheckCombinedDelta, _exampleValuesResponse) and use void operator instead to satisfy noUnusedLocals without polluting the public API
- Revert Source type to simple 'any' definition, removing the comprehensive interface per maintainer preference to deprecate Source in favor of SourceRef
- Add @deprecated markers to source fields in Update and NormalizedBaseDelta types to guide developers toward using $source (SourceRef)
- Change DataRow type from restrictive primitives-only to [Timestamp, ...unknown[]] to accommodate object values like navigation.position
- Revert debug() method signature to use 'any' instead of 'unknown' - this is the semantically correct type for unrestricted logging that doesn't constrain input
- Revert mmsi/mid.ts reduce pattern to original inline destructuring with blank element
- Fix PUT method documentation to clarify they "call the PUT handler" rather than "update values"
- Fix ActionHandler documentation to specify "path specified in the PUT request" rather than "path being updated"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants