Type Definitions (beta)

To ease the use of the external packages 'writer' and 'substance' we created two npm packages with type definitions.

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 repository, or on their organisation @types on npm.

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:

$ 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:

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

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