What to put in the package.json types field for typescript based libs

I'm a bit confused about how best to develop multiple typescript modules in parallel with code navigation and still publish the correct path. So what should I put in the package.json "types" field?

According to: Typescriptlang.org/publishing.html

I should put a link to my generated index.d.ts as follows:

 { "name": "awesome", "author": "Vandelay Industries", "version": "1.0.0", "main": "./lib/main.js", "types": "./lib/main.d.ts" } 

If I then create a parallel module that depends on this using the npm link , navigating code like vscode, for example, allows me to simply go to this definition file. This is not what I want.

I want to go to the source file in order to be able to edit the folder in parallel. No tsconfig configuration with source cards, built-in or not helping in this regard. Maybe I missed something. The only way I decided that my workflow works decently is to actually point to the source main.ts file:

 { "name": "awesome", "author": "Vandelay Industries", "version": "1.0.0", "main": "./lib/main.js", "types": "./src/main.ts" } 

What, however, will break something when published correctly?

At least if I put src under .npmignore. I don't understand a better way to have a good workflow with multiple typescript modules.

I mean, I would not want to cripple package.json as part of the release process ...?

+5
source share

Source: https://habr.com/ru/post/1275545/


All Articles