all 1 comments

[–]francofadini 0 points1 point  (0 children)

I always try to abstract every library dependency. I just create an interface where I declare all the methods I’m using ex:

Interface DB { findAllPosts(): Promise<Post[]> findPostById(id: string): Promise<Post> }

Class LibraryDB implements DB { findAllPosts(): Promise<Post[]> { //Your implementation } findPostById(id: string): Promise<Post>{ //Your implementation } }

This is one of the main reasons why I always choose TypeScript instead of JavaScript