# Type Definitions (beta)

## What are type definitions

Type definitions (sometimes called type declarations or `d.ts`-files) are files which describe the shape of an existing module/library/code base without the implementation of that code. This basically enables the developer to get code completion, and inline documentation for external javascript modules.

A popular and huge collection of types can be found in the [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) repository, or on their organisation [@types on npm](https://www.npmjs.com/~types).

The usefulness of these type definitions comes down to the support of the developer's editor/IDE. Writer and Substance type definitions have been tested using Visual Studio Code.

## Installing Type Definitions

Currently we supply beta versions of both the writer, and substance module. These are public npm packages and can be installed using the following command:

```bash
$ npm install @infomaker/types-writer @infomaker/types-substance --save-dev
```

This will install the type definitions in your node\_modules folder, but in order for your editor to understand them you will need to add or update a `tsconfig.json` file in your root folder:

{% code title="tsconfig.json" %}

```javascript
{
    "compilerOptions": {
        "allowJs": true,
        "noEmit": true,
        "baseUrl": ".",
        "paths": {
            "*": [
                "*",
                "node_modules/@infomaker/types-*"
            ]
        }
    }
}
```

{% endcode %}

This will basically tell your editor to look for any imported package `"*"`, first in its normal location `"*"`, and if it can't be found there, look for it using the format `"node_modules/@infomaker/types-*"`, where `"*"` is the package's name, e.g. `"writer"`, or `"substance"`.

**NPM Packages**

* [@infomaker/types-writer](https://www.npmjs.com/package/@infomaker/types-writer)
* [@infomaker/types-substance](https://www.npmjs.com/package/@infomaker/types-substance)
