How to use TypeScript definition files from the @types npm repository when --module is 'none'

Viewed 753

how can I use TypeScript definition files via @types if the compiler's module system parameter is set to 'none'? For example, when using the type definitions for the express web server:

npm install @types/express

with the following tsconfig.json

{
    "compilerOptions":
    {
        "module": "none"
    }
}

This code fails:

import * as express from "express";

export module Web.Server
{
    const app = express();
}

with the error message:

Cannot use imports, exports, or module augmentations when '--module' is 'none'.

If it is not possible to use type definition files in an non-module environment, what is best practice to cope with this situation?

Thanks in advance...

2 Answers
Related