Describe the bug
This is a subtle one, but bit me and took me a while to debug because I have a shared defaultCompilerOptions object that is used to instantiate multiple ts-morph Project instances.
Because this object is mutated when a Project is created, it ends up taking along the lib and configFilePath settings on to the next Project instance that is created. I was noticing that my second instance was "inheriting" the tsconfig settings from the first instance when the second instance doesn't configure a tsconfig.json file of its own.
Version: 25.0.1
To Reproduce
import { Project, ts } from "ts-morph";
const defaultCompilerOptions = {
jsx: ts.JsxEmit.React,
};
new Project({
defaultCompilerOptions,
});
console.log(defaultCompilerOptions);
// {
// jsx: 4,
// lib: ['lib.dom.d.ts', 'lib.es2020.d.ts'],
// configFilePath: 'path/to/tsconfig.json'
// }
Expected behavior
Object is not mutated.
I can work around this of course by always making a copy of the defaultCompilerOptions object, but figured I'd mention and save someone else from a little debugging time :)
Best,
Greg
Describe the bug
This is a subtle one, but bit me and took me a while to debug because I have a shared
defaultCompilerOptionsobject that is used to instantiate multiple ts-morphProjectinstances.Because this object is mutated when a
Projectis created, it ends up taking along thelibandconfigFilePathsettings on to the nextProjectinstance that is created. I was noticing that my second instance was "inheriting" the tsconfig settings from the first instance when the second instance doesn't configure atsconfig.jsonfile of its own.Version: 25.0.1
To Reproduce
Expected behavior
Object is not mutated.
I can work around this of course by always making a copy of the
defaultCompilerOptionsobject, but figured I'd mention and save someone else from a little debugging time :)Best,
Greg