1.

How Would You Define Custom Typings To Avoid Editor Warnings?

Answer»

Well, in most of the CASES, the 3RD party library comes with its own .d.ts file for its type definition. In some cases, we need to extend the existing type by PROVIDING some more properties to it or if we need to define additional types to avoid Typescript warning.

If we need to extend the type definition for external library, as a good PRACTICE, we should not touch the node_modules or existing typings folder. We can create a new folder, say “custom-typings” and keep all customized type definition in that.

To define typings for application (JavaScript/Typescript) objects, we should define interfaces and entity classes in models folder in the respective module of the application.

For those cases, we can define or extend the types by creating our own “.d.ts” file.

Well, in most of the cases, the 3rd party library comes with its own .d.ts file for its type definition. In some cases, we need to extend the existing type by providing some more properties to it or if we need to define additional types to avoid Typescript warning.

If we need to extend the type definition for external library, as a good practice, we should not touch the node_modules or existing typings folder. We can create a new folder, say “custom-typings” and keep all customized type definition in that.

To define typings for application (JavaScript/Typescript) objects, we should define interfaces and entity classes in models folder in the respective module of the application.

For those cases, we can define or extend the types by creating our own “.d.ts” file.



Discussion

No Comment Found