TS1148 ~ How to "import" with --module: "none" and typescript 2.x
You need to export rxjs
to the global namespace. There are two ways to do it, depends on the shape of rxjs
.
If rxjs
export only one thing, e.g. Rx.*
, then you can do this:
// custom-typings/rxjs.d.ts
import * from 'rxjs'
export as namespace Rx
// tsconfig.json
{
"include": [
"custom-typings"
]
}
If it export more than one thing, then you need to do global augmentation:
// custom-typings/rxjs.d.ts
import * as Rx from 'rxjs'
declare global {
type Rx = Rx
...
}
// same change to tsconfig.json
Here are some info on global augmentation. https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Create a global declaration for Rx
which is the type of the RxJS exports, like so:
import * as RxJS from "rxjs";
declare global {
const Rx: typeof RxJS;
}
export {};
Save it to a file (e.g. global.d.ts
) and then add that to the include
array of tsconfig.json
.