Skip to content

moduleDetection force compiler setting does not work #1611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
souporserious opened this issue Feb 5, 2025 · 0 comments
Open

moduleDetection force compiler setting does not work #1611

souporserious opened this issue Feb 5, 2025 · 0 comments

Comments

@souporserious
Copy link
Contributor

Describe the bug

Version: 25.0.0

To Reproduce

Create a simple project setting moduleDetection to force which should treat each source file as a module:

import { Project, ts } from 'ts-morph';

const project = new Project({
  compilerOptions: {
    module: ts.ModuleKind.ESNext,
    moduleDetection: ts.ModuleDetectionKind.Force,
  },
  useInMemoryFileSystem: true,
});

project.createSourceFile('a.ts', `const a = 'a'`);
project.createSourceFile('b.ts', `const a = 'a'`);

project.getPreEmitDiagnostics().forEach((diagnostic) => {
  console.log(diagnostic.getMessageText());
});

However, this will not work as expected and produce type errors. Here is a StackBlitz Node.js project reproducing the issue along with using the TypeScript compiler directly which works as expected.

Expected behavior

The moduleDetection compiler setting should be respected and not produce diagnostics when set to force.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant