Revision fe185272cfff3bff7129a3ebc828bf1a0479572f authored by Oleksandr T on 15 December 2022, 18:44:06 UTC, committed by GitHub on 15 December 2022, 18:44:06 UTC
* feat(51000): add ignoreDeprecations option

* use constants of versions

* change the ignoreDeprecations type to allow only one value - '5.0'

* add tests

* update baseline

* add typeScriptVersion to CreateProgramOptions

* update baseline

* change diagnostic message
1 parent e0bfac5
Raw File
find-unused-diganostic-messages.mjs
// This file requires a modern version of node 14+, and grep to be available.

// node scripts/find-unused-diagnostic-messages.mjs
import { readFileSync } from "fs";
import { EOL } from "os";
import { execSync } from "child_process";

const diags = readFileSync("src/compiler/diagnosticInformationMap.generated.ts", "utf8");
const startOfDiags = diags.split("export const Diagnostics")[1];

/** @type {string[]} */
const missingNames = [];
startOfDiags.split(EOL).forEach(line => {
    if (!line.includes(":")) return;
    const diagName = line.split(":")[0].trim();

    try {
        execSync(`grep -rnw 'src' -e 'Diagnostics.${diagName}'`).toString();
        process.stdout.write(".");
    }
    catch (error) {
        missingNames.push(diagName);
        process.stdout.write("x");
    }
});

if (missingNames.length) {
    process.exitCode = 1;
    console.log("Could not find usage of these diagnostics in the codebase:");
    console.log(missingNames);
}
back to top