-
-
Notifications
You must be signed in to change notification settings - Fork 184
refactor: migrate server-api package to TypeScript strict mode #2273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dirkwa
wants to merge
3
commits into
SignalK:master
Choose a base branch
from
dirkwa:ts-strict-server-api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
69b18d3 to
191f0b5
Compare
Member
|
This is misleading: Breaking Changes None - you tighten the types, code that used to work may very well break. |
tkurki
reviewed
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Enable TypeScript strict mode in
packages/server-apiand replaceanytypes withunknownor 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 returnunknowninstead ofany- requires type validation before usePropertyValue.valueis nowunknown- requires runtime type checkingSourceRef(string-based)These changes make implicit assumptions explicit through the type system without changing runtime behavior.
Changes
TypeScript Configuration
@tsconfig/node20to@tsconfig/node22strict,noImplicitAny,strictNullChecks,noUncheckedIndexedAccess,noUnusedLocals,noUnusedParametersType Improvements
getSelfPath()/getPath(): returnunknowninstead ofany(Signal K data model is dynamic and requires runtime validation)PropertyValue.value:unknowninstead ofanyResourcesApi: useRecord<string, unknown>for query params and resource dataRadarApi: useunknownfor dynamic control valuesSourcetype: keep as simpleanytype (maintainer prefers deprecatingSourcein favor ofSourceRef)@deprecatedmarkers tosourcefields, guiding developers toward$source(SourceRef)DataRow: use[Timestamp, ...unknown[]]to accommodate object values likenavigation.positionisRadarProvider,isWeatherProvider) with properunknownparameter typesdebug()method: intentionally usesanyfor unrestricted logging inputDocumentation
/signalk/v2/api/vessels/self/radars(returnsRadarInfo[], notstring[])Code Quality
voidoperator to satisfynoUnusedLocalswithout polluting public API