function findDanglingTypes()

in compiler/src/dangling-types-report.ts [28:61]


function findDanglingTypes (): void {
  const project = new Project({ tsConfigFilePath })

  const definedButNeverUsed: string[] = []
  for (const sourceFile of project.getSourceFiles()) {
    for (const declaration of sourceFile.getClasses()) {
      if (customTypes.includes(declaration.getName() ?? '')) continue
      if (isDefinedButNeverUsed(declaration)) {
        definedButNeverUsed.push(`${declaration.getName() ?? ''},${formatDanglingPath(declaration.getSourceFile().getFilePath())}`)
      }
    }
    for (const declaration of sourceFile.getInterfaces()) {
      if (isDefinedButNeverUsed(declaration)) {
        definedButNeverUsed.push(`${declaration.getName() ?? ''},${formatDanglingPath(declaration.getSourceFile().getFilePath())}`)
      }
    }
    for (const declaration of sourceFile.getEnums()) {
      if (isDefinedButNeverUsed(declaration)) {
        definedButNeverUsed.push(`${declaration.getName() ?? ''},${formatDanglingPath(declaration.getSourceFile().getFilePath())}`)
      }
    }
    for (const declaration of sourceFile.getTypeAliases()) {
      if (isDefinedButNeverUsed(declaration)) {
        definedButNeverUsed.push(`${declaration.getName() ?? ''},${formatDanglingPath(declaration.getSourceFile().getFilePath())}`)
      }
    }
  }

  writeFileSync(
    join(__dirname, '..', '..', 'output', 'dangling-types', 'dangling.csv'),
    definedButNeverUsed.join('\n'),
    'utf8'
  )
}