You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems the TypeScript return type definition for getAll() is not quite right.
Description
If I do something like:
constapiClient=newExampleApiClient()// some class that extends EntityApiClient<TEntity, T> (e.g. ExampleApiClient<ExampleEntity, string>)constapiData=ref<PagedList<ExampleEntity>>(newPagedList<ExampleEntity>());//... later on in <script setup>onMounted(async()=>{apiData.value=awaitapiClient.getAll();// error: Types of property "data" are incompatible. ts(2322)});
After digging, I inspected the actual result of the API call:
constapiClient=newExampleApiClient()// some class that extends EntityApiClient<TEntity, T> (e.g. ExampleApiClient<ExampleEntity, string>)constapiResponse=awaitapiClient.getAll();// getAll() returns a Promise<PagedList<string>>, according to TSdebugger;// value of apiResponse is actually PagedList<ExampleEntity> when this line is hit at runtime
So it appears that this bug doesn't cause any issues at runtime but it causes a TypeScript type check error (that will probably fail CI)
Expected Behavior
The return type of getAll() should be Promise<PagedList<TEntity>>, like the other methods in the class
Actual Behavior
The return type of getAll() is Promise<PagedList<T>>, where T is the type of the ID of the "entity"
Possible Fix
Change the return type - at runtime we don't see any issue, but we get a TS compiler error
Steps to Reproduce
See description for example code
Context
I was trying to get all entities without paging and came across this error
Your Environment
Environment name and version: Chrome 117, nodejs v20.7.0
Operating System and version: Windows 10 Pro 22H2 19045.3448
TypeScript version: 4.9.5
The text was updated successfully, but these errors were encountered:
It seems the TypeScript return type definition for
getAll()
is not quite right.Description
If I do something like:
After digging, I inspected the actual result of the API call:
So it appears that this bug doesn't cause any issues at runtime but it causes a TypeScript type check error (that will probably fail CI)
Expected Behavior
The return type of
getAll()
should bePromise<PagedList<TEntity>>
, like the other methods in the classActual Behavior
The return type of
getAll()
isPromise<PagedList<T>>
, whereT
is the type of the ID of the "entity"Possible Fix
Change the return type - at runtime we don't see any issue, but we get a TS compiler error
Steps to Reproduce
See description for example code
Context
I was trying to get all entities without paging and came across this error
Your Environment
The text was updated successfully, but these errors were encountered: