If your users want the benefits of TypeScript, such as a better IDE experience and fewer bugs, they will need to install TypeScript as a dev dependency and make a few additional tweaks to their project. It isn’t hard but it takes some time.
Rather than passing an untyped object to a function as your users do today, they would instead:
1. Create a generic object (e.g. via JSON.parse)
2. Invoke a validator which returns a typed value
3. Use the validator’s output
Ideally, the types that you pained to declare in TypeScript would be reusable when defining validation schemas. However, there’s a difference between document structure and type definitions. Documents have top-level structures that don’t exist in the type system. For example, JSON can represent an array of objects. Also, because type definitions can change, it is sometimes necessary to read old documents into new type definitions. Therefore, declaring separate schemas may be simply unavoidable.