The findById method in BaseFirestoreRepository is expected to return Promise<T | null>. However, the generated TypeScript declaration file shows Promise<T>, losing the benefit of type safety. This issue is likely due to strictNullChecks being set to false. Enabling strictNullChecks and fixing the resulting errors will improve type safety throughout the library.
Steps to Reproduce
Check the findById method in BaseFirestoreRepository.
Observe that it is expected to return Promise<T | null>.
Build the library and check the generated declaration file.
Notice that the return type is Promise<T> instead of Promise<T | null>.
Expected Behavior
The findById method should correctly reflect Promise<T | null> in the generated declaration file, ensuring proper type safety.
Actual Behavior
The findById method's return type is Promise<T> in the generated declaration file, losing the benefit of type safety.
Acceptance Criteria
Enable strictNullChecks in the TypeScript configuration.
Fix any resulting errors to ensure the library builds successfully.
Ensure the correct return types are reflected in the generated declaration files.
Additional Context
March 18, 2022: Initial issue raised about the incorrect return type in the generated declaration file.
April 7, 2022: Acknowledgment of the issue and the need for help to fix it.
Proposed API Changes
Enable strictNullChecks:
Update the tsconfig.json file to enable strictNullChecks.
Description
The
findById
method inBaseFirestoreRepository
is expected to returnPromise<T | null>
. However, the generated TypeScript declaration file showsPromise<T>
, losing the benefit of type safety. This issue is likely due tostrictNullChecks
being set tofalse
. EnablingstrictNullChecks
and fixing the resulting errors will improve type safety throughout the library.Steps to Reproduce
findById
method inBaseFirestoreRepository
.Promise<T | null>
.Promise<T>
instead ofPromise<T | null>
.Expected Behavior
The
findById
method should correctly reflectPromise<T | null>
in the generated declaration file, ensuring proper type safety.Actual Behavior
The
findById
method's return type isPromise<T>
in the generated declaration file, losing the benefit of type safety.Acceptance Criteria
strictNullChecks
in the TypeScript configuration.Additional Context
Proposed API Changes
Enable strictNullChecks:
tsconfig.json
file to enablestrictNullChecks
.Fix Resulting Errors:
strictNullChecks
to ensure the library builds successfully.Validate Return Types:
Unit Tests:
Example Implementation
Original Issue