-
Notifications
You must be signed in to change notification settings - Fork 1
How to use tsd & tsd link
First of all, to check what is tsd go to https://github.com/DefinitelyTyped/tsd
- The primary use in MyKoop is to help get typescript definitions for node modules like
node
,express
,mysql
,etc... - It is also used to query definitions from MyKoop Definitions
-
tsd link
andtsd-link
are used to create symbolic links to definitions files across multiple local projects. This is especially useful when working on various modules of MyKoop.
To install tsd & tsd-link use
$ npm install Cellule/tsd#mykoop -g
$ npm install Cellule/tsd-link -g
We use a different tsd than DefinitelyTyped because it overwrites data used by tsd-link
- To add a new definition from the original repo type
tsd query modulename -a install --save -c tsd-dt.json
- To add a new definition from MyKoop use
tsd query mykoop-modulename -a install --save
These downloads the definition file, add a line in typings/tsd.d.ts
and save the module to tsd.json
or tsd-dt.json
Linking means creating symbolic links to use the same version of the file across all projects
There are 2 idioms when it comes to linking type definitions.
- Linking to a module used with
require("mykoop-module");
- Linking to a module using dynamic require
require(moduleNameVar);
Most of MyKoop module are required dynamically (2nd idiom). The way to link these definition is by using tsd-link
.
-
tsd-link -o mykoop-module
: This will create a link from the user profile to the definition file in the module. Use at the root of the module (aka wheretsd.json
is) -
tsd-link mykoop-module
: This will create a link from the module to the link in the user profile.
For the module required directly (1st idiom) you most write in the package.json
file
"typescript": {
"definition": "path/file.d.ts"
}
Then after you installed that module, type tsd link
and this will scan your npm module and add a line to your tsd.d.ts
file to link to the definition of the module.