Typescript compilerOptions for a module

Viewed 375

I Have a monaco editor in my project configured to work with typescript, I have configured the compilerOptions from typescriptDefaults object and works well. We get the compilerOptions from the .tsconfig file. The thing is, We could open two modules with different .tsconfig files and I need to configure the monaco editor to be compatible with that if that files have different configuration. But the way to configure it is by default and general if I understand. How can I add configurations only for an editor instance?

This is the code how I configure it now:

   monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
        experimentalDecorators: true,
        allowSyntheticDefaultImports: true,
        jsx: this.monaco.languages.typescript.JsxEmit.React,
        moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
        allowNonTsExtensions: true,
        target: monaco.languages.typescript.ScriptTarget.ES2020,
   });

UPDATE

I use setCompilerOptions mainly for set typescript definitions such as ES2020 or types. There is another way to set this rules ?

1 Answers

It's a static setting for the language server, which is used by all editor instances. So it is not possible to have individual configurations.

Related