etienne-martin/device-detector-js

typings

WuglyakBolgoink opened this issue · 3 comments

Hallo!

I think, typings folder should contain only *.d.tsfiles and not any js files

image

Same is for utils and parsers folder...

And I think, it will be better to have only one file ./types/index.d.ts, which contain all public interfaces.

type-only files cannot be written as *.d.ts as they will not be emitted by the typescript compiler.

The .d.ts files you use are an input to the build system but not an output. It's perfectly reasonable to consume some types from a .d.ts but have your output not use those types, so there'd be no reason to distribute the input .d.ts with your build results. [...] It sounds like you'll want a post-build step in your build tool to copy the relevant .d.ts files wherever you need them.

The .d.ts files are considered "references" the compiler will not touch them, not move them, or recreate them. An easy way to think of the .d.ts files is that they go along with your .js files. if you are copying the .js files, you should copy the matching .d.ts.

As for having a single type file, these are auto-generated by the tsc compiler based on the structure of the actual source code. This should have no impact on how people consume this library.

What advantages do you see in having a single file for typings?

@etienne-martin

single file like a https://github.com/apache/cordova-plugin-file/tree/master/types.

if you think, that this is not necessary, then you can close the issue.

Ok thanks for the answer.

In the example you gave me, the project is written in javascript and the types are maintained manually and they decided to go with a single .d.ts file.

This is not really possible to do that in this library without introducing additional complexity.