JoshuaKGoldberg / TypeStat

Converts JavaScript to TypeScript and TypeScript to better TypeScript. 🧫

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› Bug: Collecting included files possibly missing bunch of them

rubiesonthesky opened this issue Β· comments

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

I expected code to collect all files that match include from compilerOptions: [ 'src', 'test/*.ts' ]

Actual

In practice, it seems that only these files where matched

[
  'test/postProcessing.test.ts',
  'test/infiniteWaveDetection.test.ts',
  'test/include.test.ts',
  'test/fixStrictNonNullAssertions.test.ts',
  'test/fixNoInferableTypes.test.ts',
  'test/fixNoImplicitThis.test.ts',
  'test/fixNoImplicitAny.test.ts',
  'test/fixMissingProperties.test.ts',
  'test/fixIncompleteTypes.test.ts',
  'test/fixImportExtensions.test.ts',
  'test/filters.test.ts',
  'test/files.test.ts',
  'test/customMutators.test.ts',
  'test/cleanups.test.ts'
]

Additional Info

I added logging to parseRawCompilerOptions to check what is doing with include. It's read correctly as [ 'src', 'test/*.ts' ] but then parseJsonConfigFileContent.filenames sets it to be just those files mentioned in Actual section.

There is mutation test for include, but it seems that the test setup does not use parseRawCompilerOptions at all. So it's not actually tested.

This manifest so that suppressTypeErrors is adding a lot ts-expect-error comments all around about things that are not problems.

If we change the code to be following, then it collect the correct files. However, it's still adding a lot unnecessary ts-expect-error comments. So there must be something else.

	config.include &&= ts.parseJsonConfigFileContent(
		compilerOptions.config,
		{
			fileExists: fs.existsSync,
			// eslint-disable-next-line @typescript-eslint/unbound-method
			readDirectory: ts.sys.readDirectory,
			readFile: (file) => fs.readFileSync(file, "utf8"),
			useCaseSensitiveFileNames: true,
		},
		cwd,
	).fileNames;