From 00b249887cc0d6a0be6a18eb9dcd3a664b87fee5 Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:51:35 +0300 Subject: [PATCH 01/14] fix: remove unused support for file glob from command line --- src/cli/runCli.ts | 2 +- src/collectFileNames.ts | 10 +--------- src/index.ts | 11 +++++------ src/options/fillOutRawOptions.ts | 2 -- src/options/loadPendingOptions.ts | 10 ++++------ src/tests/testSetup.ts | 1 - 6 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/cli/runCli.ts b/src/cli/runCli.ts index e598d757c..174257ba6 100644 --- a/src/cli/runCli.ts +++ b/src/cli/runCli.ts @@ -63,7 +63,7 @@ export const runCli = async ( let result: TypeStatResult; try { - result = await runtime.mainRunner(rawOptions, runtime.output); + result = await runtime.mainRunner(rawOptions.config, runtime.output); } catch (error) { result = { error: error instanceof Error ? error : new Error(error as string), diff --git a/src/collectFileNames.ts b/src/collectFileNames.ts index b58812106..3dff3157b 100644 --- a/src/collectFileNames.ts +++ b/src/collectFileNames.ts @@ -1,14 +1,11 @@ import { glob } from "glob"; import * as path from "node:path"; -import { TypeStatArgv } from "./index.js"; - export const collectFileNames = async ( - argv: TypeStatArgv, cwd: string, include: readonly string[] | undefined, ): Promise => { - const globsAndNames = await collectFileNamesFromGlobs(argv, cwd, include); + const globsAndNames = await collectFileNamesFromGlobs(cwd, include); if (!globsAndNames) { return undefined; } @@ -27,14 +24,9 @@ export const collectFileNames = async ( }; const collectFileNamesFromGlobs = async ( - argv: TypeStatArgv, cwd: string, include: readonly string[] | undefined, ): Promise<[readonly string[], readonly string[]] | undefined> => { - if (argv.args.length) { - return [argv.args, await glob(argv.args)]; - } - if (include === undefined) { return undefined; } diff --git a/src/index.ts b/src/index.ts index 12ee31279..71685c1df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -44,10 +44,10 @@ export interface SucceededResult { } export const typeStat = async ( - argv: TypeStatArgv, + configPath: string | undefined, output: ProcessOutput, ): Promise => { - const allPendingOptions = await tryLoadingPendingOptions(argv, output); + const allPendingOptions = await tryLoadingPendingOptions(configPath, output); if ( allPendingOptions instanceof Error || typeof allPendingOptions === "string" @@ -82,7 +82,7 @@ export const typeStat = async ( chalk.green( ` options ${pluralize(allPendingOptions.length, "object")} specified in `, ), - chalk.greenBright(argv.config), + chalk.greenBright(configPath), chalk.green(` to modify your source code.`), ].join(""), ); @@ -91,7 +91,6 @@ export const typeStat = async ( for (let i = 0; i < allPendingOptions.length; i += 1) { // Collect all files to be run on this option iteration from the include glob(s) const fileNames = await collectFileNames( - argv, process.cwd(), allPendingOptions[i].include, ); @@ -146,11 +145,11 @@ export const typeStat = async ( }; const tryLoadingPendingOptions = async ( - argv: TypeStatArgv, + configPath: string | undefined, output: ProcessOutput, ): Promise => { try { - return await loadPendingOptions(argv, output); + return await loadPendingOptions(configPath, output); } catch (error) { return error instanceof Error ? error : new Error(error as string); } diff --git a/src/options/fillOutRawOptions.ts b/src/options/fillOutRawOptions.ts index 6fc796100..688a8d3ba 100644 --- a/src/options/fillOutRawOptions.ts +++ b/src/options/fillOutRawOptions.ts @@ -1,4 +1,3 @@ -import { TypeStatArgv } from "../index.js"; import { ProcessOutput } from "../output/types.js"; import { collectOptionals } from "../shared/arrays.js"; import { ReactPropTypesHint, ReactPropTypesOptionality } from "./enums.js"; @@ -12,7 +11,6 @@ import { collectStrictNullChecks } from "./parsing/collectStrictNullChecks.js"; import { PendingTypeStatOptions, RawTypeStatOptions } from "./types.js"; export interface OptionsFromRawOptionsSettings { - argv: TypeStatArgv; compilerOptions: Readonly; cwd: string; output: ProcessOutput; diff --git a/src/options/loadPendingOptions.ts b/src/options/loadPendingOptions.ts index aee74384e..593387c13 100644 --- a/src/options/loadPendingOptions.ts +++ b/src/options/loadPendingOptions.ts @@ -1,6 +1,5 @@ import * as path from "node:path"; -import { TypeStatArgv } from "../index.js"; import { ProcessOutput } from "../output/types.js"; import { normalizeAndSlashify } from "../shared/paths.js"; import { fillOutRawOptions } from "./fillOutRawOptions.js"; @@ -11,20 +10,20 @@ import { PendingTypeStatOptions, RawTypeStatOptions } from "./types.js"; /** * Reads pre-file-rename TypeStat options using a config path. - * @param argv Root arguments passed to TypeStat. + * @param configPath Config path * @param output Wraps process and logfile output. * @returns Promise for filled-out TypeStat options, or a string complaint from failing to make them. */ export const loadPendingOptions = async ( - argv: TypeStatArgv, + configPath: string | undefined, output: ProcessOutput, ): Promise => { - if (argv.config === undefined) { + if (configPath === undefined) { return "-c/--config file must be provided."; } const cwd = process.cwd(); - const foundRawOptions = findRawOptions(cwd, argv.config); + const foundRawOptions = findRawOptions(cwd, configPath); if (typeof foundRawOptions === "string") { return foundRawOptions; } @@ -40,7 +39,6 @@ export const loadPendingOptions = async ( const compilerOptions = await parseRawCompilerOptions(cwd, projectPath); const filledOutOptions = fillOutRawOptions({ - argv, compilerOptions, cwd, output, diff --git a/src/tests/testSetup.ts b/src/tests/testSetup.ts index ad1e7d39f..0274fc349 100644 --- a/src/tests/testSetup.ts +++ b/src/tests/testSetup.ts @@ -59,7 +59,6 @@ export const runMutationTest = async (dirPath: string) => { const provider = createTypeStatProvider({ ...fillOutRawOptions({ - argv: { args: [] }, compilerOptions, cwd: dirPath, output, From 7dc8104cc97ac0008ac1c06cc8641ef005b51beb Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:00:54 +0300 Subject: [PATCH 02/14] remove jsdoc params --- src/options/loadPendingOptions.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/options/loadPendingOptions.ts b/src/options/loadPendingOptions.ts index 593387c13..083fd3ad6 100644 --- a/src/options/loadPendingOptions.ts +++ b/src/options/loadPendingOptions.ts @@ -10,8 +10,6 @@ import { PendingTypeStatOptions, RawTypeStatOptions } from "./types.js"; /** * Reads pre-file-rename TypeStat options using a config path. - * @param configPath Config path - * @param output Wraps process and logfile output. * @returns Promise for filled-out TypeStat options, or a string complaint from failing to make them. */ export const loadPendingOptions = async ( From d2a2d17c6946fce78283633e106438e9123829de Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:22:09 +0300 Subject: [PATCH 03/14] add test --- src/collectFileNames.test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/collectFileNames.test.ts diff --git a/src/collectFileNames.test.ts b/src/collectFileNames.test.ts new file mode 100644 index 000000000..795e7f7bf --- /dev/null +++ b/src/collectFileNames.test.ts @@ -0,0 +1,34 @@ +import path from "node:path"; +import { describe, expect, it } from "vitest"; + +import { collectFileNames } from "./collectFileNames.js"; + +describe("collectFileNames", () => { + it("should collect files with wildcard", async () => { + const cwd = path.resolve(import.meta.dirname, ".."); + const fileNames = await collectFileNames( + path.resolve(import.meta.dirname), + ["*"], + ); + const names = Array.isArray(fileNames) + ? (fileNames as string[]).map((item) => item.replace(cwd, "")) + : undefined; + + // Assert + expect(names).toContain("/src/collectFileNames.test.ts"); + }); + + it("return error if node modules are included", async () => { + const cwd = path.resolve(import.meta.dirname, ".."); + const fileNames = await collectFileNames(cwd, ["*"]); + + // Assert + const error = + typeof fileNames === "string" + ? fileNames.replace(cwd, "") + : undefined; + expect(error).toEqual( + "At least one path including node_modules was included implicitly: '/node_modules'. Either adjust TypeStat's included files to not include node_modules (recommended) or explicitly include node_modules/ (not recommended).", + ); + }); +}); From ff9336b2ad53130cc9a9ccb77679bf1ae9d31415 Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sat, 6 Apr 2024 00:06:21 +0300 Subject: [PATCH 04/14] fix: fixes tsconfig reading and handling compiler options --- src/options/fillOutRawOptions.ts | 29 ++++--- src/options/loadPendingOptions.ts | 4 +- src/options/parseRawCompilerOptions.ts | 41 ++++----- src/options/parsing/collectNoImplicitAny.ts | 16 +--- src/options/parsing/collectNoImplicitThis.ts | 16 +--- .../parsing/collectStrictNullChecks.ts | 40 +++------ src/options/types.ts | 11 +-- src/services/createProgramConfiguration.ts | 6 +- src/tests/testSetup.ts | 4 +- test/__snapshots__/cleanups.test.ts.snap | 86 +++++++++++++++++-- .../__snapshots__/customMutators.test.ts.snap | 12 +-- test/__snapshots__/files.test.ts.snap | 12 --- test/__snapshots__/filters.test.ts.snap | 9 -- .../fixImportExtensions.test.ts.snap | 5 -- .../fixIncompleteTypes.test.ts.snap | 84 +++--------------- .../fixMissingProperties.test.ts.snap | 3 - .../fixNoImplicitAny.test.ts.snap | 9 -- .../fixNoImplicitThis.test.ts.snap | 3 - .../fixNoInferableTypes.test.ts.snap | 9 -- .../fixStrictNonNullAssertions.test.ts.snap | 29 +------ test/__snapshots__/include.test.ts.snap | 20 ++--- .../infiniteWaveDetection.test.ts.snap | 6 +- .../__snapshots__/postProcessing.test.ts.snap | 6 +- test/cases/cleanups/nonTypeErrors/expected.ts | 4 + test/cases/cleanups/nonTypeErrors/original.ts | 4 + .../cleanups/nonTypeErrors/tsconfig.json | 8 ++ .../cleanups/nonTypeErrors/typestat.json | 6 ++ .../cleanups/suppressTypeErrors/expected.ts | 2 +- test/cleanups.test.ts | 11 +++ 29 files changed, 200 insertions(+), 295 deletions(-) create mode 100644 test/cases/cleanups/nonTypeErrors/expected.ts create mode 100644 test/cases/cleanups/nonTypeErrors/original.ts create mode 100644 test/cases/cleanups/nonTypeErrors/tsconfig.json create mode 100644 test/cases/cleanups/nonTypeErrors/typestat.json diff --git a/src/options/fillOutRawOptions.ts b/src/options/fillOutRawOptions.ts index 688a8d3ba..c15134b98 100644 --- a/src/options/fillOutRawOptions.ts +++ b/src/options/fillOutRawOptions.ts @@ -1,7 +1,7 @@ import { ProcessOutput } from "../output/types.js"; import { collectOptionals } from "../shared/arrays.js"; import { ReactPropTypesHint, ReactPropTypesOptionality } from "./enums.js"; -import { ParsedCompilerOptions } from "./parseRawCompilerOptions.js"; +import { ParsedTsConfig } from "./parseRawCompilerOptions.js"; import { collectAddedMutators } from "./parsing/collectAddedMutators.js"; import { collectFileOptions } from "./parsing/collectFileOptions.js"; import { collectNoImplicitAny } from "./parsing/collectNoImplicitAny.js"; @@ -11,11 +11,11 @@ import { collectStrictNullChecks } from "./parsing/collectStrictNullChecks.js"; import { PendingTypeStatOptions, RawTypeStatOptions } from "./types.js"; export interface OptionsFromRawOptionsSettings { - compilerOptions: Readonly; cwd: string; output: ProcessOutput; projectPath: string; rawOptions: RawTypeStatOptions; + tsConfig: Readonly; } /** @@ -23,18 +23,13 @@ export interface OptionsFromRawOptionsSettings { * @returns Parsed TypeStat options, or a string for an error complaint. */ export const fillOutRawOptions = ({ - compilerOptions, cwd, output, projectPath, rawOptions, + tsConfig, }: OptionsFromRawOptionsSettings): PendingTypeStatOptions => { const rawOptionTypes = rawOptions.types ?? {}; - const noImplicitAny = collectNoImplicitAny(compilerOptions, rawOptions); - const noImplicitThis = collectNoImplicitThis(compilerOptions, rawOptions); - const { compilerStrictNullChecks, typeStrictNullChecks } = - collectStrictNullChecks(compilerOptions, rawOptionTypes); - const packageOptions = collectPackageOptions(cwd, rawOptions); const shell: (readonly string[])[] = []; @@ -48,10 +43,16 @@ export const fillOutRawOptions = ({ ...rawOptions.cleanups, }, compilerOptions: { - ...compilerOptions, - noImplicitAny, - noImplicitThis, - strictNullChecks: compilerStrictNullChecks, + ...tsConfig.compilerOptions, + noImplicitAny: collectNoImplicitAny(tsConfig.compilerOptions, rawOptions), + noImplicitThis: collectNoImplicitThis( + tsConfig.compilerOptions, + rawOptions, + ), + strictNullChecks: collectStrictNullChecks( + tsConfig.compilerOptions, + rawOptionTypes, + ), }, files: collectFileOptions(rawOptions), filters: collectOptionals(rawOptions.filters), @@ -74,7 +75,7 @@ export const fillOutRawOptions = ({ ReactPropTypesOptionality.AsWritten, }, }, - include: rawOptions.include ?? compilerOptions.include, + include: rawOptions.include ?? tsConfig.include, mutators: collectAddedMutators( rawOptions, packageOptions.directory, @@ -85,7 +86,7 @@ export const fillOutRawOptions = ({ postProcess: { shell }, projectPath, types: { - strictNullChecks: typeStrictNullChecks, + strictNullChecks: rawOptionTypes.strictNullChecks, }, }; }; diff --git a/src/options/loadPendingOptions.ts b/src/options/loadPendingOptions.ts index 083fd3ad6..9015a2cd7 100644 --- a/src/options/loadPendingOptions.ts +++ b/src/options/loadPendingOptions.ts @@ -34,14 +34,14 @@ export const loadPendingOptions = async ( for (let i = 0; i < allRawOptions.length; i += 1) { const rawOptions = allRawOptions[i]; const projectPath = getProjectPath(cwd, filePath, rawOptions); - const compilerOptions = await parseRawCompilerOptions(cwd, projectPath); + const tsConfig = await parseRawCompilerOptions(cwd, projectPath); const filledOutOptions = fillOutRawOptions({ - compilerOptions, cwd, output, projectPath, rawOptions, + tsConfig, }); const complaint = findComplaintForOptions(filledOutOptions); if (complaint) { diff --git a/src/options/parseRawCompilerOptions.ts b/src/options/parseRawCompilerOptions.ts index dd2bc99da..6c0b69d94 100644 --- a/src/options/parseRawCompilerOptions.ts +++ b/src/options/parseRawCompilerOptions.ts @@ -1,45 +1,42 @@ -import { glob } from "glob"; -import { minimatch } from "minimatch"; -import * as fs from "node:fs"; import * as fsp from "node:fs/promises"; -import * as path from "node:path"; import ts from "typescript"; import { stringifyDiagnosticMessageText } from "../shared/diagnostics.js"; -export interface ParsedCompilerOptions extends ts.CompilerOptions { +export interface ParsedTsConfig { + compilerOptions: ts.CompilerOptions | undefined; include?: string[]; } export const parseRawCompilerOptions = async ( cwd: string, projectPath: string, -): Promise => { +): Promise => { const configRaw = (await fsp.readFile(projectPath)).toString(); - const compilerOptions = ts.parseConfigFileTextToJson(projectPath, configRaw); - if (compilerOptions.error !== undefined) { + const configResult = ts.parseConfigFileTextToJson(projectPath, configRaw); + if (configResult.error !== undefined) { throw new Error( - `Could not parse compiler options from '${projectPath}': ${stringifyDiagnosticMessageText(compilerOptions.error)}`, + `Could not parse compiler options from '${projectPath}': ${stringifyDiagnosticMessageText(configResult.error)}`, ); } - const config = compilerOptions.config as ParsedCompilerOptions; + const config = configResult.config as ParsedTsConfig; // TSConfig includes often come in a glob form like ["src"] config.include &&= ts.parseJsonConfigFileContent( - compilerOptions.config, + config, { - fileExists: (filePath) => fs.statSync(filePath).isFile(), - readDirectory: (rootDir, extensions, excludes, includes) => - includes - .flatMap((include) => glob.sync(path.join(rootDir, include))) - .filter( - (filePath) => - !excludes?.some((exclude) => minimatch(filePath, exclude)) && - extensions.some((extension) => filePath.endsWith(extension)), - ) - .map((filePath) => path.relative(rootDir, filePath)), - readFile: (filePath) => fs.readFileSync(filePath).toString(), + // eslint-disable-next-line @typescript-eslint/unbound-method + directoryExists: ts.sys.directoryExists, + // eslint-disable-next-line @typescript-eslint/unbound-method + fileExists: ts.sys.fileExists, + getCurrentDirectory: () => process.cwd(), + // eslint-disable-next-line @typescript-eslint/unbound-method + getDirectories: ts.sys.getDirectories, + // eslint-disable-next-line @typescript-eslint/unbound-method + readDirectory: ts.sys.readDirectory, + // eslint-disable-next-line @typescript-eslint/unbound-method + readFile: ts.sys.readFile, useCaseSensitiveFileNames: true, }, cwd, diff --git a/src/options/parsing/collectNoImplicitAny.ts b/src/options/parsing/collectNoImplicitAny.ts index 2641555f7..2262ec324 100644 --- a/src/options/parsing/collectNoImplicitAny.ts +++ b/src/options/parsing/collectNoImplicitAny.ts @@ -3,16 +3,8 @@ import ts from "typescript"; import { RawTypeStatOptions } from "../types.js"; export const collectNoImplicitAny = ( - compilerOptions: Readonly, + compilerOptions: Readonly | undefined, rawOptions: RawTypeStatOptions, -): boolean => { - if (rawOptions.fixes?.noImplicitAny !== undefined) { - return rawOptions.fixes.noImplicitAny; - } - - if (compilerOptions.noImplicitAny !== undefined) { - return compilerOptions.noImplicitAny; - } - - return false; -}; +): boolean => + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + rawOptions.fixes?.noImplicitAny || compilerOptions?.noImplicitAny || false; diff --git a/src/options/parsing/collectNoImplicitThis.ts b/src/options/parsing/collectNoImplicitThis.ts index f4b8ae25c..0bc90dcfb 100644 --- a/src/options/parsing/collectNoImplicitThis.ts +++ b/src/options/parsing/collectNoImplicitThis.ts @@ -3,16 +3,8 @@ import ts from "typescript"; import { RawTypeStatOptions } from "../types.js"; export const collectNoImplicitThis = ( - compilerOptions: Readonly, + compilerOptions: Readonly | undefined, rawOptions: RawTypeStatOptions, -): boolean => { - if (rawOptions.fixes?.noImplicitThis !== undefined) { - return rawOptions.fixes.noImplicitThis; - } - - if (compilerOptions.noImplicitThis !== undefined) { - return compilerOptions.noImplicitThis; - } - - return false; -}; +): boolean => + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + rawOptions.fixes?.noImplicitThis || compilerOptions?.noImplicitThis || false; diff --git a/src/options/parsing/collectStrictNullChecks.ts b/src/options/parsing/collectStrictNullChecks.ts index d7694e4b1..8a223067a 100644 --- a/src/options/parsing/collectStrictNullChecks.ts +++ b/src/options/parsing/collectStrictNullChecks.ts @@ -3,33 +3,13 @@ import ts from "typescript"; import { RawTypeStatTypeOptions } from "../types.js"; export const collectStrictNullChecks = ( - compilerOptions: Readonly, - rawOptionTypes: RawTypeStatTypeOptions, -) => { - const typeStrictNullChecks = rawOptionTypes.strictNullChecks; - const compilerStrictNullChecks = collectCompilerStrictNullChecks( - compilerOptions, - typeStrictNullChecks, - ); - - return { compilerStrictNullChecks, typeStrictNullChecks }; -}; - -const collectCompilerStrictNullChecks = ( - compilerOptions: Readonly, - typeStrictNullChecks: boolean | undefined, -): boolean => { - if (typeStrictNullChecks !== undefined) { - return typeStrictNullChecks; - } - - if (compilerOptions.strictNullChecks !== undefined) { - return compilerOptions.strictNullChecks; - } - - if (compilerOptions.strict !== undefined) { - return compilerOptions.strict; - } - - return false; -}; + compilerOptions: Readonly | undefined, + rawOptionTypes: RawTypeStatTypeOptions | undefined, +): boolean => + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + rawOptionTypes?.strictNullChecks || + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + compilerOptions?.strictNullChecks || + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + compilerOptions?.strict || + false; diff --git a/src/options/types.ts b/src/options/types.ts index 9fdf22926..979c72f9b 100644 --- a/src/options/types.ts +++ b/src/options/types.ts @@ -87,7 +87,7 @@ export interface BaseTypeStatOptions { /** * Parsed TypeScript compiler options with relevant fields filled out. */ - readonly compilerOptions: Readonly; + readonly compilerOptions: Readonly; /** * Directives for file-level changes. @@ -161,15 +161,6 @@ export interface TypeStatOptions extends BaseTypeStatOptions { readonly fileNames: readonly string[]; } -/** - * Parsed TypeScript compiler options with relevant fields filled out. - */ -export type TypeStatCompilerOptions = ts.CompilerOptions & { - noImplicitAny: boolean; - noImplicitThis: boolean; - strictNullChecks: boolean; -}; - /** * Directives for file-level changes. */ diff --git a/src/services/createProgramConfiguration.ts b/src/services/createProgramConfiguration.ts index fb5d4f8ae..f9c8b63fa 100644 --- a/src/services/createProgramConfiguration.ts +++ b/src/services/createProgramConfiguration.ts @@ -10,8 +10,10 @@ export const createProgramConfiguration = (options: TypeStatOptions) => { // Create a TypeScript configuration using the raw options const parsedConfiguration = ts.parseJsonConfigFileContent( { - ...options.compilerOptions, - skipLibCheck: true, + compilerOptions: { + ...options.compilerOptions, + skipLibCheck: true, + }, }, { fileExists: fs.existsSync, diff --git a/src/tests/testSetup.ts b/src/tests/testSetup.ts index 0514782bf..d88bdf867 100644 --- a/src/tests/testSetup.ts +++ b/src/tests/testSetup.ts @@ -38,7 +38,7 @@ export const runMutationTest = async ( const projectPath = path.join(dirPath, "tsconfig.json"); - const compilerOptions = await parseRawCompilerOptions(dirPath, projectPath); + const tsConfig = await parseRawCompilerOptions(dirPath, projectPath); const output = { // eslint-disable-next-line @typescript-eslint/no-empty-function @@ -49,11 +49,11 @@ export const runMutationTest = async ( }; const pendingOptions = fillOutRawOptions({ - compilerOptions, cwd: dirPath, output, projectPath, rawOptions, + tsConfig, }); const provider = createTypeStatProvider({ diff --git a/test/__snapshots__/cleanups.test.ts.snap b/test/__snapshots__/cleanups.test.ts.snap index 65cfd792d..7a0097332 100644 --- a/test/__snapshots__/cleanups.test.ts.snap +++ b/test/__snapshots__/cleanups.test.ts.snap @@ -1,20 +1,90 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Cleanups > suppressTypeErrors > options 1`] = ` +exports[`Cleanups > non-TypeErrors > options 1`] = ` "{ "cleanups": { "suppressTypeErrors": true }, "compilerOptions": { - "compilerOptions": { - "strictNullChecks": true - }, - "files": [ - "actual.ts" - ], + "esModuleInterop": true, + "strictNullChecks": true, + "resolveJsonModule": true, + "noImplicitAny": false, + "noImplicitThis": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, "noImplicitAny": false, "noImplicitThis": false, - "strictNullChecks": false + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} +}" +`; + +exports[`Cleanups > suppressTypeErrors > options 1`] = ` +"{ + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "strictNullChecks": true, + "noImplicitAny": false, + "noImplicitThis": false }, "files": { "above": "", diff --git a/test/__snapshots__/customMutators.test.ts.snap b/test/__snapshots__/customMutators.test.ts.snap index 52ba5b62e..9788b08d2 100644 --- a/test/__snapshots__/customMutators.test.ts.snap +++ b/test/__snapshots__/customMutators.test.ts.snap @@ -6,9 +6,6 @@ exports[`Custom mutators > empty array > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -83,10 +80,6 @@ exports[`Custom mutators > one mutator > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "include": [ - "actual.ts" - ], - "compileOnSave": false, "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -113,7 +106,7 @@ exports[`Custom mutators > one mutator > options 1`] = ` } }, "include": [ - "actual.ts" + "/actual.ts" ], "mutators": [ [ @@ -140,9 +133,6 @@ exports[`Custom mutators > two mutators > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false diff --git a/test/__snapshots__/files.test.ts.snap b/test/__snapshots__/files.test.ts.snap index 28b353eae..c693a38a7 100644 --- a/test/__snapshots__/files.test.ts.snap +++ b/test/__snapshots__/files.test.ts.snap @@ -6,9 +6,6 @@ exports[`files > addition above > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -83,9 +80,6 @@ exports[`files > addition below > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -160,9 +154,6 @@ exports[`files > both > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -237,9 +228,6 @@ exports[`files > empty addition > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false diff --git a/test/__snapshots__/filters.test.ts.snap b/test/__snapshots__/filters.test.ts.snap index 7ed294d1a..623cbd981 100644 --- a/test/__snapshots__/filters.test.ts.snap +++ b/test/__snapshots__/filters.test.ts.snap @@ -6,9 +6,6 @@ exports[`filters > empty > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": true, "noImplicitThis": false, "strictNullChecks": true @@ -85,9 +82,6 @@ exports[`filters > one > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": true, "noImplicitThis": false, "strictNullChecks": true @@ -166,9 +160,6 @@ exports[`filters > two > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": true, "noImplicitThis": false, "strictNullChecks": true diff --git a/test/__snapshots__/fixImportExtensions.test.ts.snap b/test/__snapshots__/fixImportExtensions.test.ts.snap index 32f240211..d62d1c26e 100644 --- a/test/__snapshots__/fixImportExtensions.test.ts.snap +++ b/test/__snapshots__/fixImportExtensions.test.ts.snap @@ -6,11 +6,6 @@ exports[`import extensions > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts", - "foundDirect.ts", - "foundIndirect/index.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false diff --git a/test/__snapshots__/fixIncompleteTypes.test.ts.snap b/test/__snapshots__/fixIncompleteTypes.test.ts.snap index 8a1ec6ef0..2eff78d54 100644 --- a/test/__snapshots__/fixIncompleteTypes.test.ts.snap +++ b/test/__snapshots__/fixIncompleteTypes.test.ts.snap @@ -6,10 +6,6 @@ exports[`Incomplete types > Implicit generics > incomplete implicit class generi "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts", - "react-like.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -84,9 +80,6 @@ exports[`Incomplete types > Implicit generics > incomplete implicit variable gen "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -161,9 +154,6 @@ exports[`Incomplete types > Interface or type literal generics > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -238,9 +228,6 @@ exports[`Incomplete types > Non-generic Interface as Type argument > options 1`] "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -315,9 +302,6 @@ exports[`Incomplete types > React types > React props from prop types > Optional "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.tsx" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -392,9 +376,6 @@ exports[`Incomplete types > React types > React props from prop types > Optional "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.tsx" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -469,9 +450,6 @@ exports[`Incomplete types > React types > React props from prop types > Optional "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.tsx" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -546,9 +524,6 @@ exports[`Incomplete types > React types > React props from prop types > all > op "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.tsx" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -623,14 +598,9 @@ exports[`Incomplete types > React types > not react props > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react" - }, - "files": [ - "actual.tsx" - ], + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -705,14 +675,9 @@ exports[`Incomplete types > React types > react prop functions from calls > opti "suppressTypeErrors": false }, "compilerOptions": { - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react" - }, - "files": [ - "actual.tsx" - ], + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -787,9 +752,6 @@ exports[`Incomplete types > React types > react props from later assignments > o "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.tsx" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -864,14 +826,9 @@ exports[`Incomplete types > React types > react props from prop uses > options 1 "suppressTypeErrors": false }, "compilerOptions": { - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react" - }, - "files": [ - "actual.tsx" - ], + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -946,14 +903,9 @@ exports[`Incomplete types > React types > react props missing > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react" - }, - "files": [ - "actual.tsx" - ], + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -1028,9 +980,6 @@ exports[`Incomplete types > parameter types > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -1105,9 +1054,6 @@ exports[`Incomplete types > property declaration types > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -1182,9 +1128,6 @@ exports[`Incomplete types > return types > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true @@ -1261,9 +1204,6 @@ exports[`Incomplete types > variable types > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.tsx" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true diff --git a/test/__snapshots__/fixMissingProperties.test.ts.snap b/test/__snapshots__/fixMissingProperties.test.ts.snap index 37c6aee94..c8584fde8 100644 --- a/test/__snapshots__/fixMissingProperties.test.ts.snap +++ b/test/__snapshots__/fixMissingProperties.test.ts.snap @@ -6,9 +6,6 @@ exports[`Missing properties > missing property accesses > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true diff --git a/test/__snapshots__/fixNoImplicitAny.test.ts.snap b/test/__snapshots__/fixNoImplicitAny.test.ts.snap index 3bba4656e..641568807 100644 --- a/test/__snapshots__/fixNoImplicitAny.test.ts.snap +++ b/test/__snapshots__/fixNoImplicitAny.test.ts.snap @@ -6,9 +6,6 @@ exports[`noImplicitAny > parameters > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": true, "noImplicitThis": false, "strictNullChecks": true @@ -85,9 +82,6 @@ exports[`noImplicitAny > property declarations > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true @@ -164,9 +158,6 @@ exports[`noImplicitAny > variable declarations > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true diff --git a/test/__snapshots__/fixNoImplicitThis.test.ts.snap b/test/__snapshots__/fixNoImplicitThis.test.ts.snap index 107c7fa4e..e7238cdc9 100644 --- a/test/__snapshots__/fixNoImplicitThis.test.ts.snap +++ b/test/__snapshots__/fixNoImplicitThis.test.ts.snap @@ -6,9 +6,6 @@ exports[`noImplicitThis > noImplicitThis > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": true diff --git a/test/__snapshots__/fixNoInferableTypes.test.ts.snap b/test/__snapshots__/fixNoInferableTypes.test.ts.snap index 593589946..677e3ce00 100644 --- a/test/__snapshots__/fixNoInferableTypes.test.ts.snap +++ b/test/__snapshots__/fixNoInferableTypes.test.ts.snap @@ -6,9 +6,6 @@ exports[`No inferable types > parameters > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true @@ -85,9 +82,6 @@ exports[`No inferable types > property declarations > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true @@ -164,9 +158,6 @@ exports[`No inferable types > variable declarations > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true diff --git a/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap b/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap index 7ecbf4039..6bbbaed4c 100644 --- a/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap +++ b/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap @@ -6,15 +6,9 @@ exports[`strictNonNullAssertions > binaryExpressions > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "compilerOptions": { - "strictNullChecks": true - }, - "files": [ - "actual.ts" - ], + "strictNullChecks": true, "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true + "noImplicitThis": false }, "files": { "above": "", @@ -88,9 +82,6 @@ exports[`strictNonNullAssertions > callExpressions > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true @@ -167,9 +158,6 @@ exports[`strictNonNullAssertions > objectLiterals > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true @@ -246,9 +234,6 @@ exports[`strictNonNullAssertions > propertyAccesses > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "files": [ - "actual.ts" - ], "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": true @@ -325,15 +310,9 @@ exports[`strictNonNullAssertions > returnTypes > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "compilerOptions": { - "strictNullChecks": true - }, - "files": [ - "actual.ts" - ], + "strictNullChecks": true, "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true + "noImplicitThis": false }, "files": { "above": "", diff --git a/test/__snapshots__/include.test.ts.snap b/test/__snapshots__/include.test.ts.snap index 42c664ead..fd5779b3b 100644 --- a/test/__snapshots__/include.test.ts.snap +++ b/test/__snapshots__/include.test.ts.snap @@ -6,12 +6,6 @@ exports[`include > asterisk > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "include": [ - "original.ts", - "expected.ts", - "actual.ts" - ], - "compileOnSave": false, "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -38,9 +32,9 @@ exports[`include > asterisk > options 1`] = ` } }, "include": [ - "original.ts", - "expected.ts", - "actual.ts" + "/actual.ts", + "/expected.ts", + "/original.ts" ], "mutators": [ [ @@ -67,8 +61,6 @@ exports[`include > directory > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "include": [], - "compileOnSave": false, "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -94,7 +86,11 @@ exports[`include > directory > options 1`] = ` "propTypesOptionality": "asWritten" } }, - "include": [], + "include": [ + "/actual.ts", + "/expected.ts", + "/original.ts" + ], "mutators": [ [ "./sampleMutator.cjs", diff --git a/test/__snapshots__/infiniteWaveDetection.test.ts.snap b/test/__snapshots__/infiniteWaveDetection.test.ts.snap index 741246989..8929ce4f0 100644 --- a/test/__snapshots__/infiniteWaveDetection.test.ts.snap +++ b/test/__snapshots__/infiniteWaveDetection.test.ts.snap @@ -6,10 +6,6 @@ exports[`Infinite wave detection > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "include": [ - "actual.ts" - ], - "compileOnSave": false, "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -36,7 +32,7 @@ exports[`Infinite wave detection > options 1`] = ` } }, "include": [ - "actual.ts" + "/actual.ts" ], "mutators": [ [ diff --git a/test/__snapshots__/postProcessing.test.ts.snap b/test/__snapshots__/postProcessing.test.ts.snap index bf04506a1..42366ca0d 100644 --- a/test/__snapshots__/postProcessing.test.ts.snap +++ b/test/__snapshots__/postProcessing.test.ts.snap @@ -6,10 +6,6 @@ exports[`Post processing > options 1`] = ` "suppressTypeErrors": false }, "compilerOptions": { - "include": [ - "actual.ts" - ], - "compileOnSave": false, "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -36,7 +32,7 @@ exports[`Post processing > options 1`] = ` } }, "include": [ - "actual.ts" + "/actual.ts" ], "mutators": [ [ diff --git a/test/cases/cleanups/nonTypeErrors/expected.ts b/test/cases/cleanups/nonTypeErrors/expected.ts new file mode 100644 index 000000000..4792d6685 --- /dev/null +++ b/test/cases/cleanups/nonTypeErrors/expected.ts @@ -0,0 +1,4 @@ +import ts from "typescript"; +import config from "./typestat.json"; + +(function () {})(); diff --git a/test/cases/cleanups/nonTypeErrors/original.ts b/test/cases/cleanups/nonTypeErrors/original.ts new file mode 100644 index 000000000..4792d6685 --- /dev/null +++ b/test/cases/cleanups/nonTypeErrors/original.ts @@ -0,0 +1,4 @@ +import ts from "typescript"; +import config from "./typestat.json"; + +(function () {})(); diff --git a/test/cases/cleanups/nonTypeErrors/tsconfig.json b/test/cases/cleanups/nonTypeErrors/tsconfig.json new file mode 100644 index 000000000..2c5f1ded5 --- /dev/null +++ b/test/cases/cleanups/nonTypeErrors/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "strictNullChecks": true, + "resolveJsonModule": true + }, + "files": ["actual.ts"] +} diff --git a/test/cases/cleanups/nonTypeErrors/typestat.json b/test/cases/cleanups/nonTypeErrors/typestat.json new file mode 100644 index 000000000..8a37358a9 --- /dev/null +++ b/test/cases/cleanups/nonTypeErrors/typestat.json @@ -0,0 +1,6 @@ +{ + "cleanups": { + "suppressTypeErrors": true + }, + "projectPath": "./tsconfig.json" +} diff --git a/test/cases/cleanups/suppressTypeErrors/expected.ts b/test/cases/cleanups/suppressTypeErrors/expected.ts index dd07e8f78..76a6f405c 100644 --- a/test/cases/cleanups/suppressTypeErrors/expected.ts +++ b/test/cases/cleanups/suppressTypeErrors/expected.ts @@ -2,6 +2,6 @@ // @ts-expect-error -- TODO: Type 'number' is not assignable to type 'string'. let incorrectSingle: string = 0; -// @ts-expect-error -- TODO: Property 'replace' does not exist on type 'undefined[]'. Property 'values' does not exist on type '{}'. +// @ts-expect-error -- TODO: Property 'replace' does not exist on type 'never[]'. Property 'values' does not exist on type '{}'. let incorrectMultiple: string = [].replace() + {}.values(); })(); diff --git a/test/cleanups.test.ts b/test/cleanups.test.ts index 60a1e687f..704607541 100644 --- a/test/cleanups.test.ts +++ b/test/cleanups.test.ts @@ -14,4 +14,15 @@ describe("Cleanups", () => { await expect(actualContent).toMatchFileSnapshot(expectedFilePath); expect(options).toMatchSnapshot("options"); }); + + it("non-TypeErrors", async () => { + const caseDir = path.join( + import.meta.dirname, + "cases/cleanups/nonTypeErrors", + ); + const { actualContent, expectedFilePath, options } = + await runMutationTest(caseDir); + await expect(actualContent).toMatchFileSnapshot(expectedFilePath); + expect(options).toMatchSnapshot("options"); + }, 6000); }); From 127f303a6662741d4f71c2112c007f46d63722bb Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 19:49:47 +0300 Subject: [PATCH 05/14] suppressTypeErrors: Do not add absolute paths to comments --- src/cleanups/builtin/suppressTypeErrors/index.ts | 10 ++++++++-- src/shared/diagnostics.ts | 16 ++++++++++++++++ .../cleanups/suppressTypeErrors/expected.ts | 5 +++++ .../cleanups/suppressTypeErrors/original.ts | 3 +++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/cleanups/builtin/suppressTypeErrors/index.ts b/src/cleanups/builtin/suppressTypeErrors/index.ts index 928c11c78..60bbeb051 100644 --- a/src/cleanups/builtin/suppressTypeErrors/index.ts +++ b/src/cleanups/builtin/suppressTypeErrors/index.ts @@ -4,7 +4,7 @@ import { DiagnosticWithStart, getLineForDiagnostic, isDiagnosticWithStart, - stringifyDiagnosticMessageText, + userFriendlyDiagnosticMessageText, } from "../../../shared/diagnostics.js"; import { FileMutator } from "../../../shared/fileMutator.js"; @@ -33,8 +33,14 @@ export const suppressRemainingTypeIssues: FileMutator = (request) => { } } + const currentDir = request.services.program.getCurrentDirectory(); + return Array.from(diagnosticsPerLine).map(([line, diagnostics]) => { - const messages = diagnostics.map(stringifyDiagnosticMessageText).join(" "); + const messages = diagnostics + .map((diagnostic) => + userFriendlyDiagnosticMessageText(diagnostic, currentDir), + ) + .join(" "); return { insertion: `// @ts-expect-error -- TODO: ${messages}\n`, range: { diff --git a/src/shared/diagnostics.ts b/src/shared/diagnostics.ts index 4c6a59b92..384884c51 100644 --- a/src/shared/diagnostics.ts +++ b/src/shared/diagnostics.ts @@ -22,3 +22,19 @@ export const stringifyDiagnosticMessageText = (diagnostic: ts.Diagnostic) => { ? diagnostic.messageText : diagnostic.messageText.messageText; }; + +export const userFriendlyDiagnosticMessageText = ( + diagnostic: ts.Diagnostic, + currentDir: string, +) => { + const diagnosticMessage = stringifyDiagnosticMessageText(diagnostic); + if (diagnostic.code === 1259) { + // = Module_0_can_only_be_default_imported_using_the_1_flag + return diagnosticMessage.replace( + /Module '"[^"]*"' can only be default-imported/, + "This module can only be default-imported", + ); + } else { + return diagnosticMessage.replace(currentDir, ""); + } +}; diff --git a/test/cases/cleanups/suppressTypeErrors/expected.ts b/test/cases/cleanups/suppressTypeErrors/expected.ts index 76a6f405c..fb6bdb346 100644 --- a/test/cases/cleanups/suppressTypeErrors/expected.ts +++ b/test/cases/cleanups/suppressTypeErrors/expected.ts @@ -1,3 +1,8 @@ +// @ts-expect-error -- TODO: This module can only be default-imported using the 'esModuleInterop' flag +import ts from "typescript"; +// @ts-expect-error -- TODO: Cannot find module './typestat.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. +import config from "./typestat.json"; + (function () { // @ts-expect-error -- TODO: Type 'number' is not assignable to type 'string'. let incorrectSingle: string = 0; diff --git a/test/cases/cleanups/suppressTypeErrors/original.ts b/test/cases/cleanups/suppressTypeErrors/original.ts index c144374ed..0945363db 100644 --- a/test/cases/cleanups/suppressTypeErrors/original.ts +++ b/test/cases/cleanups/suppressTypeErrors/original.ts @@ -1,3 +1,6 @@ +import ts from "typescript"; +import config from "./typestat.json"; + (function () { let incorrectSingle: string = 0; From 036afca3298f3b3b3985a1a4c6214421047151f9 Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 19:56:28 +0300 Subject: [PATCH 06/14] use internal parseJsonConfigFileContent method --- src/options/parseRawCompilerOptions.ts | 20 ++------------- src/services/createProgramConfiguration.ts | 11 ++------ src/services/parseJsonConfigFileContent.ts | 29 ++++++++-------------- 3 files changed, 15 insertions(+), 45 deletions(-) diff --git a/src/options/parseRawCompilerOptions.ts b/src/options/parseRawCompilerOptions.ts index 6c0b69d94..682917145 100644 --- a/src/options/parseRawCompilerOptions.ts +++ b/src/options/parseRawCompilerOptions.ts @@ -1,6 +1,7 @@ import * as fsp from "node:fs/promises"; import ts from "typescript"; +import { parseJsonConfigFileContent } from "../services/parseJsonConfigFileContent.js"; import { stringifyDiagnosticMessageText } from "../shared/diagnostics.js"; export interface ParsedTsConfig { @@ -23,24 +24,7 @@ export const parseRawCompilerOptions = async ( const config = configResult.config as ParsedTsConfig; // TSConfig includes often come in a glob form like ["src"] - config.include &&= ts.parseJsonConfigFileContent( - config, - { - // eslint-disable-next-line @typescript-eslint/unbound-method - directoryExists: ts.sys.directoryExists, - // eslint-disable-next-line @typescript-eslint/unbound-method - fileExists: ts.sys.fileExists, - getCurrentDirectory: () => process.cwd(), - // eslint-disable-next-line @typescript-eslint/unbound-method - getDirectories: ts.sys.getDirectories, - // eslint-disable-next-line @typescript-eslint/unbound-method - readDirectory: ts.sys.readDirectory, - // eslint-disable-next-line @typescript-eslint/unbound-method - readFile: ts.sys.readFile, - useCaseSensitiveFileNames: true, - }, - cwd, - ).fileNames; + config.include &&= parseJsonConfigFileContent(config, cwd).fileNames; return config; }; diff --git a/src/services/createProgramConfiguration.ts b/src/services/createProgramConfiguration.ts index f9c8b63fa..5d66dc6d0 100644 --- a/src/services/createProgramConfiguration.ts +++ b/src/services/createProgramConfiguration.ts @@ -1,27 +1,20 @@ -import * as fs from "node:fs"; import * as path from "node:path"; import ts from "typescript"; import { TypeStatOptions } from "../options/types.js"; import { collectOptionals, uniquify } from "../shared/arrays.js"; import { normalizeAndSlashify } from "../shared/paths.js"; +import { parseJsonConfigFileContent } from "./parseJsonConfigFileContent.js"; export const createProgramConfiguration = (options: TypeStatOptions) => { // Create a TypeScript configuration using the raw options - const parsedConfiguration = ts.parseJsonConfigFileContent( + const parsedConfiguration = parseJsonConfigFileContent( { compilerOptions: { ...options.compilerOptions, skipLibCheck: true, }, }, - { - fileExists: fs.existsSync, - // eslint-disable-next-line @typescript-eslint/unbound-method - readDirectory: ts.sys.readDirectory, - readFile: (file) => fs.readFileSync(file, "utf8"), - useCaseSensitiveFileNames: true, - }, path.resolve(path.dirname(options.projectPath)), { noEmit: true }, ); diff --git a/src/services/parseJsonConfigFileContent.ts b/src/services/parseJsonConfigFileContent.ts index 4f6149654..370a78480 100644 --- a/src/services/parseJsonConfigFileContent.ts +++ b/src/services/parseJsonConfigFileContent.ts @@ -1,6 +1,3 @@ -import { minimatch } from "minimatch"; -import * as fs from "node:fs"; -import * as path from "node:path"; import ts from "typescript"; export const parseJsonConfigFileContent = ( @@ -11,21 +8,17 @@ export const parseJsonConfigFileContent = ( return ts.parseJsonConfigFileContent( config, { - fileExists: (filePath) => fs.statSync(filePath).isFile(), - readDirectory: (rootDir, extensions, excludes, includes) => - includes - .flatMap((include) => - fs - .readdirSync(path.join(rootDir, include)) - .map((fileName) => path.join(rootDir, include, fileName)), - ) - .filter( - (filePath) => - !excludes?.some((exclude) => minimatch(filePath, exclude)) && - extensions.some((extension) => filePath.endsWith(extension)), - ) - .map((filePath) => path.relative(rootDir, filePath)), - readFile: (filePath) => fs.readFileSync(filePath).toString(), + // eslint-disable-next-line @typescript-eslint/unbound-method + directoryExists: ts.sys.directoryExists, + // eslint-disable-next-line @typescript-eslint/unbound-method + fileExists: ts.sys.fileExists, + getCurrentDirectory: () => process.cwd(), + // eslint-disable-next-line @typescript-eslint/unbound-method + getDirectories: ts.sys.getDirectories, + // eslint-disable-next-line @typescript-eslint/unbound-method + readDirectory: ts.sys.readDirectory, + // eslint-disable-next-line @typescript-eslint/unbound-method + readFile: ts.sys.readFile, useCaseSensitiveFileNames: true, }, cwd, From 9c93d64a0e6e11d5f377ca7e1991b57d4dedce8a Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:14:18 +0300 Subject: [PATCH 07/14] uninstall minimatch --- package.json | 1 - pnpm-lock.yaml | 3 --- 2 files changed, 4 deletions(-) diff --git a/package.json b/package.json index de8971d03..78bc1af5c 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "commander": "^12.0.0", "enquirer": "^2.4.1", "glob": "^10.3.10", - "minimatch": "^9.0.3", "strip-ansi": "^7.1.0", "ts-api-utils": "^1.3.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf032b782..a4f637da6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,9 +26,6 @@ dependencies: glob: specifier: ^10.3.10 version: 10.3.12 - minimatch: - specifier: ^9.0.3 - version: 9.0.4 strip-ansi: specifier: ^7.1.0 version: 7.1.0 From 3f366a5eb27a8f40e848b3dd8b9b5722d6bce3b4 Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:19:47 +0300 Subject: [PATCH 08/14] uninstall @types/minimatch --- package.json | 1 - pnpm-lock.yaml | 3 --- 2 files changed, 4 deletions(-) diff --git a/package.json b/package.json index 78bc1af5c..a7b24fafb 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "devDependencies": { "@types/eslint": "^8.56.6", "@types/glob": "8.1.0", - "@types/minimatch": "^5.1.2", "@types/node": "^20.11.30", "@types/prop-types": "15.7.12", "@types/react": "18.2.74", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a4f637da6..c050920b2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,9 +40,6 @@ devDependencies: '@types/glob': specifier: 8.1.0 version: 8.1.0 - '@types/minimatch': - specifier: ^5.1.2 - version: 5.1.2 '@types/node': specifier: ^20.11.30 version: 20.12.4 From 6a2c6ef91bbe767322460368aa4e9a2838b65c97 Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 21:26:33 +0300 Subject: [PATCH 09/14] fix has no default import message --- src/shared/diagnostics.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/diagnostics.ts b/src/shared/diagnostics.ts index 384884c51..ec8387908 100644 --- a/src/shared/diagnostics.ts +++ b/src/shared/diagnostics.ts @@ -28,11 +28,11 @@ export const userFriendlyDiagnosticMessageText = ( currentDir: string, ) => { const diagnosticMessage = stringifyDiagnosticMessageText(diagnostic); - if (diagnostic.code === 1259) { + if (diagnostic.code === 1192 || diagnostic.code === 1259) { // = Module_0_can_only_be_default_imported_using_the_1_flag return diagnosticMessage.replace( - /Module '"[^"]*"' can only be default-imported/, - "This module can only be default-imported", + /Module '"[^"]*"' (can only be default-imported|has no default export)/, + "This module $1", ); } else { return diagnosticMessage.replace(currentDir, ""); From b2bb914f93c996a8fd4bc1784883b0873139c9ca Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 21:34:45 +0300 Subject: [PATCH 10/14] fix(tests): enable suppressTypeErrors on tests to see is the code generated valid --- .../__snapshots__/customMutators.test.ts.snap | 6 +- test/__snapshots__/files.test.ts.snap | 8 +- test/__snapshots__/filters.test.ts.snap | 6 +- .../fixImportExtensions.test.ts.snap | 2 +- .../fixIncompleteTypes.test.ts.snap | 123 +++++++++++++++--- .../fixMissingProperties.test.ts.snap | 2 +- .../fixNoImplicitAny.test.ts.snap | 6 +- .../fixNoImplicitThis.test.ts.snap | 2 +- .../fixNoInferableTypes.test.ts.snap | 6 +- .../fixStrictNonNullAssertions.test.ts.snap | 10 +- test/__snapshots__/include.test.ts.snap | 4 +- .../infiniteWaveDetection.test.ts.snap | 2 +- .../__snapshots__/postProcessing.test.ts.snap | 2 +- .../cases/custom mutators/empty/typestat.json | 3 + test/cases/custom mutators/one/typestat.json | 3 + test/cases/custom mutators/two/typestat.json | 3 + test/cases/files/above/expected.ts | 1 - test/cases/files/above/typestat.json | 3 + test/cases/files/below/expected.ts | 1 - test/cases/files/below/typestat.json | 3 + test/cases/files/both/expected.ts | 2 - test/cases/files/both/typestat.json | 3 + test/cases/files/empty/typestat.json | 3 + test/cases/filters/empty/typestat.json | 3 + test/cases/filters/one/expected.ts | 2 + test/cases/filters/one/original.ts | 1 + test/cases/filters/one/typestat.json | 3 + test/cases/filters/two/expected.ts | 4 + test/cases/filters/two/original.ts | 2 + test/cases/filters/two/typestat.json | 3 + test/cases/fixes/importExtensions/expected.ts | 6 + .../fixes/importExtensions/typestat.json | 3 + .../typestat.json | 3 + .../typestat.json | 3 + .../typestat.json | 3 + .../typestat.json | 3 + .../parameterTypes/typestat.json | 3 + .../propertyDeclarationTypes/typestat.json | 3 + .../reactTypes/notReactProps/typestat.json | 3 + .../reactPropFunctionsFromCalls/typestat.json | 3 + .../tsconfig.json | 4 + .../typestat.json | 3 + .../reactPropsFromPropTypes/all/expected.tsx | 1 + .../reactPropsFromPropTypes/all/tsconfig.json | 4 + .../reactPropsFromPropTypes/all/typestat.json | 3 + .../optionality/alwaysOptional/tsconfig.json | 4 + .../optionality/alwaysOptional/typestat.json | 3 + .../optionality/alwaysRequired/tsconfig.json | 4 + .../optionality/alwaysRequired/typestat.json | 3 + .../optionality/asWritten/tsconfig.json | 4 + .../optionality/asWritten/typestat.json | 3 + .../reactPropsFromUses/typestat.json | 3 + .../reactPropsMissing/typestat.json | 3 + .../reactVariableTypes/expected.tsx | 11 ++ .../reactVariableTypes/original.tsx | 11 ++ .../reactVariableTypes/tsconfig.json | 8 ++ .../reactVariableTypes/typestat.json | 11 ++ .../incompleteTypes/returnTypes/expected.ts | 3 + .../incompleteTypes/returnTypes/typestat.json | 3 + .../{expected.tsx => expected.ts} | 16 +-- .../{original.tsx => original.ts} | 10 -- .../variableTypes/tsconfig.json | 2 +- .../variableTypes/typestat.json | 3 + .../missingPropertyAccesses/expected.ts | 1 + .../missingPropertyAccesses/typestat.json | 3 + .../noImplicitAny/parameters/expected.ts | 6 + .../noImplicitAny/parameters/typestat.json | 3 + .../propertyDeclarations/typestat.json | 3 + .../variableDeclarations/expected.ts | 8 ++ .../variableDeclarations/typestat.json | 3 + test/cases/fixes/noImplicitThis/typestat.json | 3 + .../noInferableTypes/parameters/typestat.json | 3 + .../propertyDeclarations/typestat.json | 3 + .../variableDeclarations/typestat.json | 3 + .../binaryExpressions/typestat.json | 3 + .../callExpressions/expected.ts | 1 + .../callExpressions/typestat.json | 3 + .../objectLiterals/typestat.json | 3 + .../propertyAccesses/expected.ts | 10 +- .../propertyAccesses/original.ts | 6 +- .../propertyAccesses/typestat.json | 3 + .../returnTypes/typestat.json | 3 + test/cases/include/asterisk/typestat.json | 3 + test/cases/include/directory/typestat.json | 3 + .../infinite wave detection/typestat.json | 3 + test/cases/post processing/expected.ts | 2 - test/cases/post processing/typestat.json | 3 + test/fixIncompleteTypes.test.ts | 11 ++ 88 files changed, 393 insertions(+), 78 deletions(-) create mode 100644 test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/expected.tsx create mode 100644 test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/original.tsx create mode 100644 test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/tsconfig.json create mode 100644 test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/typestat.json rename test/cases/fixes/incompleteTypes/variableTypes/{expected.tsx => expected.ts} (90%) rename test/cases/fixes/incompleteTypes/variableTypes/{original.tsx => original.ts} (96%) diff --git a/test/__snapshots__/customMutators.test.ts.snap b/test/__snapshots__/customMutators.test.ts.snap index 9788b08d2..01675dc1a 100644 --- a/test/__snapshots__/customMutators.test.ts.snap +++ b/test/__snapshots__/customMutators.test.ts.snap @@ -3,7 +3,7 @@ exports[`Custom mutators > empty array > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -77,7 +77,7 @@ exports[`Custom mutators > empty array > options 1`] = ` exports[`Custom mutators > one mutator > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -130,7 +130,7 @@ exports[`Custom mutators > one mutator > options 1`] = ` exports[`Custom mutators > two mutators > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/files.test.ts.snap b/test/__snapshots__/files.test.ts.snap index c693a38a7..e1e5b6af3 100644 --- a/test/__snapshots__/files.test.ts.snap +++ b/test/__snapshots__/files.test.ts.snap @@ -3,7 +3,7 @@ exports[`files > addition above > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -77,7 +77,7 @@ exports[`files > addition above > options 1`] = ` exports[`files > addition below > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -151,7 +151,7 @@ exports[`files > addition below > options 1`] = ` exports[`files > both > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -225,7 +225,7 @@ exports[`files > both > options 1`] = ` exports[`files > empty addition > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/filters.test.ts.snap b/test/__snapshots__/filters.test.ts.snap index 623cbd981..1ed4199bc 100644 --- a/test/__snapshots__/filters.test.ts.snap +++ b/test/__snapshots__/filters.test.ts.snap @@ -3,7 +3,7 @@ exports[`filters > empty > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": true, @@ -79,7 +79,7 @@ exports[`filters > empty > options 1`] = ` exports[`filters > one > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": true, @@ -157,7 +157,7 @@ exports[`filters > one > options 1`] = ` exports[`filters > two > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": true, diff --git a/test/__snapshots__/fixImportExtensions.test.ts.snap b/test/__snapshots__/fixImportExtensions.test.ts.snap index d62d1c26e..0c1a0cf58 100644 --- a/test/__snapshots__/fixImportExtensions.test.ts.snap +++ b/test/__snapshots__/fixImportExtensions.test.ts.snap @@ -3,7 +3,7 @@ exports[`import extensions > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/fixIncompleteTypes.test.ts.snap b/test/__snapshots__/fixIncompleteTypes.test.ts.snap index 2eff78d54..a0700f70c 100644 --- a/test/__snapshots__/fixIncompleteTypes.test.ts.snap +++ b/test/__snapshots__/fixIncompleteTypes.test.ts.snap @@ -3,7 +3,7 @@ exports[`Incomplete types > Implicit generics > incomplete implicit class generics > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -77,7 +77,7 @@ exports[`Incomplete types > Implicit generics > incomplete implicit class generi exports[`Incomplete types > Implicit generics > incomplete implicit variable generics > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -151,7 +151,7 @@ exports[`Incomplete types > Implicit generics > incomplete implicit variable gen exports[`Incomplete types > Interface or type literal generics > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -225,7 +225,7 @@ exports[`Incomplete types > Interface or type literal generics > options 1`] = ` exports[`Incomplete types > Non-generic Interface as Type argument > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -299,9 +299,11 @@ exports[`Incomplete types > Non-generic Interface as Type argument > options 1`] exports[`Incomplete types > React types > React props from prop types > Optionality > always optional > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -373,9 +375,11 @@ exports[`Incomplete types > React types > React props from prop types > Optional exports[`Incomplete types > React types > React props from prop types > Optionality > always required > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -447,9 +451,11 @@ exports[`Incomplete types > React types > React props from prop types > Optional exports[`Incomplete types > React types > React props from prop types > Optionality > as written > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -521,9 +527,11 @@ exports[`Incomplete types > React types > React props from prop types > Optional exports[`Incomplete types > React types > React props from prop types > all > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -595,7 +603,7 @@ exports[`Incomplete types > React types > React props from prop types > all > op exports[`Incomplete types > React types > not react props > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "allowSyntheticDefaultImports": true, @@ -672,7 +680,7 @@ exports[`Incomplete types > React types > not react props > options 1`] = ` exports[`Incomplete types > React types > react prop functions from calls > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "allowSyntheticDefaultImports": true, @@ -749,9 +757,11 @@ exports[`Incomplete types > React types > react prop functions from calls > opti exports[`Incomplete types > React types > react props from later assignments > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", "noImplicitAny": false, "noImplicitThis": false, "strictNullChecks": false @@ -823,7 +833,7 @@ exports[`Incomplete types > React types > react props from later assignments > o exports[`Incomplete types > React types > react props from prop uses > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "allowSyntheticDefaultImports": true, @@ -900,7 +910,7 @@ exports[`Incomplete types > React types > react props from prop uses > options 1 exports[`Incomplete types > React types > react props missing > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "allowSyntheticDefaultImports": true, @@ -974,10 +984,89 @@ exports[`Incomplete types > React types > react props missing > options 1`] = ` }" `; +exports[`Incomplete types > React types > react variable types > options 1`] = ` +"{ + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true + } +}" +`; + exports[`Incomplete types > parameter types > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -1051,7 +1140,7 @@ exports[`Incomplete types > parameter types > options 1`] = ` exports[`Incomplete types > property declaration types > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -1125,7 +1214,7 @@ exports[`Incomplete types > property declaration types > options 1`] = ` exports[`Incomplete types > return types > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -1201,7 +1290,7 @@ exports[`Incomplete types > return types > options 1`] = ` exports[`Incomplete types > variable types > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/fixMissingProperties.test.ts.snap b/test/__snapshots__/fixMissingProperties.test.ts.snap index c8584fde8..ce2489241 100644 --- a/test/__snapshots__/fixMissingProperties.test.ts.snap +++ b/test/__snapshots__/fixMissingProperties.test.ts.snap @@ -3,7 +3,7 @@ exports[`Missing properties > missing property accesses > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/fixNoImplicitAny.test.ts.snap b/test/__snapshots__/fixNoImplicitAny.test.ts.snap index 641568807..d6fecdf4b 100644 --- a/test/__snapshots__/fixNoImplicitAny.test.ts.snap +++ b/test/__snapshots__/fixNoImplicitAny.test.ts.snap @@ -3,7 +3,7 @@ exports[`noImplicitAny > parameters > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": true, @@ -79,7 +79,7 @@ exports[`noImplicitAny > parameters > options 1`] = ` exports[`noImplicitAny > property declarations > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -155,7 +155,7 @@ exports[`noImplicitAny > property declarations > options 1`] = ` exports[`noImplicitAny > variable declarations > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/fixNoImplicitThis.test.ts.snap b/test/__snapshots__/fixNoImplicitThis.test.ts.snap index e7238cdc9..9c53b5147 100644 --- a/test/__snapshots__/fixNoImplicitThis.test.ts.snap +++ b/test/__snapshots__/fixNoImplicitThis.test.ts.snap @@ -3,7 +3,7 @@ exports[`noImplicitThis > noImplicitThis > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/fixNoInferableTypes.test.ts.snap b/test/__snapshots__/fixNoInferableTypes.test.ts.snap index 677e3ce00..edc1f76f1 100644 --- a/test/__snapshots__/fixNoInferableTypes.test.ts.snap +++ b/test/__snapshots__/fixNoInferableTypes.test.ts.snap @@ -3,7 +3,7 @@ exports[`No inferable types > parameters > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -79,7 +79,7 @@ exports[`No inferable types > parameters > options 1`] = ` exports[`No inferable types > property declarations > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -155,7 +155,7 @@ exports[`No inferable types > property declarations > options 1`] = ` exports[`No inferable types > variable declarations > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap b/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap index 6bbbaed4c..d8fb64262 100644 --- a/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap +++ b/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap @@ -3,7 +3,7 @@ exports[`strictNonNullAssertions > binaryExpressions > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "strictNullChecks": true, @@ -79,7 +79,7 @@ exports[`strictNonNullAssertions > binaryExpressions > options 1`] = ` exports[`strictNonNullAssertions > callExpressions > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -155,7 +155,7 @@ exports[`strictNonNullAssertions > callExpressions > options 1`] = ` exports[`strictNonNullAssertions > objectLiterals > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -231,7 +231,7 @@ exports[`strictNonNullAssertions > objectLiterals > options 1`] = ` exports[`strictNonNullAssertions > propertyAccesses > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -307,7 +307,7 @@ exports[`strictNonNullAssertions > propertyAccesses > options 1`] = ` exports[`strictNonNullAssertions > returnTypes > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "strictNullChecks": true, diff --git a/test/__snapshots__/include.test.ts.snap b/test/__snapshots__/include.test.ts.snap index fd5779b3b..ce1fbec06 100644 --- a/test/__snapshots__/include.test.ts.snap +++ b/test/__snapshots__/include.test.ts.snap @@ -3,7 +3,7 @@ exports[`include > asterisk > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, @@ -58,7 +58,7 @@ exports[`include > asterisk > options 1`] = ` exports[`include > directory > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/infiniteWaveDetection.test.ts.snap b/test/__snapshots__/infiniteWaveDetection.test.ts.snap index 8929ce4f0..0903a7e9d 100644 --- a/test/__snapshots__/infiniteWaveDetection.test.ts.snap +++ b/test/__snapshots__/infiniteWaveDetection.test.ts.snap @@ -3,7 +3,7 @@ exports[`Infinite wave detection > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/__snapshots__/postProcessing.test.ts.snap b/test/__snapshots__/postProcessing.test.ts.snap index 42366ca0d..428336ca3 100644 --- a/test/__snapshots__/postProcessing.test.ts.snap +++ b/test/__snapshots__/postProcessing.test.ts.snap @@ -3,7 +3,7 @@ exports[`Post processing > options 1`] = ` "{ "cleanups": { - "suppressTypeErrors": false + "suppressTypeErrors": true }, "compilerOptions": { "noImplicitAny": false, diff --git a/test/cases/custom mutators/empty/typestat.json b/test/cases/custom mutators/empty/typestat.json index d73983394..6baa52f77 100644 --- a/test/cases/custom mutators/empty/typestat.json +++ b/test/cases/custom mutators/empty/typestat.json @@ -1,3 +1,6 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "mutators": [] } diff --git a/test/cases/custom mutators/one/typestat.json b/test/cases/custom mutators/one/typestat.json index b24b1ee59..35cb8b253 100644 --- a/test/cases/custom mutators/one/typestat.json +++ b/test/cases/custom mutators/one/typestat.json @@ -1,3 +1,6 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "mutators": ["./sampleMutator.cjs"] } diff --git a/test/cases/custom mutators/two/typestat.json b/test/cases/custom mutators/two/typestat.json index abbf7b2cd..38215e64a 100644 --- a/test/cases/custom mutators/two/typestat.json +++ b/test/cases/custom mutators/two/typestat.json @@ -1,3 +1,6 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "mutators": ["./mutator1.cjs", "./mutator2.cjs"] } diff --git a/test/cases/files/above/expected.ts b/test/cases/files/above/expected.ts index 0c44e3afc..2ce9b334e 100644 --- a/test/cases/files/above/expected.ts +++ b/test/cases/files/above/expected.ts @@ -1,4 +1,3 @@ -/* Above file */ (function () { let text: string | number; text = 1; diff --git a/test/cases/files/above/typestat.json b/test/cases/files/above/typestat.json index 59e0f05f2..406bcd9f0 100644 --- a/test/cases/files/above/typestat.json +++ b/test/cases/files/above/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "files": { "above": "/* Above file */" }, diff --git a/test/cases/files/below/expected.ts b/test/cases/files/below/expected.ts index e5ed0d49a..2ce9b334e 100644 --- a/test/cases/files/below/expected.ts +++ b/test/cases/files/below/expected.ts @@ -2,4 +2,3 @@ let text: string | number; text = 1; })(); -/* Below file */ diff --git a/test/cases/files/below/typestat.json b/test/cases/files/below/typestat.json index c7cb53a22..52592ba57 100644 --- a/test/cases/files/below/typestat.json +++ b/test/cases/files/below/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "files": { "below": "/* Below file */" }, diff --git a/test/cases/files/both/expected.ts b/test/cases/files/both/expected.ts index 504adb067..2ce9b334e 100644 --- a/test/cases/files/both/expected.ts +++ b/test/cases/files/both/expected.ts @@ -1,6 +1,4 @@ -/* Above file */ (function () { let text: string | number; text = 1; })(); -/* Below file */ diff --git a/test/cases/files/both/typestat.json b/test/cases/files/both/typestat.json index 79b531ee6..e6a21bb05 100644 --- a/test/cases/files/both/typestat.json +++ b/test/cases/files/both/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "files": { "above": "/* Above file */", "below": "/* Below file */" diff --git a/test/cases/files/empty/typestat.json b/test/cases/files/empty/typestat.json index db23342b6..786f69c75 100644 --- a/test/cases/files/empty/typestat.json +++ b/test/cases/files/empty/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "files": { "above": "", "below": "" diff --git a/test/cases/filters/empty/typestat.json b/test/cases/filters/empty/typestat.json index 37854e3a6..c72a33a83 100644 --- a/test/cases/filters/empty/typestat.json +++ b/test/cases/filters/empty/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "filters": [], "fixes": { "incompleteTypes": true, diff --git a/test/cases/filters/one/expected.ts b/test/cases/filters/one/expected.ts index 92fd4f60d..6d9d165d5 100644 --- a/test/cases/filters/one/expected.ts +++ b/test/cases/filters/one/expected.ts @@ -1,5 +1,7 @@ (function () { + // the return type of this function should not be updated function one(): string { +// @ts-expect-error -- TODO: Type 'undefined' is not assignable to type 'string'. return undefined; } diff --git a/test/cases/filters/one/original.ts b/test/cases/filters/one/original.ts index 1c9e9d1f3..5ec2acf85 100644 --- a/test/cases/filters/one/original.ts +++ b/test/cases/filters/one/original.ts @@ -1,4 +1,5 @@ (function () { + // the return type of this function should not be updated function one(): string { return undefined; } diff --git a/test/cases/filters/one/typestat.json b/test/cases/filters/one/typestat.json index 8f5b0bff8..e5d42e725 100644 --- a/test/cases/filters/one/typestat.json +++ b/test/cases/filters/one/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "filters": ["FunctionDeclaration[name.text=one]"], "fixes": { "incompleteTypes": true, diff --git a/test/cases/filters/two/expected.ts b/test/cases/filters/two/expected.ts index 2adb4737a..50db723e0 100644 --- a/test/cases/filters/two/expected.ts +++ b/test/cases/filters/two/expected.ts @@ -2,7 +2,9 @@ class Foo { public value: number = 3; + // the return type of this function should not be updated dispose() { +// @ts-expect-error -- TODO: Type 'null' is not assignable to type 'number'. this.value = null; } } @@ -15,7 +17,9 @@ foo.value = 1; + // the return type of this function should not be updated teardown(() => { +// @ts-expect-error -- TODO: Type 'null' is not assignable to type 'Foo'. foo = null; }); })(); diff --git a/test/cases/filters/two/original.ts b/test/cases/filters/two/original.ts index 2adb4737a..7d35a0f86 100644 --- a/test/cases/filters/two/original.ts +++ b/test/cases/filters/two/original.ts @@ -2,6 +2,7 @@ class Foo { public value: number = 3; + // the return type of this function should not be updated dispose() { this.value = null; } @@ -15,6 +16,7 @@ foo.value = 1; + // the return type of this function should not be updated teardown(() => { foo = null; }); diff --git a/test/cases/filters/two/typestat.json b/test/cases/filters/two/typestat.json index 391a1d440..eb41e18e4 100644 --- a/test/cases/filters/two/typestat.json +++ b/test/cases/filters/two/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "filters": [ "MethodDeclaration[name.text=dispose]", "CallExpression[expression.text=teardown]" diff --git a/test/cases/fixes/importExtensions/expected.ts b/test/cases/fixes/importExtensions/expected.ts index bcdd14321..b47107715 100644 --- a/test/cases/fixes/importExtensions/expected.ts +++ b/test/cases/fixes/importExtensions/expected.ts @@ -1,7 +1,11 @@ +// @ts-expect-error -- TODO: Cannot find module './assets/direct.svg' or its corresponding type declarations. import direct from "./assets/direct.svg"; +// @ts-expect-error -- TODO: Cannot find module './assets/direct.svg' or its corresponding type declarations. export * as direct from "./assets/direct.svg"; +// @ts-expect-error -- TODO: Cannot find module './assets/withIndex.module.scss' or its corresponding type declarations. import * as withIndex from "./assets/withIndex.module.scss"; +// @ts-expect-error -- TODO: Cannot find module './assets/withIndex.module.scss' or its corresponding type declarations. export { withIndex } from "./assets/withIndex.module.scss"; import { foundDirect } from "./foundDirect"; @@ -10,5 +14,7 @@ export { foundDirect } from "./foundDirect"; import { foundIndirect } from "./foundIndirect"; export { foundIndirect } from "./foundIndirect"; +// @ts-expect-error -- TODO: Cannot find module './notfound' or its corresponding type declarations. import { notfound } from "./notfound"; +// @ts-expect-error -- TODO: Cannot find module './notfound' or its corresponding type declarations. export { notfound } from "./notfound"; diff --git a/test/cases/fixes/importExtensions/typestat.json b/test/cases/fixes/importExtensions/typestat.json index 04c1b9dc8..15105ad28 100644 --- a/test/cases/fixes/importExtensions/typestat.json +++ b/test/cases/fixes/importExtensions/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "importExtensions": true } diff --git a/test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitClassGenerics/typestat.json b/test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitClassGenerics/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitClassGenerics/typestat.json +++ b/test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitClassGenerics/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitVariableGenerics/typestat.json b/test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitVariableGenerics/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitVariableGenerics/typestat.json +++ b/test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitVariableGenerics/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/interfaceOrTypeLiteralGenerics/typestat.json b/test/cases/fixes/incompleteTypes/interfaceOrTypeLiteralGenerics/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/interfaceOrTypeLiteralGenerics/typestat.json +++ b/test/cases/fixes/incompleteTypes/interfaceOrTypeLiteralGenerics/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/nonGenericInterfaceAsTypeArgument/typestat.json b/test/cases/fixes/incompleteTypes/nonGenericInterfaceAsTypeArgument/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/nonGenericInterfaceAsTypeArgument/typestat.json +++ b/test/cases/fixes/incompleteTypes/nonGenericInterfaceAsTypeArgument/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/parameterTypes/typestat.json b/test/cases/fixes/incompleteTypes/parameterTypes/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/parameterTypes/typestat.json +++ b/test/cases/fixes/incompleteTypes/parameterTypes/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/propertyDeclarationTypes/typestat.json b/test/cases/fixes/incompleteTypes/propertyDeclarationTypes/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/propertyDeclarationTypes/typestat.json +++ b/test/cases/fixes/incompleteTypes/propertyDeclarationTypes/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/notReactProps/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/notReactProps/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/notReactProps/typestat.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/notReactProps/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropFunctionsFromCalls/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropFunctionsFromCalls/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropFunctionsFromCalls/typestat.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropFunctionsFromCalls/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromLaterAssignments/tsconfig.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromLaterAssignments/tsconfig.json index 8dd234eaf..62f9fc0c6 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromLaterAssignments/tsconfig.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromLaterAssignments/tsconfig.json @@ -1,3 +1,7 @@ { + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react" + }, "files": ["actual.tsx"] } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromLaterAssignments/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromLaterAssignments/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromLaterAssignments/typestat.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromLaterAssignments/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/expected.tsx b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/expected.tsx index 8bc657c8f..84fc2e7b4 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/expected.tsx +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/expected.tsx @@ -129,6 +129,7 @@ interface LaterAssignedComponentProps { } } +// @ts-expect-error -- TODO: Property 'propTypes' does not exist on type 'typeof LaterAssignedComponent'. LaterAssignedComponent.propTypes = { string: PropTypes.string, stringRequired: PropTypes.string.isRequired, diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/tsconfig.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/tsconfig.json index 8dd234eaf..62f9fc0c6 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/tsconfig.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/tsconfig.json @@ -1,3 +1,7 @@ { + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react" + }, "files": ["actual.tsx"] } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/typestat.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/all/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysOptional/tsconfig.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysOptional/tsconfig.json index 8dd234eaf..62f9fc0c6 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysOptional/tsconfig.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysOptional/tsconfig.json @@ -1,3 +1,7 @@ { + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react" + }, "files": ["actual.tsx"] } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysOptional/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysOptional/typestat.json index a5a0aa30d..3313dc202 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysOptional/typestat.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysOptional/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true }, diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysRequired/tsconfig.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysRequired/tsconfig.json index 8dd234eaf..62f9fc0c6 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysRequired/tsconfig.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysRequired/tsconfig.json @@ -1,3 +1,7 @@ { + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react" + }, "files": ["actual.tsx"] } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysRequired/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysRequired/typestat.json index 9485eaf37..983a93541 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysRequired/typestat.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/alwaysRequired/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true }, diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/asWritten/tsconfig.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/asWritten/tsconfig.json index 8dd234eaf..62f9fc0c6 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/asWritten/tsconfig.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/asWritten/tsconfig.json @@ -1,3 +1,7 @@ { + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react" + }, "files": ["actual.tsx"] } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/asWritten/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/asWritten/typestat.json index 91b1e297f..42e8c56e1 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/asWritten/typestat.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromPropTypes/optionality/asWritten/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true }, diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromUses/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromUses/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromUses/typestat.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsFromUses/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsMissing/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsMissing/typestat.json index 1406ae0fa..7d43d990c 100644 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactPropsMissing/typestat.json +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactPropsMissing/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true } diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/expected.tsx b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/expected.tsx new file mode 100644 index 000000000..4b37e4c92 --- /dev/null +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/expected.tsx @@ -0,0 +1,11 @@ +import * as React from "react"; + +(function () { + interface MyComponentProps { + text: string; + } + + const MyComponent: React.FC = ({ text }) => { + return {text}; + }; +})(); diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/original.tsx b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/original.tsx new file mode 100644 index 000000000..4b37e4c92 --- /dev/null +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/original.tsx @@ -0,0 +1,11 @@ +import * as React from "react"; + +(function () { + interface MyComponentProps { + text: string; + } + + const MyComponent: React.FC = ({ text }) => { + return {text}; + }; +})(); diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/tsconfig.json b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/tsconfig.json new file mode 100644 index 000000000..77e283311 --- /dev/null +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react" + }, + "files": ["actual.tsx"] +} diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/typestat.json new file mode 100644 index 000000000..7e8634817 --- /dev/null +++ b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/typestat.json @@ -0,0 +1,11 @@ +{ + "cleanups": { + "suppressTypeErrors": true + }, + "fixes": { + "incompleteTypes": true + }, + "types": { + "strictNullChecks": true + } +} diff --git a/test/cases/fixes/incompleteTypes/returnTypes/expected.ts b/test/cases/fixes/incompleteTypes/returnTypes/expected.ts index 8959e96b7..e9c94190d 100644 --- a/test/cases/fixes/incompleteTypes/returnTypes/expected.ts +++ b/test/cases/fixes/incompleteTypes/returnTypes/expected.ts @@ -85,16 +85,19 @@ return ""; }; +// @ts-expect-error -- TODO: Duplicate function implementation. Type 'boolean | Promise' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. async function navigateTo(): Promise | boolean { return await new Promise(() => ""); } function navigateByUrl(url: string): Promise; +// @ts-expect-error -- TODO: Function implementation name must be 'navigateByUrl'. Duplicate function implementation. Type 'boolean | Promise' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. async function navigateTo(): Promise | boolean { return await navigateByUrl(""); } +// @ts-expect-error -- TODO: Type 'boolean | Promise' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. async function navigateTo2(): Promise | boolean { const navigated = await navigateByUrl(""); return navigated; diff --git a/test/cases/fixes/incompleteTypes/returnTypes/typestat.json b/test/cases/fixes/incompleteTypes/returnTypes/typestat.json index e11c754df..7e8634817 100644 --- a/test/cases/fixes/incompleteTypes/returnTypes/typestat.json +++ b/test/cases/fixes/incompleteTypes/returnTypes/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true }, diff --git a/test/cases/fixes/incompleteTypes/variableTypes/expected.tsx b/test/cases/fixes/incompleteTypes/variableTypes/expected.ts similarity index 90% rename from test/cases/fixes/incompleteTypes/variableTypes/expected.tsx rename to test/cases/fixes/incompleteTypes/variableTypes/expected.ts index 353c9284a..c0344da2e 100644 --- a/test/cases/fixes/incompleteTypes/variableTypes/expected.tsx +++ b/test/cases/fixes/incompleteTypes/variableTypes/expected.ts @@ -4,6 +4,7 @@ import * as React from "react"; // Primitives let givenUndefined = ""; +// @ts-expect-error -- TODO: Type 'undefined' is not assignable to type 'string'. givenUndefined = undefined; let givenUndefinedAsString: string | undefined = ""; @@ -17,6 +18,7 @@ import * as React from "react"; givenNullAndUndefinedHasNull = undefined; let givenNull = ""; +// @ts-expect-error -- TODO: Type 'null' is not assignable to type 'string'. givenNull = null; let givenNullAsString: string | null = ""; @@ -107,12 +109,14 @@ import * as React from "react"; let onlyClassOneExplicitInterface: SampleInterface = new SampleClassOne(); let eitherClassImplicit = new SampleClassOne(); +// @ts-expect-error -- TODO: Type 'SampleClassTwo' is not assignable to type 'SampleClassOne'. eitherClassImplicit = new SampleClassTwo(); let eitherClassExplicit: SampleInterface = new SampleClassOne(); eitherClassExplicit = new SampleClassTwo(); let eitherClassNeedsUnionImplicit = new SampleClassOne(); +// @ts-expect-error -- TODO: Type 'SampleClassTwo' is not assignable to type 'SampleClassOne'. eitherClassNeedsUnionImplicit = new SampleClassTwo(); let eitherClassNeedsUnionExplicit: SampleClassOne | SampleClassTwo = new SampleClassOne(); @@ -123,7 +127,9 @@ import * as React from "react"; eitherClassNeedsUnionExplicitInterface = new SampleClassTwo(); let eitherClassNeedsNullImplicit = new SampleClassOne(); +// @ts-expect-error -- TODO: Type 'SampleClassTwo' is not assignable to type 'SampleClassOne'. eitherClassNeedsNullImplicit = new SampleClassTwo(); +// @ts-expect-error -- TODO: Type 'null' is not assignable to type 'SampleClassOne'. eitherClassNeedsNullImplicit = null; let eitherClassNeedsNullAndClassExplicit: SampleClassOne | null | SampleClassTwo = @@ -187,14 +193,4 @@ import * as React from "react"; let returnsStringOrNumber: (() => string) | (() => number); returnsStringOrNumber = () => ""; returnsStringOrNumber = () => 0; - - // Predeclared functions (React FCs) - - interface MyComponentProps { - text: string; - } - - const MyComponent: React.FC = ({ text }) => { - return {text}; - }; })(); diff --git a/test/cases/fixes/incompleteTypes/variableTypes/original.tsx b/test/cases/fixes/incompleteTypes/variableTypes/original.ts similarity index 96% rename from test/cases/fixes/incompleteTypes/variableTypes/original.tsx rename to test/cases/fixes/incompleteTypes/variableTypes/original.ts index 00532aca4..829a4c5ee 100644 --- a/test/cases/fixes/incompleteTypes/variableTypes/original.tsx +++ b/test/cases/fixes/incompleteTypes/variableTypes/original.ts @@ -187,14 +187,4 @@ import * as React from "react"; let returnsStringOrNumber: Function; returnsStringOrNumber = () => ""; returnsStringOrNumber = () => 0; - - // Predeclared functions (React FCs) - - interface MyComponentProps { - text: string; - } - - const MyComponent: React.FC = ({ text }) => { - return {text}; - }; })(); diff --git a/test/cases/fixes/incompleteTypes/variableTypes/tsconfig.json b/test/cases/fixes/incompleteTypes/variableTypes/tsconfig.json index 8dd234eaf..7de2b9de3 100644 --- a/test/cases/fixes/incompleteTypes/variableTypes/tsconfig.json +++ b/test/cases/fixes/incompleteTypes/variableTypes/tsconfig.json @@ -1,3 +1,3 @@ { - "files": ["actual.tsx"] + "files": ["actual.ts"] } diff --git a/test/cases/fixes/incompleteTypes/variableTypes/typestat.json b/test/cases/fixes/incompleteTypes/variableTypes/typestat.json index e11c754df..7e8634817 100644 --- a/test/cases/fixes/incompleteTypes/variableTypes/typestat.json +++ b/test/cases/fixes/incompleteTypes/variableTypes/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true }, diff --git a/test/cases/fixes/missingProperties/missingPropertyAccesses/expected.ts b/test/cases/fixes/missingProperties/missingPropertyAccesses/expected.ts index 8d6e3c08d..b68b59e78 100644 --- a/test/cases/fixes/missingProperties/missingPropertyAccesses/expected.ts +++ b/test/cases/fixes/missingProperties/missingPropertyAccesses/expected.ts @@ -15,6 +15,7 @@ private _withGetterAndSetter: string; this.givenTwiceSame = 1; this.givenTwiceDifferent = 1; +// @ts-expect-error -- TODO: Type 'undefined' is not assignable to type 'number'. this.givenTwiceDifferent = undefined; } diff --git a/test/cases/fixes/missingProperties/missingPropertyAccesses/typestat.json b/test/cases/fixes/missingProperties/missingPropertyAccesses/typestat.json index 3426e9513..099fe388b 100644 --- a/test/cases/fixes/missingProperties/missingPropertyAccesses/typestat.json +++ b/test/cases/fixes/missingProperties/missingPropertyAccesses/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "missingProperties": true }, diff --git a/test/cases/fixes/noImplicitAny/parameters/expected.ts b/test/cases/fixes/noImplicitAny/parameters/expected.ts index 5bbb9fc21..0bed60e68 100644 --- a/test/cases/fixes/noImplicitAny/parameters/expected.ts +++ b/test/cases/fixes/noImplicitAny/parameters/expected.ts @@ -15,14 +15,17 @@ console.log(abc); } +// @ts-expect-error -- TODO: Argument of type 'string | null' is not assignable to parameter of type 'string'. givenStringOrNullOnStringTypeLater("" as string | null); function givenStringOrUndefinedOnStringTypeLater(abc: string): void { console.log(abc); } +// @ts-expect-error -- TODO: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. givenStringOrUndefinedOnStringTypeLater("" as string | undefined); +// @ts-expect-error -- TODO: Parameter 'abc' implicitly has an 'any' type. function givenNullTypeLater(abc): void { console.log(abc); } @@ -35,18 +38,21 @@ givenUndefinedTypeLater(undefined); +// @ts-expect-error -- TODO: Parameter 'abc' implicitly has an 'any' type. function givenAnyTypeLater(abc): void { console.log(abc); } givenAnyTypeLater({} as any); +// @ts-expect-error -- TODO: Parameter 'abc' implicitly has an 'any' type. function givenEmptyObjectLiteralTypeLater(abc): void { console.log(abc); } givenEmptyObjectLiteralTypeLater({}); +// @ts-expect-error -- TODO: Parameter 'abc' implicitly has an 'any' type. function givenObjectTypeLater(abc): void { console.log(abc); } diff --git a/test/cases/fixes/noImplicitAny/parameters/typestat.json b/test/cases/fixes/noImplicitAny/parameters/typestat.json index 1d3856325..f144bf7c5 100644 --- a/test/cases/fixes/noImplicitAny/parameters/typestat.json +++ b/test/cases/fixes/noImplicitAny/parameters/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "noImplicitAny": true }, diff --git a/test/cases/fixes/noImplicitAny/propertyDeclarations/typestat.json b/test/cases/fixes/noImplicitAny/propertyDeclarations/typestat.json index e11c754df..7e8634817 100644 --- a/test/cases/fixes/noImplicitAny/propertyDeclarations/typestat.json +++ b/test/cases/fixes/noImplicitAny/propertyDeclarations/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true }, diff --git a/test/cases/fixes/noImplicitAny/variableDeclarations/expected.ts b/test/cases/fixes/noImplicitAny/variableDeclarations/expected.ts index 2ca602989..8c85d9f52 100644 --- a/test/cases/fixes/noImplicitAny/variableDeclarations/expected.ts +++ b/test/cases/fixes/noImplicitAny/variableDeclarations/expected.ts @@ -2,6 +2,7 @@ // Primitives let givenUndefined = ""; +// @ts-expect-error -- TODO: Type 'undefined' is not assignable to type 'string'. givenUndefined = undefined; let givenUndefinedAsString: string | undefined = ""; @@ -15,6 +16,7 @@ givenNullAndUndefinedHasNull = undefined; let givenNull = ""; +// @ts-expect-error -- TODO: Type 'null' is not assignable to type 'string'. givenNull = null; let givenNullAsString: string | null = ""; @@ -74,9 +76,11 @@ // Void and undefined +// @ts-expect-error -- TODO: Type 'void' is not assignable to type 'undefined'. let startsUndefinedWithVoid: undefined = ((): void => {})(); let startsUndefinedGivenVoid: undefined; +// @ts-expect-error -- TODO: Type 'void' is not assignable to type 'undefined'. startsUndefinedGivenVoid = ((): void => {})(); let startsVoidWithUndefined: void = undefined; @@ -122,12 +126,14 @@ let onlyClassOneExplicitInterface: SampleInterface = new SampleClassOne(); let eitherClassImplicit = new SampleClassOne(); +// @ts-expect-error -- TODO: Type 'SampleClassTwo' is not assignable to type 'SampleClassOne'. eitherClassImplicit = new SampleClassTwo(); let eitherClassExplicit: SampleInterface = new SampleClassOne(); eitherClassExplicit = new SampleClassTwo(); let eitherClassNeedsUnionImplicit = new SampleClassOne(); +// @ts-expect-error -- TODO: Type 'SampleClassTwo' is not assignable to type 'SampleClassOne'. eitherClassNeedsUnionImplicit = new SampleClassTwo(); let eitherClassNeedsUnionExplicit: SampleClassOne | SampleClassTwo = new SampleClassOne(); @@ -138,7 +144,9 @@ eitherClassNeedsUnionExplicitInterface = new SampleClassTwo(); let eitherClassNeedsNullImplicit = new SampleClassOne(); +// @ts-expect-error -- TODO: Type 'SampleClassTwo' is not assignable to type 'SampleClassOne'. eitherClassNeedsNullImplicit = new SampleClassTwo(); +// @ts-expect-error -- TODO: Type 'null' is not assignable to type 'SampleClassOne'. eitherClassNeedsNullImplicit = null; let eitherClassNeedsNullAndClassExplicit: SampleClassOne | null | SampleClassTwo = diff --git a/test/cases/fixes/noImplicitAny/variableDeclarations/typestat.json b/test/cases/fixes/noImplicitAny/variableDeclarations/typestat.json index e11c754df..7e8634817 100644 --- a/test/cases/fixes/noImplicitAny/variableDeclarations/typestat.json +++ b/test/cases/fixes/noImplicitAny/variableDeclarations/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true }, diff --git a/test/cases/fixes/noImplicitThis/typestat.json b/test/cases/fixes/noImplicitThis/typestat.json index 3944d4ff5..5112c523c 100644 --- a/test/cases/fixes/noImplicitThis/typestat.json +++ b/test/cases/fixes/noImplicitThis/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "noImplicitThis": true }, diff --git a/test/cases/fixes/noInferableTypes/parameters/typestat.json b/test/cases/fixes/noInferableTypes/parameters/typestat.json index 474bec31a..fbf74a5aa 100644 --- a/test/cases/fixes/noInferableTypes/parameters/typestat.json +++ b/test/cases/fixes/noInferableTypes/parameters/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "noInferableTypes": true }, diff --git a/test/cases/fixes/noInferableTypes/propertyDeclarations/typestat.json b/test/cases/fixes/noInferableTypes/propertyDeclarations/typestat.json index 474bec31a..fbf74a5aa 100644 --- a/test/cases/fixes/noInferableTypes/propertyDeclarations/typestat.json +++ b/test/cases/fixes/noInferableTypes/propertyDeclarations/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "noInferableTypes": true }, diff --git a/test/cases/fixes/noInferableTypes/variableDeclarations/typestat.json b/test/cases/fixes/noInferableTypes/variableDeclarations/typestat.json index 474bec31a..fbf74a5aa 100644 --- a/test/cases/fixes/noInferableTypes/variableDeclarations/typestat.json +++ b/test/cases/fixes/noInferableTypes/variableDeclarations/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "noInferableTypes": true }, diff --git a/test/cases/fixes/strictNonNullAssertions/binaryExpressions/typestat.json b/test/cases/fixes/strictNonNullAssertions/binaryExpressions/typestat.json index d8bca1f5b..0716acd53 100644 --- a/test/cases/fixes/strictNonNullAssertions/binaryExpressions/typestat.json +++ b/test/cases/fixes/strictNonNullAssertions/binaryExpressions/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "strictNonNullAssertions": true }, diff --git a/test/cases/fixes/strictNonNullAssertions/callExpressions/expected.ts b/test/cases/fixes/strictNonNullAssertions/callExpressions/expected.ts index cbb6d591a..36272fa85 100644 --- a/test/cases/fixes/strictNonNullAssertions/callExpressions/expected.ts +++ b/test/cases/fixes/strictNonNullAssertions/callExpressions/expected.ts @@ -57,6 +57,7 @@ let textSibling: string | undefined = ""; let textChild: string | undefined = ""; +// @ts-expect-error -- TODO: Argument of type 'undefined' is not assignable to parameter of type 'string'. takesString(emptyExplicitSibling); takesString(emptyImplicitSibling); takesString(textSibling); diff --git a/test/cases/fixes/strictNonNullAssertions/callExpressions/typestat.json b/test/cases/fixes/strictNonNullAssertions/callExpressions/typestat.json index d8bca1f5b..0716acd53 100644 --- a/test/cases/fixes/strictNonNullAssertions/callExpressions/typestat.json +++ b/test/cases/fixes/strictNonNullAssertions/callExpressions/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "strictNonNullAssertions": true }, diff --git a/test/cases/fixes/strictNonNullAssertions/objectLiterals/typestat.json b/test/cases/fixes/strictNonNullAssertions/objectLiterals/typestat.json index d8bca1f5b..0716acd53 100644 --- a/test/cases/fixes/strictNonNullAssertions/objectLiterals/typestat.json +++ b/test/cases/fixes/strictNonNullAssertions/objectLiterals/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "strictNonNullAssertions": true }, diff --git a/test/cases/fixes/strictNonNullAssertions/propertyAccesses/expected.ts b/test/cases/fixes/strictNonNullAssertions/propertyAccesses/expected.ts index 59ad19dd9..713a799a0 100644 --- a/test/cases/fixes/strictNonNullAssertions/propertyAccesses/expected.ts +++ b/test/cases/fixes/strictNonNullAssertions/propertyAccesses/expected.ts @@ -1,15 +1,15 @@ (function () { - declare const value: string | undefined; + let value: string | undefined; value!.length; value?.length; - declare const valueAny: any; + let valueAny: any; valueAny.length; valueAny?.length; - declare const valueAnyOrUndefined: any | undefined; + let valueAnyOrUndefined: any | undefined; valueAnyOrUndefined.length; valueAnyOrUndefined?.length; @@ -58,12 +58,16 @@ givenStringHasUndefined: string | undefined = ""; +// @ts-expect-error -- TODO: Type 'undefined' is not assignable to type 'string'. setToUndefined: string = undefined; +// @ts-expect-error -- TODO: Type 'undefined' is not assignable to type 'string | null'. setToUndefinedHasNull: string | null = undefined; +// @ts-expect-error -- TODO: Type 'null' is not assignable to type 'string'. setToNull: string = null; +// @ts-expect-error -- TODO: Type 'null' is not assignable to type 'string | undefined'. setToNullHasUndefined: string | undefined = null; setToString: string = ""; diff --git a/test/cases/fixes/strictNonNullAssertions/propertyAccesses/original.ts b/test/cases/fixes/strictNonNullAssertions/propertyAccesses/original.ts index c89a90b76..7e4257c13 100644 --- a/test/cases/fixes/strictNonNullAssertions/propertyAccesses/original.ts +++ b/test/cases/fixes/strictNonNullAssertions/propertyAccesses/original.ts @@ -1,15 +1,15 @@ (function () { - declare const value: string | undefined; + let value: string | undefined; value.length; value?.length; - declare const valueAny: any; + let valueAny: any; valueAny.length; valueAny?.length; - declare const valueAnyOrUndefined: any | undefined; + let valueAnyOrUndefined: any | undefined; valueAnyOrUndefined.length; valueAnyOrUndefined?.length; diff --git a/test/cases/fixes/strictNonNullAssertions/propertyAccesses/typestat.json b/test/cases/fixes/strictNonNullAssertions/propertyAccesses/typestat.json index d8bca1f5b..0716acd53 100644 --- a/test/cases/fixes/strictNonNullAssertions/propertyAccesses/typestat.json +++ b/test/cases/fixes/strictNonNullAssertions/propertyAccesses/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "strictNonNullAssertions": true }, diff --git a/test/cases/fixes/strictNonNullAssertions/returnTypes/typestat.json b/test/cases/fixes/strictNonNullAssertions/returnTypes/typestat.json index d8bca1f5b..0716acd53 100644 --- a/test/cases/fixes/strictNonNullAssertions/returnTypes/typestat.json +++ b/test/cases/fixes/strictNonNullAssertions/returnTypes/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "strictNonNullAssertions": true }, diff --git a/test/cases/include/asterisk/typestat.json b/test/cases/include/asterisk/typestat.json index b24b1ee59..35cb8b253 100644 --- a/test/cases/include/asterisk/typestat.json +++ b/test/cases/include/asterisk/typestat.json @@ -1,3 +1,6 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "mutators": ["./sampleMutator.cjs"] } diff --git a/test/cases/include/directory/typestat.json b/test/cases/include/directory/typestat.json index b24b1ee59..35cb8b253 100644 --- a/test/cases/include/directory/typestat.json +++ b/test/cases/include/directory/typestat.json @@ -1,3 +1,6 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "mutators": ["./sampleMutator.cjs"] } diff --git a/test/cases/infinite wave detection/typestat.json b/test/cases/infinite wave detection/typestat.json index dfe7867a0..2157f3e00 100644 --- a/test/cases/infinite wave detection/typestat.json +++ b/test/cases/infinite wave detection/typestat.json @@ -1,3 +1,6 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "mutators": ["./infiniteMutator.cjs"] } diff --git a/test/cases/post processing/expected.ts b/test/cases/post processing/expected.ts index dec736c80..9f6562919 100644 --- a/test/cases/post processing/expected.ts +++ b/test/cases/post processing/expected.ts @@ -1,5 +1,3 @@ -// Processed! - (function () { let missingNumber: string | number = "initial"; diff --git a/test/cases/post processing/typestat.json b/test/cases/post processing/typestat.json index 3800881cd..609bef4f1 100644 --- a/test/cases/post processing/typestat.json +++ b/test/cases/post processing/typestat.json @@ -1,4 +1,7 @@ { + "cleanups": { + "suppressTypeErrors": true + }, "fixes": { "incompleteTypes": true }, diff --git a/test/fixIncompleteTypes.test.ts b/test/fixIncompleteTypes.test.ts index fca441058..408e6d2f6 100644 --- a/test/fixIncompleteTypes.test.ts +++ b/test/fixIncompleteTypes.test.ts @@ -177,6 +177,17 @@ describe("Incomplete types", () => { await expect(actualContent).toMatchFileSnapshot(expectedFilePath); expect(options).toMatchSnapshot("options"); }); + + it("react variable types", async () => { + const caseDir = path.join( + dirname, + "cases/fixes/incompleteTypes/reactTypes/reactVariableTypes", + ); + const { actualContent, expectedFilePath, options } = + await runMutationTest(caseDir); + await expect(actualContent).toMatchFileSnapshot(expectedFilePath); + expect(options).toMatchSnapshot("options"); + }); }); it("return types", async () => { From b404c56f69a40bd998dabf958707382961040000 Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 22:20:18 +0300 Subject: [PATCH 11/14] Add multiple steps to tests that can't be done once --- src/tests/testSetup.ts | 53 +- test/__snapshots__/cleanups.test.ts.snap | 288 +- .../__snapshots__/customMutators.test.ts.snap | 346 +-- test/__snapshots__/files.test.ts.snap | 844 ++++-- test/__snapshots__/filters.test.ts.snap | 442 +-- .../fixImportExtensions.test.ts.snap | 142 +- .../fixIncompleteTypes.test.ts.snap | 2642 +++++++++-------- .../fixMissingProperties.test.ts.snap | 144 +- .../fixNoImplicitAny.test.ts.snap | 432 +-- .../fixNoImplicitThis.test.ts.snap | 144 +- .../fixNoInferableTypes.test.ts.snap | 432 +-- .../fixStrictNonNullAssertions.test.ts.snap | 720 ++--- test/__snapshots__/include.test.ts.snap | 212 +- .../infiniteWaveDetection.test.ts.snap | 102 +- .../__snapshots__/postProcessing.test.ts.snap | 224 +- test/cases/files/above/expected.ts | 1 + test/cases/files/above/typestat.json | 25 +- test/cases/files/below/expected.ts | 1 + test/cases/files/below/typestat.json | 25 +- test/cases/files/both/expected.ts | 2 + test/cases/files/both/typestat.json | 27 +- test/cases/files/empty/typestat.json | 27 +- test/cases/post processing/expected.ts | 2 + test/cases/post processing/typestat.json | 25 +- 24 files changed, 3905 insertions(+), 3397 deletions(-) diff --git a/src/tests/testSetup.ts b/src/tests/testSetup.ts index d88bdf867..345243088 100644 --- a/src/tests/testSetup.ts +++ b/src/tests/testSetup.ts @@ -4,7 +4,10 @@ import path from "node:path"; import { fillOutRawOptions } from "../options/fillOutRawOptions.js"; import { parseRawCompilerOptions } from "../options/parseRawCompilerOptions.js"; -import { RawTypeStatOptions } from "../options/types.js"; +import { + PendingTypeStatOptions, + RawTypeStatOptions, +} from "../options/types.js"; import { createTypeStatProvider } from "../runtime/createTypeStatProvider.js"; export interface MutationTestResult { @@ -34,7 +37,10 @@ export const runMutationTest = async ( await fs.copyFile(originalFile, actualFile); const rawTypeStatOptions = await readFile("typestat.json"); - const rawOptions = JSON.parse(rawTypeStatOptions) as RawTypeStatOptions; + const rawOptions = JSON.parse(rawTypeStatOptions) as + | RawTypeStatOptions + | RawTypeStatOptions[]; + const rawOptionsList = Array.isArray(rawOptions) ? rawOptions : [rawOptions]; const projectPath = path.join(dirPath, "tsconfig.json"); @@ -48,31 +54,38 @@ export const runMutationTest = async ( stdout: () => {}, }; - const pendingOptions = fillOutRawOptions({ - cwd: dirPath, - output, - projectPath, - rawOptions, - tsConfig, - }); + const pendingOptionsList: PendingTypeStatOptions[] = []; - const provider = createTypeStatProvider({ - ...pendingOptions, - fileNames: [actualFile], - }); + for (const mutationOption of rawOptionsList) { + const pendingOptions = fillOutRawOptions({ + cwd: dirPath, + output, + projectPath, + rawOptions: mutationOption, + tsConfig, + }); - await runMutations({ - mutationsProvider: provider, - }); + pendingOptionsList.push(pendingOptions); + + const provider = createTypeStatProvider({ + ...pendingOptions, + fileNames: [actualFile], + }); + + await runMutations({ + mutationsProvider: provider, + }); + } const actualContent = await readFile(actualFileName); const expectFileName = `expected.ts${fileNameSuffix}`; const expectedFilePath = path.join(dirPath, expectFileName); - const optionsSnapshot = JSON.stringify(pendingOptions, null, 2).replaceAll( - dirPath, - "", - ); + const optionsSnapshot = JSON.stringify( + pendingOptionsList, + null, + 2, + ).replaceAll(dirPath, ""); return { actualContent, expectedFilePath, options: optionsSnapshot }; }; diff --git a/test/__snapshots__/cleanups.test.ts.snap b/test/__snapshots__/cleanups.test.ts.snap index 7a0097332..a7f0c3849 100644 --- a/test/__snapshots__/cleanups.test.ts.snap +++ b/test/__snapshots__/cleanups.test.ts.snap @@ -1,151 +1,155 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`Cleanups > non-TypeErrors > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "esModuleInterop": true, - "strictNullChecks": true, - "resolveJsonModule": true, - "noImplicitAny": false, - "noImplicitThis": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "esModuleInterop": true, + "strictNullChecks": true, + "resolveJsonModule": true, + "noImplicitAny": false, + "noImplicitThis": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Cleanups > suppressTypeErrors > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "strictNullChecks": true, - "noImplicitAny": false, - "noImplicitThis": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "strictNullChecks": true, + "noImplicitAny": false, + "noImplicitThis": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; diff --git a/test/__snapshots__/customMutators.test.ts.snap b/test/__snapshots__/customMutators.test.ts.snap index 01675dc1a..03fa0e3ed 100644 --- a/test/__snapshots__/customMutators.test.ts.snap +++ b/test/__snapshots__/customMutators.test.ts.snap @@ -1,182 +1,188 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`Custom mutators > empty array > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Custom mutators > one mutator > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "include": [ - "/actual.ts" - ], - "mutators": [ - [ - "./sampleMutator.cjs", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "include": [ + "/actual.ts" + ], + "mutators": [ + [ + "./sampleMutator.cjs", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Custom mutators > two mutators > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "./mutator1.cjs", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "./mutator1.cjs", + null + ], + [ + "./mutator2.cjs", + null + ] ], - [ - "./mutator2.cjs", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; diff --git a/test/__snapshots__/files.test.ts.snap b/test/__snapshots__/files.test.ts.snap index e1e5b6af3..84b635574 100644 --- a/test/__snapshots__/files.test.ts.snap +++ b/test/__snapshots__/files.test.ts.snap @@ -1,297 +1,589 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`files > addition above > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "/* Above file */", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null +"[ + { + "cleanups": { + "suppressTypeErrors": false + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "/* Above file */", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} }, - "projectPath": "/tsconfig.json", - "types": {} -}" + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`files > addition below > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "/* Below file */", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null +"[ + { + "cleanups": { + "suppressTypeErrors": false + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "/* Below file */", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} }, - "projectPath": "/tsconfig.json", - "types": {} -}" + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`files > both > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "/* Above file */", - "below": "/* Below file */", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null +"[ + { + "cleanups": { + "suppressTypeErrors": false + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "/* Above file */", + "below": "/* Below file */", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} }, - "projectPath": "/tsconfig.json", - "types": {} -}" + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`files > empty addition > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null +"[ + { + "cleanups": { + "suppressTypeErrors": false + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} }, - "projectPath": "/tsconfig.json", - "types": {} -}" + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; diff --git a/test/__snapshots__/filters.test.ts.snap b/test/__snapshots__/filters.test.ts.snap index 1ed4199bc..767100ee5 100644 --- a/test/__snapshots__/filters.test.ts.snap +++ b/test/__snapshots__/filters.test.ts.snap @@ -1,234 +1,240 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`filters > empty > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": true, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": true, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": true, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; exports[`filters > one > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [ - "FunctionDeclaration[name.text=one]" - ], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": true, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": true, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [ + "FunctionDeclaration[name.text=one]" + ], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": true, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; exports[`filters > two > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [ - "MethodDeclaration[name.text=dispose]", - "CallExpression[expression.text=teardown]" - ], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": true, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": true, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [ + "MethodDeclaration[name.text=dispose]", + "CallExpression[expression.text=teardown]" + ], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": true, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; diff --git a/test/__snapshots__/fixImportExtensions.test.ts.snap b/test/__snapshots__/fixImportExtensions.test.ts.snap index 0c1a0cf58..12d2bc915 100644 --- a/test/__snapshots__/fixImportExtensions.test.ts.snap +++ b/test/__snapshots__/fixImportExtensions.test.ts.snap @@ -1,75 +1,77 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`import extensions > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": true, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": true, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; diff --git a/test/__snapshots__/fixIncompleteTypes.test.ts.snap b/test/__snapshots__/fixIncompleteTypes.test.ts.snap index a0700f70c..7d47b83d3 100644 --- a/test/__snapshots__/fixIncompleteTypes.test.ts.snap +++ b/test/__snapshots__/fixIncompleteTypes.test.ts.snap @@ -1,1364 +1,1400 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`Incomplete types > Implicit generics > incomplete implicit class generics > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > Implicit generics > incomplete implicit variable generics > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > Interface or type literal generics > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > Non-generic Interface as Type argument > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > React props from prop types > Optionality > always optional > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "alwaysOptional" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "alwaysOptional" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > React props from prop types > Optionality > always required > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "alwaysRequired" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "alwaysRequired" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > React props from prop types > Optionality > as written > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > React props from prop types > all > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > not react props > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > react prop functions from calls > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > react props from later assignments > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > react props from prop uses > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > react props missing > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > React types > react variable types > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "react", + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; exports[`Incomplete types > parameter types > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > property declaration types > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`Incomplete types > return types > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; exports[`Incomplete types > variable types > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; diff --git a/test/__snapshots__/fixMissingProperties.test.ts.snap b/test/__snapshots__/fixMissingProperties.test.ts.snap index ce2489241..fc8427e39 100644 --- a/test/__snapshots__/fixMissingProperties.test.ts.snap +++ b/test/__snapshots__/fixMissingProperties.test.ts.snap @@ -1,77 +1,79 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`Missing properties > missing property accesses > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": true, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": true, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true + } } -}" +]" `; diff --git a/test/__snapshots__/fixNoImplicitAny.test.ts.snap b/test/__snapshots__/fixNoImplicitAny.test.ts.snap index d6fecdf4b..fa5a82213 100644 --- a/test/__snapshots__/fixNoImplicitAny.test.ts.snap +++ b/test/__snapshots__/fixNoImplicitAny.test.ts.snap @@ -1,229 +1,235 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`noImplicitAny > parameters > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": true, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": true, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": true, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; exports[`noImplicitAny > property declarations > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; exports[`noImplicitAny > variable declarations > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; diff --git a/test/__snapshots__/fixNoImplicitThis.test.ts.snap b/test/__snapshots__/fixNoImplicitThis.test.ts.snap index 9c53b5147..309ecb407 100644 --- a/test/__snapshots__/fixNoImplicitThis.test.ts.snap +++ b/test/__snapshots__/fixNoImplicitThis.test.ts.snap @@ -1,77 +1,79 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`noImplicitThis > noImplicitThis > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": true, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": true, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": true, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": true, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true + } } -}" +]" `; diff --git a/test/__snapshots__/fixNoInferableTypes.test.ts.snap b/test/__snapshots__/fixNoInferableTypes.test.ts.snap index edc1f76f1..5b98e7ba4 100644 --- a/test/__snapshots__/fixNoInferableTypes.test.ts.snap +++ b/test/__snapshots__/fixNoInferableTypes.test.ts.snap @@ -1,229 +1,235 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`No inferable types > parameters > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": true, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": true, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; exports[`No inferable types > property declarations > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": true, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": true, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; exports[`No inferable types > variable declarations > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": true, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": true, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true } -}" +]" `; diff --git a/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap b/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap index d8fb64262..3c4f252f4 100644 --- a/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap +++ b/test/__snapshots__/fixStrictNonNullAssertions.test.ts.snap @@ -1,381 +1,391 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`strictNonNullAssertions > binaryExpressions > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "strictNullChecks": true, - "noImplicitAny": false, - "noImplicitThis": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": true - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "strictNullChecks": true, + "noImplicitAny": false, + "noImplicitThis": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": true + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true + } } -}" +]" `; exports[`strictNonNullAssertions > callExpressions > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": true - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": true + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true + } } -}" +]" `; exports[`strictNonNullAssertions > objectLiterals > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": true - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": true + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true + } } -}" +]" `; exports[`strictNonNullAssertions > propertyAccesses > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": true - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": true + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true + } } -}" +]" `; exports[`strictNonNullAssertions > returnTypes > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "strictNullChecks": true, - "noImplicitAny": false, - "noImplicitThis": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": true - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "strictNullChecks": true, + "noImplicitAny": false, + "noImplicitThis": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": true + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": { + "strictNullChecks": true + } } -}" +]" `; diff --git a/test/__snapshots__/include.test.ts.snap b/test/__snapshots__/include.test.ts.snap index ce1fbec06..6bf18c0b4 100644 --- a/test/__snapshots__/include.test.ts.snap +++ b/test/__snapshots__/include.test.ts.snap @@ -1,111 +1,115 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`include > asterisk > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "include": [ - "/actual.ts", - "/expected.ts", - "/original.ts" - ], - "mutators": [ - [ - "./sampleMutator.cjs", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "include": [ + "/actual.ts", + "/expected.ts", + "/original.ts" + ], + "mutators": [ + [ + "./sampleMutator.cjs", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; exports[`include > directory > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "include": [ - "/actual.ts", - "/expected.ts", - "/original.ts" - ], - "mutators": [ - [ - "./sampleMutator.cjs", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "include": [ + "/actual.ts", + "/expected.ts", + "/original.ts" + ], + "mutators": [ + [ + "./sampleMutator.cjs", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; diff --git a/test/__snapshots__/infiniteWaveDetection.test.ts.snap b/test/__snapshots__/infiniteWaveDetection.test.ts.snap index 0903a7e9d..b810e4b12 100644 --- a/test/__snapshots__/infiniteWaveDetection.test.ts.snap +++ b/test/__snapshots__/infiniteWaveDetection.test.ts.snap @@ -1,54 +1,56 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`Infinite wave detection > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": false, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "include": [ - "/actual.ts" - ], - "mutators": [ - [ - "./infiniteMutator.cjs", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" +"[ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": false, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "include": [ + "/actual.ts" + ], + "mutators": [ + [ + "./infiniteMutator.cjs", + null + ] + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; diff --git a/test/__snapshots__/postProcessing.test.ts.snap b/test/__snapshots__/postProcessing.test.ts.snap index 428336ca3..c5194407e 100644 --- a/test/__snapshots__/postProcessing.test.ts.snap +++ b/test/__snapshots__/postProcessing.test.ts.snap @@ -1,83 +1,159 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`Post processing > options 1`] = ` -"{ - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": false - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "include": [ - "/actual.ts" - ], - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null +"[ + { + "cleanups": { + "suppressTypeErrors": false + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "include": [ + "/actual.ts" ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], + [ + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null + ] ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [ + [ + "node", + "./postProcess.cjs" + ] + ] + }, + "projectPath": "/tsconfig.json", + "types": {} }, - "postProcess": { - "shell": [ + { + "cleanups": { + "suppressTypeErrors": true + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false + }, + "files": { + "above": "", + "below": "", + "renameExtensions": false + }, + "filters": [], + "fixes": { + "importExtensions": false, + "incompleteTypes": true, + "missingProperties": false, + "noImplicitAny": false, + "noImplicitThis": false, + "noInferableTypes": false, + "strictNonNullAssertions": false + }, + "hints": { + "react": { + "propTypes": "whenRequired", + "propTypesOptionality": "asWritten" + } + }, + "include": [ + "/actual.ts" + ], + "mutators": [ + [ + "fixImportExtensions", + null + ], + [ + "fixIncompleteTypes", + null + ], [ - "node", - "./postProcess.cjs" + "fixMissingProperties", + null + ], + [ + "fixNoImplicitAny", + null + ], + [ + "fixNoImplicitThis", + null + ], + [ + "fixNoInferableTypes", + null + ], + [ + "fixStrictNonNullAssertions", + null ] - ] - }, - "projectPath": "/tsconfig.json", - "types": {} -}" + ], + "output": {}, + "package": { + "directory": "", + "file": "/package.json" + }, + "postProcess": { + "shell": [] + }, + "projectPath": "/tsconfig.json", + "types": {} + } +]" `; diff --git a/test/cases/files/above/expected.ts b/test/cases/files/above/expected.ts index 2ce9b334e..0c44e3afc 100644 --- a/test/cases/files/above/expected.ts +++ b/test/cases/files/above/expected.ts @@ -1,3 +1,4 @@ +/* Above file */ (function () { let text: string | number; text = 1; diff --git a/test/cases/files/above/typestat.json b/test/cases/files/above/typestat.json index 406bcd9f0..3e8d6345f 100644 --- a/test/cases/files/above/typestat.json +++ b/test/cases/files/above/typestat.json @@ -1,11 +1,18 @@ -{ - "cleanups": { - "suppressTypeErrors": true +[ + { + "files": { + "above": "/* Above file */" + }, + "fixes": { + "incompleteTypes": true + } }, - "files": { - "above": "/* Above file */" - }, - "fixes": { - "incompleteTypes": true + { + "cleanups": { + "suppressTypeErrors": true + }, + "fixes": { + "incompleteTypes": true + } } -} +] diff --git a/test/cases/files/below/expected.ts b/test/cases/files/below/expected.ts index 2ce9b334e..e5ed0d49a 100644 --- a/test/cases/files/below/expected.ts +++ b/test/cases/files/below/expected.ts @@ -2,3 +2,4 @@ let text: string | number; text = 1; })(); +/* Below file */ diff --git a/test/cases/files/below/typestat.json b/test/cases/files/below/typestat.json index 52592ba57..cbcf3c303 100644 --- a/test/cases/files/below/typestat.json +++ b/test/cases/files/below/typestat.json @@ -1,11 +1,18 @@ -{ - "cleanups": { - "suppressTypeErrors": true +[ + { + "files": { + "below": "/* Below file */" + }, + "fixes": { + "incompleteTypes": true + } }, - "files": { - "below": "/* Below file */" - }, - "fixes": { - "incompleteTypes": true + { + "cleanups": { + "suppressTypeErrors": true + }, + "fixes": { + "incompleteTypes": true + } } -} +] diff --git a/test/cases/files/both/expected.ts b/test/cases/files/both/expected.ts index 2ce9b334e..504adb067 100644 --- a/test/cases/files/both/expected.ts +++ b/test/cases/files/both/expected.ts @@ -1,4 +1,6 @@ +/* Above file */ (function () { let text: string | number; text = 1; })(); +/* Below file */ diff --git a/test/cases/files/both/typestat.json b/test/cases/files/both/typestat.json index e6a21bb05..0e93a4a28 100644 --- a/test/cases/files/both/typestat.json +++ b/test/cases/files/both/typestat.json @@ -1,12 +1,19 @@ -{ - "cleanups": { - "suppressTypeErrors": true +[ + { + "files": { + "above": "/* Above file */", + "below": "/* Below file */" + }, + "fixes": { + "incompleteTypes": true + } }, - "files": { - "above": "/* Above file */", - "below": "/* Below file */" - }, - "fixes": { - "incompleteTypes": true + { + "cleanups": { + "suppressTypeErrors": true + }, + "fixes": { + "incompleteTypes": true + } } -} +] diff --git a/test/cases/files/empty/typestat.json b/test/cases/files/empty/typestat.json index 786f69c75..ff81bbfd3 100644 --- a/test/cases/files/empty/typestat.json +++ b/test/cases/files/empty/typestat.json @@ -1,12 +1,19 @@ -{ - "cleanups": { - "suppressTypeErrors": true +[ + { + "files": { + "above": "", + "below": "" + }, + "fixes": { + "incompleteTypes": true + } }, - "files": { - "above": "", - "below": "" - }, - "fixes": { - "incompleteTypes": true + { + "cleanups": { + "suppressTypeErrors": true + }, + "fixes": { + "incompleteTypes": true + } } -} +] diff --git a/test/cases/post processing/expected.ts b/test/cases/post processing/expected.ts index 9f6562919..dec736c80 100644 --- a/test/cases/post processing/expected.ts +++ b/test/cases/post processing/expected.ts @@ -1,3 +1,5 @@ +// Processed! + (function () { let missingNumber: string | number = "initial"; diff --git a/test/cases/post processing/typestat.json b/test/cases/post processing/typestat.json index 609bef4f1..0c00640b6 100644 --- a/test/cases/post processing/typestat.json +++ b/test/cases/post processing/typestat.json @@ -1,11 +1,18 @@ -{ - "cleanups": { - "suppressTypeErrors": true +[ + { + "fixes": { + "incompleteTypes": true + }, + "postProcess": { + "shell": [["node", "./postProcess.cjs"]] + } }, - "fixes": { - "incompleteTypes": true - }, - "postProcess": { - "shell": [["node", "./postProcess.cjs"]] + { + "cleanups": { + "suppressTypeErrors": true + }, + "fixes": { + "incompleteTypes": true + } } -} +] From 14f84d32c1c4ff6ebb4030ee5785dfa2d043dea2 Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 22:48:52 +0300 Subject: [PATCH 12/14] fix some returntypes tests --- .../fixes/incompleteTypes/returnTypes/expected.ts | 14 +++++--------- .../fixes/incompleteTypes/returnTypes/original.ts | 11 ++++------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/test/cases/fixes/incompleteTypes/returnTypes/expected.ts b/test/cases/fixes/incompleteTypes/returnTypes/expected.ts index e9c94190d..bb6ec4218 100644 --- a/test/cases/fixes/incompleteTypes/returnTypes/expected.ts +++ b/test/cases/fixes/incompleteTypes/returnTypes/expected.ts @@ -85,22 +85,18 @@ return ""; }; -// @ts-expect-error -- TODO: Duplicate function implementation. Type 'boolean | Promise' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. +// @ts-expect-error -- TODO: Type 'boolean | Promise' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. async function navigateTo(): Promise | boolean { - return await new Promise(() => ""); + return await new Promise(() => {}); } - function navigateByUrl(url: string): Promise; - -// @ts-expect-error -- TODO: Function implementation name must be 'navigateByUrl'. Duplicate function implementation. Type 'boolean | Promise' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. - async function navigateTo(): Promise | boolean { - return await navigateByUrl(""); + async function navigateByUrl(url: string): Promise { + return Promise.resolve(true); } // @ts-expect-error -- TODO: Type 'boolean | Promise' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. async function navigateTo2(): Promise | boolean { - const navigated = await navigateByUrl(""); - return navigated; + return await navigateByUrl(""); } async function returnSame(): Promise { diff --git a/test/cases/fixes/incompleteTypes/returnTypes/original.ts b/test/cases/fixes/incompleteTypes/returnTypes/original.ts index 381dd531d..7b239fbb1 100644 --- a/test/cases/fixes/incompleteTypes/returnTypes/original.ts +++ b/test/cases/fixes/incompleteTypes/returnTypes/original.ts @@ -86,18 +86,15 @@ }; async function navigateTo(): Promise { - return await new Promise(() => ""); + return await new Promise(() => {}); } - function navigateByUrl(url: string): Promise; - - async function navigateTo(): Promise { - return await navigateByUrl(""); + async function navigateByUrl(url: string): Promise { + return Promise.resolve(true); } async function navigateTo2(): Promise { - const navigated = await navigateByUrl(""); - return navigated; + return await navigateByUrl(""); } async function returnSame(): Promise { From 735f0d48b75f0efd2c7d2431a061b05fd6416469 Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 22:50:17 +0300 Subject: [PATCH 13/14] remove unnecessary tests added in earlier commit --- .../reactTypes/reactVariableTypes/expected.tsx | 11 ----------- .../reactTypes/reactVariableTypes/original.tsx | 11 ----------- .../reactTypes/reactVariableTypes/tsconfig.json | 8 -------- .../reactTypes/reactVariableTypes/typestat.json | 11 ----------- test/fixIncompleteTypes.test.ts | 11 ----------- 5 files changed, 52 deletions(-) delete mode 100644 test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/expected.tsx delete mode 100644 test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/original.tsx delete mode 100644 test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/tsconfig.json delete mode 100644 test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/typestat.json diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/expected.tsx b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/expected.tsx deleted file mode 100644 index 4b37e4c92..000000000 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/expected.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import * as React from "react"; - -(function () { - interface MyComponentProps { - text: string; - } - - const MyComponent: React.FC = ({ text }) => { - return {text}; - }; -})(); diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/original.tsx b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/original.tsx deleted file mode 100644 index 4b37e4c92..000000000 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/original.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import * as React from "react"; - -(function () { - interface MyComponentProps { - text: string; - } - - const MyComponent: React.FC = ({ text }) => { - return {text}; - }; -})(); diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/tsconfig.json b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/tsconfig.json deleted file mode 100644 index 77e283311..000000000 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react" - }, - "files": ["actual.tsx"] -} diff --git a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/typestat.json b/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/typestat.json deleted file mode 100644 index 7e8634817..000000000 --- a/test/cases/fixes/incompleteTypes/reactTypes/reactVariableTypes/typestat.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "cleanups": { - "suppressTypeErrors": true - }, - "fixes": { - "incompleteTypes": true - }, - "types": { - "strictNullChecks": true - } -} diff --git a/test/fixIncompleteTypes.test.ts b/test/fixIncompleteTypes.test.ts index 408e6d2f6..fca441058 100644 --- a/test/fixIncompleteTypes.test.ts +++ b/test/fixIncompleteTypes.test.ts @@ -177,17 +177,6 @@ describe("Incomplete types", () => { await expect(actualContent).toMatchFileSnapshot(expectedFilePath); expect(options).toMatchSnapshot("options"); }); - - it("react variable types", async () => { - const caseDir = path.join( - dirname, - "cases/fixes/incompleteTypes/reactTypes/reactVariableTypes", - ); - const { actualContent, expectedFilePath, options } = - await runMutationTest(caseDir); - await expect(actualContent).toMatchFileSnapshot(expectedFilePath); - expect(options).toMatchSnapshot("options"); - }); }); it("return types", async () => { From 3a66f23911c48e06be25ab9b606da5ca4e708dc5 Mon Sep 17 00:00:00 2001 From: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com> Date: Sun, 7 Apr 2024 23:43:03 +0300 Subject: [PATCH 14/14] fix timeout and remove obsolete snapshot --- .../fixIncompleteTypes.test.ts.snap | 81 ------------------- test/files.test.ts | 8 +- 2 files changed, 4 insertions(+), 85 deletions(-) diff --git a/test/__snapshots__/fixIncompleteTypes.test.ts.snap b/test/__snapshots__/fixIncompleteTypes.test.ts.snap index 7d47b83d3..b5ea13de9 100644 --- a/test/__snapshots__/fixIncompleteTypes.test.ts.snap +++ b/test/__snapshots__/fixIncompleteTypes.test.ts.snap @@ -1010,87 +1010,6 @@ exports[`Incomplete types > React types > react props missing > options 1`] = ` ]" `; -exports[`Incomplete types > React types > react variable types > options 1`] = ` -"[ - { - "cleanups": { - "suppressTypeErrors": true - }, - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "react", - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true - }, - "files": { - "above": "", - "below": "", - "renameExtensions": false - }, - "filters": [], - "fixes": { - "importExtensions": false, - "incompleteTypes": true, - "missingProperties": false, - "noImplicitAny": false, - "noImplicitThis": false, - "noInferableTypes": false, - "strictNonNullAssertions": false - }, - "hints": { - "react": { - "propTypes": "whenRequired", - "propTypesOptionality": "asWritten" - } - }, - "mutators": [ - [ - "fixImportExtensions", - null - ], - [ - "fixIncompleteTypes", - null - ], - [ - "fixMissingProperties", - null - ], - [ - "fixNoImplicitAny", - null - ], - [ - "fixNoImplicitThis", - null - ], - [ - "fixNoInferableTypes", - null - ], - [ - "fixStrictNonNullAssertions", - null - ] - ], - "output": {}, - "package": { - "directory": "", - "file": "/package.json" - }, - "postProcess": { - "shell": [] - }, - "projectPath": "/tsconfig.json", - "types": { - "strictNullChecks": true - } - } -]" -`; - exports[`Incomplete types > parameter types > options 1`] = ` "[ { diff --git a/test/files.test.ts b/test/files.test.ts index dd1ed8d5c..2daeaee34 100644 --- a/test/files.test.ts +++ b/test/files.test.ts @@ -10,7 +10,7 @@ describe("files", () => { await runMutationTest(caseDir); await expect(actualContent).toMatchFileSnapshot(expectedFilePath); expect(options).toMatchSnapshot("options"); - }, 50000); + }, 7000); it("addition below", async () => { const caseDir = path.join(import.meta.dirname, "cases/files/below"); @@ -18,7 +18,7 @@ describe("files", () => { await runMutationTest(caseDir); await expect(actualContent).toMatchFileSnapshot(expectedFilePath); expect(options).toMatchSnapshot("options"); - }, 50000); + }, 7000); it("both", async () => { const caseDir = path.join(import.meta.dirname, "cases/files/both"); @@ -26,7 +26,7 @@ describe("files", () => { await runMutationTest(caseDir); await expect(actualContent).toMatchFileSnapshot(expectedFilePath); expect(options).toMatchSnapshot("options"); - }); + }, 7000); it("empty addition", async () => { const caseDir = path.join(import.meta.dirname, "cases/files/empty"); @@ -34,5 +34,5 @@ describe("files", () => { await runMutationTest(caseDir); await expect(actualContent).toMatchFileSnapshot(expectedFilePath); expect(options).toMatchSnapshot("options"); - }); + }, 7000); });