Is there any official Typescript definition for fabric.js?

Viewed 916

At the moment, I am able to find a Typescript definition for fabric.js in https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fabric (https://www.npmjs.com/package/@types/fabric). However, I am not sure if it is an official one. Does anyone know it?

On the other hand, the version of above definition is 1.5.27 whereas the latest version of fabric.js is 1.7.19. Does it mean the definition is out-dated? Does anyone know how to generate an updated definition for latest fabric.js?

Thanks.

1 Answers

Typically, packages in Definitely Typed aren't official type definitions. They are user contributed for the better typing of all: https://github.com/DefinitelyTyped/DefinitelyTyped#how-can-i-contribute.

If there were official type definitions, it would likely be in the library itself, in which case, you wouldn't need a separate file download.

From FabricJs's github: https://github.com/fabricjs/fabric.js/issues/4507#issuecomment-469191403

we do not have any. No one ever did them.

The Definitely Typed file is likely the best you are going to get right now. If there's anything wrong with the type definitions, you should be able to set up a .d.ts file that extends the type definitions that exist. Or just bring the definitely typed files into your project and modify them as needed to update it.

There are Definitely Typed versions for version 3.6.3 of fabricjs.

Related