I have a repo that's comprised only of an index.d.ts
file (TypeScript definition file) that I want to share among a number of repos I have. The only declaration in the type definition file is an interface like so:
interface MyInterface {
thisSuperCoolFunction(): void;
}
Unfortunately, the definition repo and all other repos I'm using are private. Is it possible to submit a private npm typings project to @types
so that installing it will just work but also not expose it to anyone else?
Note: Not the typings repo, only @types
on npm.
You don't have to send your typings anywhere. You can use git url as dependency or local path
Assuming you want to create @types/secret-library
. And your types are in file index.d.ts
.
Create package.json
with @types/secret-library
as a package name
// package.json
{
"name": "@types/secret-library",
"private": true,
"types:" "index.d.ts"
}
Push both index.d.ts
and package.json
to some repo e.g. git.acme.com/secret-project.git
.
Now in your other project you can reference this repository as a dependency
// package.json
{
"name": "doom-machine",
"private": true,
"dependencies":{
"@types/secret-library": "git://git.acme.com/secret-project.git"
}
}
If both index.d.ts
and package.json
are in directory /home/evil-genius/doom-saucer
You can reference this path as a dependency
// package.json
{
"name": "doom-machine",
"private": true,
"dependencies":{
"@types/secret-library": "file:/home/evil-genius/doom-saucer"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With