For adding type definitions for a js library, the first step is to find the source code of the library.
Try to find the file that imports the js script of the library. For example PencilCodeEmbed is imported by the pencilcode.html file.
Create a file which will contain the type definitions in the typings directory with name library-name-defs.d.ts
.
For writing custom definitions, existing type definitions in DefinitelyTyped and this guide can be used as a reference.
The type checks run with the typescript tests. So you can run the following command to see if the definitions you wrote are correct:
python -m scripts.run_typescript_checks
-
Look for the difference in the code of the library compared to the present version.
-
Update the type definitions accordingly if the arguments or return types are modified or some new functions or variables are defined.
Refer this doc for detailed instructions & example.