feat: Add TypeScript types for abstract store providers#1395
Merged
JamieMagee merged 1 commit intomasterfrom Jan 17, 2026
Merged
feat: Add TypeScript types for abstract store providers#1395JamieMagee merged 1 commit intomasterfrom
JamieMagee merged 1 commit intomasterfrom
Conversation
9cde083 to
90e414a
Compare
Base automatically changed from
jamiemagee/typescript-batch1-lib-types
to
master
January 16, 2026 23:57
…rtial Batch 3)
Add type definitions and JSDoc annotations for the provider infrastructure
and abstract store base classes as part of the ongoing TypeScript migration.
## JavaScript code changes required for type safety:
### abstractFileStore.js
- Add \`.toString()\` when parsing \`fs.readFile\` results in \`list()\`, \`get()\`,
and \`find()\` methods. TypeScript's Buffer type is not directly assignable
to \`JSON.parse()\` which expects a string parameter.
- Cast caught errors to \`NodeJS.ErrnoException\` type to safely access the
\`.code\` property (e.g., checking for 'ENOENT').
- Add \`@ts-ignore\` for the JSON schema import which has no type declarations.
### abstractAzblobStore.js
- Cast caught errors to \`{statusCode?: number}\` to safely access the
\`.statusCode\` property for Azure error handling.
- Add \`@ts-ignore\` comments for azure-storage \`promisify\` calls which expect
4 arguments instead of the standard 3-argument signature.
### abstractMongoDefinitionStore.js
- Wrap score parameters with \`String()\` before \`parseInt()\` calls in
\`buildQuery()\`. TypeScript correctly identifies that these parameters
could already be numbers, making direct \`parseInt()\` calls invalid.
- Cast the \`error\` parameter to \`Error\` in the retry handler to access
\`.message\` property safely.
- Add \`@ts-ignore\` for MongoDB \`sort\` parameter - the mongodb driver's
\`Sort\` type is stricter than our \`Record<string, number>\` representation,
but they are functionally equivalent.
- Rename unused parameters with underscore prefix (e.g., \`coordinates\` to
\`_coordinates\`) per TypeScript/ESLint conventions for abstract methods.
## Files added
- providers/index.d.ts
- providers/stores/abstractFileStore.d.ts
- providers/stores/abstractAzblobStore.d.ts
- providers/stores/abstractMongoDefinitionStore.d.ts
## Files modified
- providers/logging/logger.d.ts (fixed Logger type import)
- tsconfig.json (added new files to include list)
7bb32bb to
d333af8
Compare
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
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
This PR continues the TypeScript migration by adding type definitions for the provider infrastructure and abstract store base classes. This required several JavaScript code changes and workarounds to satisfy TypeScript's type checker.
JavaScript Code Changes
abstractFileStore.js
Buffer to string conversion: Added
.toString()when parsingfs.readFileresults inlist(),get(), andfind()methods. TypeScript'sBuffertype is not directly assignable toJSON.parse()which expects a string parameter.Error type casting: Cast caught errors to
NodeJS.ErrnoExceptiontype to safely access the.codeproperty (e.g., checking for'ENOENT').Schema import: Added
@ts-ignorefor the JSON schema import (schemas/definition-1.0) which has no type declarations.abstractAzblobStore.js
Azure error handling: Cast caught errors to
{statusCode?: number}to safely access the.statusCodeproperty for Azure-specific error handling.Azure storage promisify: Added
@ts-ignorecomments for azure-storagepromisifycalls. The azure-storage library's callback signatures expect 4 arguments instead of the standard 3-argument signature that Node'spromisifyexpects.abstractMongoDefinitionStore.js
parseInt type safety: Wrapped score parameters with
String()beforeparseInt()calls inbuildQuery(). TypeScript correctly identifies that these parameters could already be numbers, making directparseInt()calls invalid.Error message access: Cast the
errorparameter toErrorin the retry handler to access.messageproperty safely.MongoDB sort compatibility: Added
@ts-ignorefor MongoDBsortparameter. The mongodb driver'sSorttype is stricter than ourRecord<string, number>representation, but they are functionally equivalent at runtime.Unused parameter naming: Renamed unused parameters with underscore prefix (e.g.,
coordinatesto_coordinates) per TypeScript/ESLint conventions for abstract method signatures.providers/logging/logger.d.ts
Loggertype import path to correctly reference the logging module types.