0
votes

I'm writing a .d.ts file that will be shipped with an existing JavaScript library that doesn't use the TypeScript compiler or contain any TypeScript code. Do I need to add a tsconfig.json to the library to support how the .d.ts file will be interpreted by clients who import these types from the library?

Or is it enough to simply add an index.d.ts file to the library's build output and reference it in package.json's types?

Note that this is not for DefinitelyTyped. It's for including types in an existing library's npm package.

1

1 Answers

1
votes

No, the settings that tsconfig.json specifies only make sense in the context of compiling Typescript.

As the handbook puts it:

The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.

If the script is written in JS, then there's no compilation to be done, and simply writing definitions for the script in a d.ts file will be sufficient.