Left-hand side of assignment expression cannot be a constant or a read-only property

This is because in es6 all module's variables are considered constants.

https://github.com/Microsoft/TypeScript/issues/6751#issuecomment-177114001

In TypeScript 2.0 the bug (of not reporting this error) was fixed.

Since mongoose is still using the commonjs - var mongoose = require("mongoose") - not the es6 import syntax (which is used in the typings), you can suppress the error by assuming the module is of type any.

WORKAROUND:

(mongoose as any).Promise = global.Promise;

There is also a way to maintain type-checking and intellisense with this technique.

import * as mongoose from "mongoose"; // same as const mongoose = require("mongoose");
type mongooseType = typeof mongoose;
(mongoose as mongooseType).Promise = global.Promise;
// OR
(<mongooseType>mongoose).Promise = global.Promise;

This can be a helpful way to override only certain functions within a module with mock functions without needing a mock framework like jest.mock().