-
Notifications
You must be signed in to change notification settings - Fork 262
A reusable library with a global dependency won't install #620
Comments
Global dependency need to be install manually by the user |
Is it possible then to change my dependency to become non-global? I've tried to remove "global", or set it to {
"name": "spex",
"global": false,
"files": [
"typescript/spex.d.ts"
]
} but if I try to install it like this
it tells me that my dependency is global regardless? I just want to be able to install the parent package without the user having to manually install dependencies on top of it. |
@vitaly-t Global dependencies are never automatically installed. You can write the dependencies in external module format. If you share a gist or link to your example, we'd be able to point out why it's a global module and not an external module. For simplicity, any definition without a top-level import or export is considered global by TypeScript. |
Actually, I found it: https://github.com/vitaly-t/spex/blob/master/typescript/spex.d.ts. Don't wrap it in |
Also, FWIW, you don't need Typings to type your library - if you type |
If it is a module, you can and you should. Change the typings to external module format and publish them to the registry |
I thought that How else should I declare an ambient module? |
No. You can read about writing TypeScript definitions for existing libraries: http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html. For example, here's a definition for one of mine - see https://github.com/blakeembrey/change-case/blob/master/package.json#L6 and https://github.com/blakeembrey/change-case/blob/master/change-case.d.ts. Notice all the dependencies are also written in external module format. There is no reason you should have to write a module in global declaration format, it's a left-over and bad practice from before better tooling existed. |
I've spent many hours searching for an answer, but couldn't find anything usable to seemingly a simple question - how to publish a package with global dependencies.
Here I asked the question: A reusable library with typings from GitHub
this is the real code example that I have:
If I instruct users to issue this command:
it installs everything but the
spex
.The only way I was able to make it work is by manually patching the client to include
spex
explicitely, which is very awkward.What am I missing? How to make to work?
I am using the latest version of typings + Node.js 6.2.2
The text was updated successfully, but these errors were encountered: