Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit c219164

Browse files
committed
Add README
1 parent e862328 commit c219164

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# nodecg-types
2+
3+
If you are developing [NodeCG](https://nodecg.dev) bundles in TypeScript you need typings for nodecg.
4+
5+
The [official guide](https://www.nodecg.dev/docs/frameworks/typescript#using-type-definitions) recommends that you import them directly from the local NodeCG installation using relative paths. This can easily break if the install NodeCG version is incorrect or the user has placed your bundle somewhere other than in `nodecgInstall/bundles/yourBundle`. Also your bundle cannot be compiled if you don't have NodeCG installed.
6+
7+
Some people require the `nodecg` npm package directly to get around these problems. However this pulls in all the dependencies of NodeCG into your project/`node_modules` directory which are tremendous in count and size.
8+
Because of this `npm install`s are pretty slow and also you have NodeCG stored multiple times on your disk. Once for your actual install and then one additional install for each TypeScript bundle that imports the NodeCG typings this way.
9+
10+
`nodecg-types` solves this by republishing just the [official NodeCG types](https://github.com/nodecg/nodecg/tree/master/types). It does not contain any other NodeCG code and only has the dependencies that are needed for the typings to work.
11+
12+
Note: this is an unofficial package and a temporary workaround till NodeCG 2.x is released! Please refer to [this](https://github.com/nodecg/nodecg/issues/552) issue regarding how the official NodeCG typings will be handled in the future.
13+
14+
## Usage
15+
16+
`nodecg-types` behaves the same way as the official `nodecg` npm package regarding types.
17+
18+
You install it using npm:
19+
20+
```shell
21+
npm install nodecg-types --save
22+
```
23+
24+
And then import the typings you need. The paths are completely the same meaning `nodecg-types` is a drop-in replacement and you can just exchange `nodecg` for `nodecg-types`:
25+
26+
```typescript
27+
import { NodeCG } from "nodecg-types/types/server";
28+
```

0 commit comments

Comments
 (0)