Property 'anime' does not exist on type 'JakanMisc'.
Closed this issue · 3 comments
Hey, it seems that most editors have a hard time figuring out the return type with this builder pattern.
You can circumvent this by specifying the client type in the withXXXX
methods, like this:
import { Jakan, JakanSearch } from "jakan"
const api = new Jakan().forSearch().withMemory<JakanSearch>()
...
Your editor should now understand that api
is of type JakanSearch
.
This also applies to withWebStorage
, withMemory
and withRedis
.
You can also import and use JakanUsers
and JakanMisc
as types.
I'm still trying to figure a way to make this detection automatic. If anyone has a good suggestion on how to achieve this (without having to use different methods for each builder type), please let me know :)
Just for a quick explanation:
I didn't want to, but i will need to change the API for the Jakan
class in 1.0.0
.
However, this will make it possible to avoid complex Typescript-only assertions.
This will only be available when 1.0.0
is out in the NPM registry. I still want to finish JakanMisc
#5 before this.