Validate Manually Created Typescript Definition Files
Asked Answered
J

0

9

Background

I have created a component library using react (plain js). I am in the process of creating Typescript definitions for the components so that consumers of the component library can use the components in a type-safe manner in their Typescript applications.

Question

What is the recommended way, if there is one, to check that the definitions manually created are correct? I am trying to catch issues before consumers have to highlighting any problems.

Investigation so far...

I have looked at https://github.com/asgerf/tscheck but it doesn't always work.

I also looked at DefinitelyTyped contribution guide: https://github.com/DefinitelyTyped/DefinitelyTyped#create-a-new-package. This says to create a typescript file with sample code for type-checking only...is this just a matter of compiling the *.test.ts file with the typescript compiler?

Jarv answered 7/3, 2018 at 11:18 Comment(3)
TypeScript code (like any other code) will be "correct" once there are no compile errors - so is your question about how to write correct .d.ts files?Gradin
I recently came across this paper which discusses this topic. Maybe it's useful to you.Megara
In a way... more along the lines of " I have written a .d.ts file I believe to be correct. Is there a way to confirm that what I think is correct is in fact correct...From your answer it appears that I need to write some typescript that uses the definitionsJarv

© 2022 - 2024 — McMap. All rights reserved.