New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rehearsal/codefixes

Package Overview
Dependencies
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rehearsal/codefixes - npm Package Compare versions

Comparing version 0.0.37 to 0.0.38

dist/src/base-codefix-collection.d.ts

12

dist/src/2571/index.d.ts

@@ -1,6 +0,10 @@

import { DiagnosticWithLocation } from 'typescript';
import { type FixedFile, FixTransform } from '../fix-transform';
export declare class FixTransform2571 extends FixTransform {
fix: (diagnostic: DiagnosticWithLocation) => FixedFile[];
import { CodeFixAction, Node } from 'typescript';
import { CodeFix, DiagnosticWithContext } from '../types';
export declare class Fix2571 implements CodeFix {
getCodeAction(diagnostic: DiagnosticWithContext): CodeFixAction | undefined;
/**
* Checks if the `node` is a part of property access expression and is a member of the `Error` interface
*/
isPropertyOfErrorInterface(node: Node): boolean;
}
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FixTransform2571 = void 0;
exports.Fix2571 = void 0;
const utils_1 = require("@rehearsal/utils");
const typescript_1 = require("typescript");
const fix_transform_1 = require("../fix-transform");
class FixTransform2571 extends fix_transform_1.FixTransform {
constructor() {
super(...arguments);
this.fix = (diagnostic) => {
const errorNode = (0, utils_1.findNodeAtPosition)(diagnostic.file, diagnostic.start, diagnostic.length);
if (errorNode && (0, typescript_1.isIdentifier)(errorNode) && (0, utils_1.isVariableOfCatchClause)(errorNode)) {
let codeReplacement;
if (isPropertyOfErrorInterface(errorNode.parent)) {
codeReplacement = `(${errorNode.getFullText()} as Error)`;
}
else {
codeReplacement = `(${errorNode.getFullText()} as any)`;
}
const originalText = diagnostic.file.getFullText();
const updatedText = `${originalText.substring(0, diagnostic.start)}${codeReplacement}${originalText.substring(diagnostic.start + errorNode.getFullText().length)}`;
return (0, fix_transform_1.getCodemodData)(diagnostic.file, updatedText, diagnostic.start, codeReplacement, 'replace');
}
else {
return [];
}
};
const types_1 = require("../types");
class Fix2571 {
getCodeAction(diagnostic) {
const errorNode = (0, utils_1.findNodeAtPosition)(diagnostic.file, diagnostic.start, diagnostic.length);
if (!errorNode || !(0, typescript_1.isIdentifier)(errorNode) || !(0, utils_1.isVariableOfCatchClause)(errorNode)) {
return undefined;
}
let codeReplacement = `(${errorNode.getText()} as Error)`;
if (!this.isPropertyOfErrorInterface(errorNode.parent)) {
codeReplacement = `(${errorNode.getText()} as any)`;
}
const changes = utils_1.ChangesFactory.replaceText(diagnostic.file, errorNode.getStart(), errorNode.getWidth(), codeReplacement);
return (0, types_1.createCodeFixAction)('addTypeGuard', [changes], 'Add type guard for an Error object');
}
}
exports.FixTransform2571 = FixTransform2571;
/**
* Checks if the `node` is a part of property access expression and is a member of the `Error` interface
*/
function isPropertyOfErrorInterface(node) {
const errorProps = ['name', 'message', 'stack'];
if ((0, typescript_1.isPropertyAccessExpression)(node)) {
return errorProps.includes(node.name.getText());
/**
* Checks if the `node` is a part of property access expression and is a member of the `Error` interface
*/
isPropertyOfErrorInterface(node) {
const errorProps = ['name', 'message', 'stack'];
if ((0, typescript_1.isPropertyAccessExpression)(node)) {
return errorProps.includes(node.name.getText());
}
return false;
}
return false;
}
exports.Fix2571 = Fix2571;
//# sourceMappingURL=index.js.map

@@ -1,7 +0,9 @@

import { type RehearsalService } from '@rehearsal/service';
import type { DiagnosticWithLocation } from 'typescript';
import { type FixedFile, FixTransform } from '../fix-transform';
export declare class FixTransform2790 extends FixTransform {
fix: (diagnostic: DiagnosticWithLocation, service: RehearsalService) => FixedFile[];
import { CodeFixAction } from 'typescript';
import { CodeFix, DiagnosticWithContext } from '../types';
import type { PropertyDeclaration, SourceFile, TypeElement } from 'typescript';
export declare class Fix2790 implements CodeFix {
getCodeAction(diagnostic: DiagnosticWithContext): CodeFixAction | undefined;
findClassMemberDeclaration(sourceFile: SourceFile, typeName: string, memberName: string): PropertyDeclaration | undefined;
findTypeMemberDeclaration(sourceFile: SourceFile, typeName: string, memberName: string): TypeElement | undefined;
}
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FixTransform2790 = void 0;
exports.Fix2790 = void 0;
const utils_1 = require("@rehearsal/utils");
const typescript_1 = require("typescript");
const fix_transform_1 = require("../fix-transform");
const types_1 = require("../types");
const OPTIONAL_TOKEN = '?';
class FixTransform2790 extends fix_transform_1.FixTransform {
constructor() {
super(...arguments);
this.fix = (diagnostic, service) => {
const errorNode = (0, utils_1.findNodeAtPosition)(diagnostic.file, diagnostic.start, diagnostic.length);
if (!errorNode ||
!(0, typescript_1.isPropertyAccessExpression)(errorNode) ||
!(0, typescript_1.isDeleteExpression)(errorNode.parent)) {
return [];
}
const program = service.getLanguageService().getProgram();
const checker = program.getTypeChecker();
const type = checker.getTypeAtLocation(errorNode.expression);
const typeDeclaration = (0, utils_1.getTypeDeclarationFromTypeSymbol)(type);
if (!typeDeclaration) {
return [];
}
const sourceFile = typeDeclaration.getSourceFile();
const typeName = (0, utils_1.getTypeNameFromType)(type, checker); //'Person' as in 'Interface Person' or 'Car' as in 'class Car'
const typeMemberName = errorNode.name.getFullText(); //'name' as in 'delete person.name' or 'make' as in 'delete car.make';
if (!typeMemberName || !typeName || !sourceFile) {
return [];
}
let nameEnd;
if (type.isClass()) {
const classMemberDeclaration = findClassMemberDeclaration(sourceFile, typeName, typeMemberName);
nameEnd =
classMemberDeclaration && classMemberDeclaration.name.getEnd();
}
else {
const typeMemberDeclaration = findTypeMemberDeclaration(sourceFile, typeName, typeMemberName);
nameEnd = typeMemberDeclaration && typeMemberDeclaration.name.getEnd();
}
if (!nameEnd) {
return [];
}
const updatedText = (0, utils_1.insertIntoText)(sourceFile.getFullText(), nameEnd, OPTIONAL_TOKEN);
return (0, fix_transform_1.getCodemodData)(sourceFile, updatedText, nameEnd, OPTIONAL_TOKEN, 'add');
};
class Fix2790 {
getCodeAction(diagnostic) {
const errorNode = (0, utils_1.findNodeAtPosition)(diagnostic.file, diagnostic.start, diagnostic.length);
if (!errorNode ||
!(0, typescript_1.isPropertyAccessExpression)(errorNode) ||
!(0, typescript_1.isDeleteExpression)(errorNode.parent)) {
return undefined;
}
const checker = diagnostic.checker;
const type = checker.getTypeAtLocation(errorNode.expression);
const typeDeclaration = (0, utils_1.getTypeDeclarationFromTypeSymbol)(type);
if (!typeDeclaration) {
return undefined;
}
const sourceFile = typeDeclaration.getSourceFile();
const typeName = (0, utils_1.getTypeNameFromType)(type, checker); //'Person' as in 'Interface Person' or 'Car' as in 'class Car'
const typeMemberName = errorNode.name.getText(); //'name' as in 'delete person.name' or 'make' as in 'delete car.make';
if (!typeMemberName || !typeName || !sourceFile) {
return undefined;
}
let nameEnd;
if (type.isClass()) {
const classMemberDeclaration = this.findClassMemberDeclaration(sourceFile, typeName, typeMemberName);
nameEnd =
classMemberDeclaration && classMemberDeclaration.name.getEnd();
}
else {
const typeMemberDeclaration = this.findTypeMemberDeclaration(sourceFile, typeName, typeMemberName);
nameEnd = typeMemberDeclaration && typeMemberDeclaration.name.getEnd();
}
if (!nameEnd) {
return undefined;
}
const changes = utils_1.ChangesFactory.insertText(sourceFile, nameEnd, OPTIONAL_TOKEN);
return (0, types_1.createCodeFixAction)('makeMemberOptional', [changes], 'Make member optional');
}
}
exports.FixTransform2790 = FixTransform2790;
function findClassMemberDeclaration(sourceFile, typeName, memberName) {
let matchedMember;
const matchedClass = (0, utils_1.getClassByName)(sourceFile, typeName);
if (matchedClass) {
matchedMember = (0, utils_1.getClassMemberByName)(matchedClass, memberName);
findClassMemberDeclaration(sourceFile, typeName, memberName) {
let matchedMember;
const matchedClass = (0, utils_1.getClassByName)(sourceFile, typeName);
if (matchedClass) {
matchedMember = (0, utils_1.getClassMemberByName)(matchedClass, memberName);
}
return matchedMember;
}
return matchedMember;
}
function findTypeMemberDeclaration(sourceFile, typeName, memberName) {
const matchedInterface = (0, utils_1.getInterfaceByName)(sourceFile, typeName);
const matchedTypeAlias = (0, utils_1.getTypeAliasByName)(sourceFile, typeName);
const matchedType = matchedInterface || matchedTypeAlias;
let matchedMember;
if (matchedType && (0, typescript_1.isInterfaceDeclaration)(matchedType)) {
matchedMember = (0, utils_1.getInterfaceMemberByName)(matchedType, memberName);
findTypeMemberDeclaration(sourceFile, typeName, memberName) {
const matchedInterface = (0, utils_1.getInterfaceByName)(sourceFile, typeName);
const matchedTypeAlias = (0, utils_1.getTypeAliasByName)(sourceFile, typeName);
const matchedType = matchedInterface || matchedTypeAlias;
let matchedMember;
if (matchedType && (0, typescript_1.isInterfaceDeclaration)(matchedType)) {
matchedMember = (0, utils_1.getInterfaceMemberByName)(matchedType, memberName);
}
else if (matchedType) {
matchedMember = (0, utils_1.getTypeAliasMemberByName)(matchedType, memberName);
}
return matchedMember;
}
else if (matchedType) {
matchedMember = (0, utils_1.getTypeAliasMemberByName)(matchedType, memberName);
}
return matchedMember;
}
exports.Fix2790 = Fix2790;
//# sourceMappingURL=index.js.map

@@ -1,7 +0,13 @@

import type { RehearsalService } from '@rehearsal/service';
import type { DiagnosticWithLocation } from 'typescript';
import { type FixedFile, FixTransform } from '../fix-transform';
export declare class FixTransform4082 extends FixTransform {
fix: (diagnostic: DiagnosticWithLocation, service: RehearsalService) => FixedFile[];
import { CodeFixAction } from 'typescript';
import { CodeFix, DiagnosticWithContext } from '../types';
import type { ExportAssignment, Node, ObjectLiteralExpression, Type, TypeChecker } from 'typescript';
export declare class Fix4082 implements CodeFix {
getCodeAction(diagnostic: DiagnosticWithContext): CodeFixAction | undefined;
getTargetTypeName(message: string): string | undefined;
findParentTypeInExportAssignment(exportAssignment: ExportAssignment, targetTypeString: string, checker: TypeChecker): Type | undefined;
findTypeInObjectLiteralExpression(expression: ObjectLiteralExpression, targetTypeStr: string, checker: TypeChecker): Type | undefined;
findNodeByText(node: Node, text: string): Node | undefined;
findTargetTypeInParentType(targetTypeString: string, parentType: Type, checker: TypeChecker): Type | undefined;
findTypeInCompositeType(type: Type, subTypeString: string, checker: TypeChecker): Type | undefined;
}
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FixTransform4082 = void 0;
exports.Fix4082 = void 0;
const utils_1 = require("@rehearsal/utils");
const typescript_1 = require("typescript");
const fix_transform_1 = require("../fix-transform");
const types_1 = require("../types");
const EXPORT_KEYWORD_WITH_SPACE = 'export ';
class FixTransform4082 extends fix_transform_1.FixTransform {
constructor() {
super(...arguments);
this.fix = (diagnostic, service) => {
const program = service.getLanguageService().getProgram();
const checker = program.getTypeChecker();
const errorNode = (0, utils_1.findNodeAtPosition)(diagnostic.file, diagnostic.start, diagnostic.length);
if (!errorNode || !(0, typescript_1.isExportAssignment)(errorNode)) {
return [];
}
/**
* For example, targetTypeString is 'Props'
* typeType is the type object that corresponds to targetTypeString
* parentType is the type object that has the type string of: '({ name: string, age: number} : Props): JXS.Element'
**/
const message = (0, typescript_1.flattenDiagnosticMessageText)(diagnostic.messageText, '. ');
const targetTypeString = getTargetTypeName(message);
if (!targetTypeString) {
return [];
}
const parentType = findParentTypeInExportAssignment(errorNode, targetTypeString, checker);
if (!parentType) {
return [];
}
const targetType = findTargetTypeInParentType(targetTypeString, parentType, checker);
const targetTypeDeclaration = targetType && (0, utils_1.getTypeDeclarationFromTypeSymbol)(targetType);
if (!targetTypeDeclaration) {
return [];
}
const sourceFile = targetTypeDeclaration.getSourceFile();
const updatedText = (0, utils_1.insertIntoText)(sourceFile.getFullText(), targetTypeDeclaration.getStart(), EXPORT_KEYWORD_WITH_SPACE);
return (0, fix_transform_1.getCodemodData)(sourceFile, updatedText, targetTypeDeclaration.getStart(), EXPORT_KEYWORD_WITH_SPACE, 'add');
};
class Fix4082 {
getCodeAction(diagnostic) {
const errorNode = (0, utils_1.findNodeAtPosition)(diagnostic.file, diagnostic.start, diagnostic.length);
if (!errorNode || !(0, typescript_1.isExportAssignment)(errorNode)) {
return undefined;
}
/**
* For example, targetTypeString is 'Props'
* typeType is the type object that corresponds to targetTypeString
* parentType is the type object that has the type string of: '({ name: string, age: number} : Props): JXS.Element'
**/
const message = (0, typescript_1.flattenDiagnosticMessageText)(diagnostic.messageText, '. ');
const targetTypeString = this.getTargetTypeName(message);
if (!targetTypeString) {
return undefined;
}
const parentType = this.findParentTypeInExportAssignment(errorNode, targetTypeString, diagnostic.checker);
if (!parentType) {
return undefined;
}
const targetType = this.findTargetTypeInParentType(targetTypeString, parentType, diagnostic.checker);
const targetTypeDeclaration = targetType && (0, utils_1.getTypeDeclarationFromTypeSymbol)(targetType);
if (!targetTypeDeclaration) {
return undefined;
}
const changes = utils_1.ChangesFactory.insertText(targetTypeDeclaration.getSourceFile(), targetTypeDeclaration.getStart(), EXPORT_KEYWORD_WITH_SPACE);
return (0, types_1.createCodeFixAction)('addMissingExport', [changes], 'Add the export keyword to missing type');
}
}
exports.FixTransform4082 = FixTransform4082;
function getTargetTypeName(message) {
const matches = message.match(/'([^']+)'/);
if (matches && matches.length > 1) {
return matches[1];
}
return undefined;
}
function findParentTypeInExportAssignment(exportAssignment, targetTypeString, checker) {
const expression = exportAssignment.expression;
let parentType;
if ((0, typescript_1.isObjectLiteralExpression)(expression)) {
parentType = findTypeInObjectLiteralExpression(expression, targetTypeString, checker);
}
else {
parentType = checker.getTypeAtLocation(expression);
}
return parentType;
}
function findTypeInObjectLiteralExpression(expression, targetTypeStr, checker) {
for (const prop of expression.properties) {
const type = checker.getTypeAtLocation(prop.initializer);
if ((0, utils_1.isSubtypeOf)(targetTypeStr, type, checker)) {
return type;
getTargetTypeName(message) {
const matches = message.match(/'([^']+)'/);
if (matches && matches.length > 1) {
return matches[1];
}
return undefined;
}
return undefined;
}
function findNodeByText(node, text) {
const children = Array.from(node.getChildren());
for (const child of children) {
const childText = child.getFullText().trim();
if (childText === text) {
return child;
findParentTypeInExportAssignment(exportAssignment, targetTypeString, checker) {
const expression = exportAssignment.expression;
let parentType;
if ((0, typescript_1.isObjectLiteralExpression)(expression)) {
parentType = this.findTypeInObjectLiteralExpression(expression, targetTypeString, checker);
}
else if (childText.match(new RegExp('\\b' + text + '\\b'))) {
return findNodeByText(child, text);
else {
parentType = checker.getTypeAtLocation(expression);
}
return parentType;
}
return undefined;
}
function findTargetTypeInParentType(targetTypeString, parentType, checker) {
let targetType;
if (parentType.symbol) {
const parentTypeDeclaration = (0, utils_1.getTypeDeclarationFromTypeSymbol)(parentType);
const targetTypeNode = parentTypeDeclaration && findNodeByText(parentTypeDeclaration, targetTypeString);
targetType = targetTypeNode && checker.getTypeAtLocation(targetTypeNode);
}
else {
targetType = findTypeInCompositeType(parentType, targetTypeString, checker);
}
return targetType;
}
function findTypeInCompositeType(type, subTypeString, checker) {
if (!(0, utils_1.isSubtypeOf)(subTypeString, type, checker)) {
findTypeInObjectLiteralExpression(expression, targetTypeStr, checker) {
for (const prop of expression.properties) {
const type = checker.getTypeAtLocation(prop.initializer);
if ((0, utils_1.isSubtypeOf)(targetTypeStr, type, checker)) {
return type;
}
}
return undefined;
}
if (type.isUnionOrIntersection()) {
for (const t of type.types) {
if ((0, utils_1.isTypeMatched)(subTypeString, t)) {
return t;
findNodeByText(node, text) {
const children = Array.from(node.getChildren());
for (const child of children) {
const childText = child.getText();
if (childText === text) {
return child;
}
else if ((0, utils_1.isSubtypeOf)(subTypeString, t, checker)) {
return findTypeInCompositeType(t, subTypeString, checker);
else if (childText.match(new RegExp('\\b' + text + '\\b'))) {
return this.findNodeByText(child, text);
}
}
return undefined;
}
else {
const typeArguments = checker.getTypeArguments(type);
if (typeArguments.length > 0) {
for (const t of typeArguments) {
findTargetTypeInParentType(targetTypeString, parentType, checker) {
let targetType;
if (parentType.symbol) {
const parentTypeDeclaration = (0, utils_1.getTypeDeclarationFromTypeSymbol)(parentType);
const targetTypeNode = parentTypeDeclaration && this.findNodeByText(parentTypeDeclaration, targetTypeString);
targetType = targetTypeNode && checker.getTypeAtLocation(targetTypeNode);
}
else {
targetType = this.findTypeInCompositeType(parentType, targetTypeString, checker);
}
return targetType;
}
findTypeInCompositeType(type, subTypeString, checker) {
if (!(0, utils_1.isSubtypeOf)(subTypeString, type, checker)) {
return undefined;
}
if (type.isUnionOrIntersection()) {
for (const t of type.types) {
if ((0, utils_1.isTypeMatched)(subTypeString, t)) {

@@ -118,20 +98,34 @@ return t;

else if ((0, utils_1.isSubtypeOf)(subTypeString, t, checker)) {
return findTypeInCompositeType(t, subTypeString, checker);
return this.findTypeInCompositeType(t, subTypeString, checker);
}
}
}
const aliasTypeArguments = type.aliasTypeArguments;
if (aliasTypeArguments && aliasTypeArguments.length > 0) {
for (const t of aliasTypeArguments) {
if ((0, utils_1.isTypeMatched)(subTypeString, t)) {
return t;
else {
const typeArguments = checker.getTypeArguments(type);
if (typeArguments.length > 0) {
for (const t of typeArguments) {
if ((0, utils_1.isTypeMatched)(subTypeString, t)) {
return t;
}
else if ((0, utils_1.isSubtypeOf)(subTypeString, t, checker)) {
return this.findTypeInCompositeType(t, subTypeString, checker);
}
}
else if ((0, utils_1.isSubtypeOf)(subTypeString, t, checker)) {
return findTypeInCompositeType(t, subTypeString, checker);
}
const aliasTypeArguments = type.aliasTypeArguments;
if (aliasTypeArguments && aliasTypeArguments.length > 0) {
for (const t of aliasTypeArguments) {
if ((0, utils_1.isTypeMatched)(subTypeString, t)) {
return t;
}
else if ((0, utils_1.isSubtypeOf)(subTypeString, t, checker)) {
return this.findTypeInCompositeType(t, subTypeString, checker);
}
}
}
}
return undefined;
}
return undefined;
}
exports.Fix4082 = Fix4082;
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import { CodeFixCollection } from './codefix-collection';
export declare const codefixes: CodeFixCollection;
import { CodeFixesProvider } from './codefixes-provider';
export declare const codefixes: CodeFixesProvider;
//# sourceMappingURL=codefixes.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.codefixes = void 0;
const utils_1 = require("@rehearsal/utils");
const typescript_1 = require("typescript");
const base_codefix_collection_1 = require("./base-codefix-collection");
const codefixes_provider_1 = require("./codefixes-provider");
const typescript_codefix_collection_1 = require("./typescript-codefix-collection");
const _2571_1 = require("./2571");
const _2790_1 = require("./2790");
const _4082_1 = require("./4082");
const _6133_1 = require("./6133");
const _7006_1 = require("./7006");
const codefix_collection_1 = require("./codefix-collection");
exports.codefixes = new codefix_collection_1.CodeFixCollection({
2322: {
hint: `Type '{0}' is being returned or assigned, but type '{1}' is expected. Please convert type '{0}' to type '{1}', or return or assign a variable of type '{1}'`,
helpUrl: 'https://stackoverflow.com/questions/72139358/ts2322-type-typeof-statusenum-is-not-assignable-to-type-statusenum',
hints: [
{
when: (n) => (0, typescript_1.isReturnStatement)(n),
hint: `The function expects to return '{1}', but '{0}' is returned. Please convert '{0}' value to '{1}' or update the function's return type.`,
},
{
when: (n) => (0, typescript_1.isIdentifier)(n),
hint: `The variable '{node.escapedText}' has type '{1}', but '{0}' is assigned. Please convert '{0}' to '{1}' or change variable's type.`,
},
],
},
2345: {
hint: `Argument of type '{0}' is not assignable to parameter of type '{1}'.`,
hints: [
{
when: (n, _, c) => (0, utils_1.getTypeNameFromVariable)(n, c) === 'unknown',
hint: `Argument of type '{0}' is not assignable to parameter of type '{1}'. Consider specifying type of argument to be '{1}', using type assertion: '({node.fullText} as {1})', or using type guard: 'if ({node.fullText} instanceof {1}) { ... }'.`,
},
{
when: (n, _, c) => (0, utils_1.getTypeNameFromVariable)(n, c) !== 'unknown',
hint: `Argument of type '{0}' is not assignable to parameter of type '{1}'. Consider verifying both types, using type assertion: '({node.fullText} as string)', or using type guard: 'if ({node.fullText} instanceof string) { ... }'.`,
},
],
helpUrl: 'https://stackoverflow.com/questions/42421501/error-ts2345-argument-of-type-t-is-not-assignable-to-parameter-of-type-objec',
},
2571: {
codefix: new _2571_1.FixTransform2571(),
helpUrl: 'https://stackoverflow.com/questions/65603803/typescript-object-is-of-type-unknown-ts2571',
hint: `Object is of type '{0}'. Specify a type of variable, use type assertion: \`(variable as DesiredType)\` or type guard: \`if (variable instanceof DesiredType) { ... }\``,
hints: [
{
when: (n) => !(0, typescript_1.isIdentifier)(n) || !(0, utils_1.isVariableOfCatchClause)(n),
hint: `Object is of type '{0}'. Specify a type of {node.text}, use type assertion: \`({node.text} as DesiredType)\` or type guard: \`if ({node.text} instanceof DesiredType) { ... }\``,
},
],
},
2790: {
codefix: new _2790_1.FixTransform2790(),
hint: `The operand of a 'delete' operator must be optional.`,
helpUrl: 'https://stackoverflow.com/questions/67266323/the-operand-of-a-delete-operator-must-be-optional-ts2790-while-creating-a-fo',
},
4082: {
codefix: new _4082_1.FixTransform4082(),
hint: `Default export of the module has or is using private name {0}.`,
helpUrl: 'https://github.com/microsoft/TypeScript/issues/6307',
},
6133: {
codefix: new _6133_1.FixTransform6133(),
hint: `The declaration '{0}' is never read or used. Remove the declaration or use it.`,
helpUrl: 'https://stackoverflow.com/search?tab=votes&q=TS6133',
hints: [
{
when: (n) => (0, typescript_1.isIdentifier)(n) && (0, typescript_1.isFunctionDeclaration)(n.parent),
hint: `The function '{0}' is never called. Remove the function or use it.`,
},
{
when: (n) => (0, typescript_1.isIdentifier)(n) && (0, typescript_1.isParameter)(n.parent),
hint: `The parameter '{0}' is never used. Remove the parameter from function definition or use it.`,
},
{
when: (n) => (0, typescript_1.isIdentifier)(n),
hint: `The variable '{0}' is never read or used. Remove the variable or use it.`,
},
],
},
7006: {
codefix: new _7006_1.FixTransform7006(),
hint: `Parameter '{0}' implicitly has an '{1}' type.`,
helpUrl: 'https://stackoverflow.com/questions/43064221/typescript-ts7006-parameter-xxx-implicitly-has-an-any-type',
},
});
exports.codefixes = new codefixes_provider_1.CodeFixesProvider([
new base_codefix_collection_1.BaseCodeFixCollection({
2571: new _2571_1.Fix2571(),
2790: new _2790_1.Fix2790(),
4082: new _4082_1.Fix4082(),
}),
new typescript_codefix_collection_1.TypescriptCodeFixCollection(),
]);
//# sourceMappingURL=codefixes.js.map

@@ -1,4 +0,4 @@

export * from './codefix-collection';
export * from './codefixes';
export * from './fix-transform';
export { codefixes } from './codefixes';
export { hints } from './hints';
export * from './types';
//# sourceMappingURL=index.d.ts.map

@@ -17,5 +17,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./codefix-collection"), exports);
__exportStar(require("./codefixes"), exports);
__exportStar(require("./fix-transform"), exports);
exports.hints = exports.codefixes = void 0;
var codefixes_1 = require("./codefixes");
Object.defineProperty(exports, "codefixes", { enumerable: true, get: function () { return codefixes_1.codefixes; } });
var hints_1 = require("./hints");
Object.defineProperty(exports, "hints", { enumerable: true, get: function () { return hints_1.hints; } });
__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@rehearsal/codefixes",
"version": "0.0.37",
"version": "0.0.38",
"description": "Rehearsal Dependency Codefixes Collection",

@@ -24,14 +24,4 @@ "keywords": [

],
"scripts": {
"build": "tsc -b",
"lint": "npm-run-all lint:*",
"lint:eslint": "eslint --fix . --ext .ts",
"lint:tsc-src": "tsc --noEmit",
"prepare": "pnpm build",
"test": "vitest --run",
"test:watch": "vitest --coverage --watch"
},
"dependencies": {
"@rehearsal/service": "workspace:*",
"@rehearsal/utils": "workspace:*"
"@rehearsal/utils": "0.0.38"
},

@@ -51,3 +41,10 @@ "devDependencies": {

},
"gitHead": "ac6c24607565fb4dadec860ff690a3025118bc7d"
}
"scripts": {
"build": "tsc -b",
"lint": "npm-run-all lint:*",
"lint:eslint": "eslint --fix . --ext .ts",
"lint:tsc-src": "tsc --noEmit",
"test": "vitest --run",
"test:watch": "vitest --coverage --watch"
}
}

@@ -1,48 +0,40 @@

import { findNodeAtPosition, isVariableOfCatchClause } from '@rehearsal/utils';
import { DiagnosticWithLocation, isIdentifier, isPropertyAccessExpression, Node } from 'typescript';
import { ChangesFactory, findNodeAtPosition, isVariableOfCatchClause } from '@rehearsal/utils';
import { CodeFixAction, isIdentifier, isPropertyAccessExpression, Node } from 'typescript';
import { CodeFix, createCodeFixAction, DiagnosticWithContext } from '../types';
import { type FixedFile, FixTransform, getCodemodData } from '../fix-transform';
export class FixTransform2571 extends FixTransform {
fix = (diagnostic: DiagnosticWithLocation): FixedFile[] => {
export class Fix2571 implements CodeFix {
getCodeAction(diagnostic: DiagnosticWithContext): CodeFixAction | undefined {
const errorNode = findNodeAtPosition(diagnostic.file, diagnostic.start, diagnostic.length);
if (errorNode && isIdentifier(errorNode) && isVariableOfCatchClause(errorNode)) {
let codeReplacement;
if (!errorNode || !isIdentifier(errorNode) || !isVariableOfCatchClause(errorNode)) {
return undefined;
}
if (isPropertyOfErrorInterface(errorNode.parent)) {
codeReplacement = `(${errorNode.getFullText()} as Error)`;
} else {
codeReplacement = `(${errorNode.getFullText()} as any)`;
}
const originalText = diagnostic.file.getFullText();
const updatedText = `${originalText.substring(
0,
diagnostic.start
)}${codeReplacement}${originalText.substring(
diagnostic.start + errorNode.getFullText().length
)}`;
return getCodemodData(
diagnostic.file,
updatedText,
diagnostic.start,
codeReplacement,
'replace'
);
} else {
return [];
let codeReplacement = `(${errorNode.getText()} as Error)`;
if (!this.isPropertyOfErrorInterface(errorNode.parent)) {
codeReplacement = `(${errorNode.getText()} as any)`;
}
};
}
/**
* Checks if the `node` is a part of property access expression and is a member of the `Error` interface
*/
function isPropertyOfErrorInterface(node: Node): boolean {
const errorProps: string[] = ['name', 'message', 'stack'];
const changes = ChangesFactory.replaceText(
diagnostic.file,
errorNode.getStart(),
errorNode.getWidth(),
codeReplacement
);
if (isPropertyAccessExpression(node)) {
return errorProps.includes(node.name.getText());
return createCodeFixAction('addTypeGuard', [changes], 'Add type guard for an Error object');
}
return false;
/**
* Checks if the `node` is a part of property access expression and is a member of the `Error` interface
*/
isPropertyOfErrorInterface(node: Node): boolean {
const errorProps: string[] = ['name', 'message', 'stack'];
if (isPropertyAccessExpression(node)) {
return errorProps.includes(node.name.getText());
}
return false;
}
}

@@ -1,3 +0,3 @@

import { type RehearsalService } from '@rehearsal/service';
import {
ChangesFactory,
findNodeAtPosition,

@@ -12,6 +12,11 @@ getClassByName,

getTypeNameFromType,
insertIntoText,
} from '@rehearsal/utils';
import {
CodeFixAction,
isDeleteExpression,
isInterfaceDeclaration,
isPropertyAccessExpression,
} from 'typescript';
import { CodeFix, createCodeFixAction, DiagnosticWithContext } from '../types';
import type {
DiagnosticWithLocation,
InterfaceDeclaration,

@@ -24,11 +29,9 @@ PropertyDeclaration,

} from 'typescript';
import { isDeleteExpression, isInterfaceDeclaration, isPropertyAccessExpression } from 'typescript';
import { type FixedFile, FixTransform, getCodemodData } from '../fix-transform';
const OPTIONAL_TOKEN = '?';
export class FixTransform2790 extends FixTransform {
fix = (diagnostic: DiagnosticWithLocation, service: RehearsalService): FixedFile[] => {
export class Fix2790 implements CodeFix {
getCodeAction(diagnostic: DiagnosticWithContext): CodeFixAction | undefined {
const errorNode = findNodeAtPosition(diagnostic.file, diagnostic.start, diagnostic.length);
if (

@@ -39,7 +42,6 @@ !errorNode ||

) {
return [];
return undefined;
}
const program = service.getLanguageService().getProgram()!;
const checker = program.getTypeChecker();
const checker = diagnostic.checker;

@@ -50,3 +52,3 @@ const type = checker.getTypeAtLocation(errorNode.expression);

if (!typeDeclaration) {
return [];
return undefined;
}

@@ -57,6 +59,6 @@

const typeName = getTypeNameFromType(type, checker); //'Person' as in 'Interface Person' or 'Car' as in 'class Car'
const typeMemberName = errorNode.name.getFullText(); //'name' as in 'delete person.name' or 'make' as in 'delete car.make';
const typeMemberName = errorNode.name.getText(); //'name' as in 'delete person.name' or 'make' as in 'delete car.make';
if (!typeMemberName || !typeName || !sourceFile) {
return [];
return undefined;
}

@@ -66,3 +68,3 @@

if (type.isClass()) {
const classMemberDeclaration = findClassMemberDeclaration(
const classMemberDeclaration = this.findClassMemberDeclaration(
sourceFile,

@@ -75,3 +77,7 @@ typeName,

} else {
const typeMemberDeclaration = findTypeMemberDeclaration(sourceFile, typeName, typeMemberName);
const typeMemberDeclaration = this.findTypeMemberDeclaration(
sourceFile,
typeName,
typeMemberName
);
nameEnd = typeMemberDeclaration && (typeMemberDeclaration as PropertySignature).name.getEnd();

@@ -81,46 +87,47 @@ }

if (!nameEnd) {
return [];
return undefined;
}
const updatedText = insertIntoText(sourceFile.getFullText(), nameEnd, OPTIONAL_TOKEN);
const changes = ChangesFactory.insertText(sourceFile, nameEnd, OPTIONAL_TOKEN);
return getCodemodData(sourceFile, updatedText, nameEnd, OPTIONAL_TOKEN, 'add');
};
}
return createCodeFixAction('makeMemberOptional', [changes], 'Make member optional');
}
function findClassMemberDeclaration(
sourceFile: SourceFile,
typeName: string,
memberName: string
): PropertyDeclaration | undefined {
let matchedMember;
const matchedClass = getClassByName(sourceFile, typeName);
if (matchedClass) {
matchedMember = getClassMemberByName(matchedClass, memberName);
findClassMemberDeclaration(
sourceFile: SourceFile,
typeName: string,
memberName: string
): PropertyDeclaration | undefined {
let matchedMember;
const matchedClass = getClassByName(sourceFile, typeName);
if (matchedClass) {
matchedMember = getClassMemberByName(matchedClass, memberName);
}
return matchedMember as PropertyDeclaration;
}
return matchedMember as PropertyDeclaration;
}
function findTypeMemberDeclaration(
sourceFile: SourceFile,
typeName: string,
memberName: string
): TypeElement | undefined {
const matchedInterface: InterfaceDeclaration | undefined = getInterfaceByName(
sourceFile,
typeName
);
const matchedTypeAlias: TypeAliasDeclaration | undefined = getTypeAliasByName(
sourceFile,
typeName
);
findTypeMemberDeclaration(
sourceFile: SourceFile,
typeName: string,
memberName: string
): TypeElement | undefined {
const matchedInterface: InterfaceDeclaration | undefined = getInterfaceByName(
sourceFile,
typeName
);
const matchedTypeAlias: TypeAliasDeclaration | undefined = getTypeAliasByName(
sourceFile,
typeName
);
const matchedType = matchedInterface || matchedTypeAlias;
const matchedType = matchedInterface || matchedTypeAlias;
let matchedMember;
if (matchedType && isInterfaceDeclaration(matchedType)) {
matchedMember = getInterfaceMemberByName(matchedType, memberName);
} else if (matchedType) {
matchedMember = getTypeAliasMemberByName(matchedType, memberName);
let matchedMember;
if (matchedType && isInterfaceDeclaration(matchedType)) {
matchedMember = getInterfaceMemberByName(matchedType, memberName);
} else if (matchedType) {
matchedMember = getTypeAliasMemberByName(matchedType, memberName);
}
return matchedMember;
}
return matchedMember;
}

@@ -1,11 +0,16 @@

import type { RehearsalService } from '@rehearsal/service';
import {
ChangesFactory,
findNodeAtPosition,
getTypeDeclarationFromTypeSymbol,
insertIntoText,
isSubtypeOf,
isTypeMatched,
} from '@rehearsal/utils';
import {
CodeFixAction,
flattenDiagnosticMessageText,
isExportAssignment,
isObjectLiteralExpression,
} from 'typescript';
import { CodeFix, createCodeFixAction, DiagnosticWithContext } from '../types';
import type {
DiagnosticWithLocation,
ExportAssignment,

@@ -19,20 +24,10 @@ Node,

} from 'typescript';
import {
flattenDiagnosticMessageText,
isExportAssignment,
isObjectLiteralExpression,
} from 'typescript';
import { type FixedFile, FixTransform, getCodemodData } from '../fix-transform';
const EXPORT_KEYWORD_WITH_SPACE = 'export ';
export class FixTransform4082 extends FixTransform {
fix = (diagnostic: DiagnosticWithLocation, service: RehearsalService): FixedFile[] => {
const program = service.getLanguageService().getProgram()!;
const checker = program.getTypeChecker();
export class Fix4082 implements CodeFix {
getCodeAction(diagnostic: DiagnosticWithContext): CodeFixAction | undefined {
const errorNode = findNodeAtPosition(diagnostic.file, diagnostic.start, diagnostic.length);
if (!errorNode || !isExportAssignment(errorNode)) {
return [];
return undefined;
}

@@ -46,22 +41,31 @@

const message = flattenDiagnosticMessageText(diagnostic.messageText, '. ');
const targetTypeString = getTargetTypeName(message);
const targetTypeString = this.getTargetTypeName(message);
if (!targetTypeString) {
return [];
return undefined;
}
const parentType = findParentTypeInExportAssignment(errorNode, targetTypeString, checker);
const parentType = this.findParentTypeInExportAssignment(
errorNode,
targetTypeString,
diagnostic.checker
);
if (!parentType) {
return [];
return undefined;
}
const targetType = findTargetTypeInParentType(targetTypeString, parentType, checker);
const targetType = this.findTargetTypeInParentType(
targetTypeString,
parentType,
diagnostic.checker
);
const targetTypeDeclaration = targetType && getTypeDeclarationFromTypeSymbol(targetType);
const targetTypeDeclaration = targetType && getTypeDeclarationFromTypeSymbol(targetType);
if (!targetTypeDeclaration) {
return [];
return undefined;
}
const sourceFile = targetTypeDeclaration.getSourceFile();
const updatedText = insertIntoText(
sourceFile.getFullText(),
const changes = ChangesFactory.insertText(
targetTypeDeclaration.getSourceFile(),
targetTypeDeclaration.getStart(),

@@ -71,121 +75,124 @@ EXPORT_KEYWORD_WITH_SPACE

return getCodemodData(
sourceFile,
updatedText,
targetTypeDeclaration.getStart(),
EXPORT_KEYWORD_WITH_SPACE,
'add'
return createCodeFixAction(
'addMissingExport',
[changes],
'Add the export keyword to missing type'
);
};
}
}
function getTargetTypeName(message: string): string | undefined {
const matches = message.match(/'([^']+)'/);
if (matches && matches.length > 1) {
return matches[1];
getTargetTypeName(message: string): string | undefined {
const matches = message.match(/'([^']+)'/);
if (matches && matches.length > 1) {
return matches[1];
}
return undefined;
}
return undefined;
}
function findParentTypeInExportAssignment(
exportAssignment: ExportAssignment,
targetTypeString: string,
checker: TypeChecker
): Type | undefined {
const expression = exportAssignment.expression;
let parentType: Type | undefined;
findParentTypeInExportAssignment(
exportAssignment: ExportAssignment,
targetTypeString: string,
checker: TypeChecker
): Type | undefined {
const expression = exportAssignment.expression;
let parentType: Type | undefined;
if (isObjectLiteralExpression(expression)) {
parentType = this.findTypeInObjectLiteralExpression(expression, targetTypeString, checker);
} else {
parentType = checker.getTypeAtLocation(expression);
}
if (isObjectLiteralExpression(expression)) {
parentType = findTypeInObjectLiteralExpression(expression, targetTypeString, checker);
} else {
parentType = checker.getTypeAtLocation(expression);
return parentType;
}
return parentType;
}
function findTypeInObjectLiteralExpression(
expression: ObjectLiteralExpression,
targetTypeStr: string,
checker: TypeChecker
): Type | undefined {
for (const prop of expression.properties) {
const type = checker.getTypeAtLocation((prop as PropertyAssignment).initializer);
if (isSubtypeOf(targetTypeStr, type, checker)) {
return type;
findTypeInObjectLiteralExpression(
expression: ObjectLiteralExpression,
targetTypeStr: string,
checker: TypeChecker
): Type | undefined {
for (const prop of expression.properties) {
const type = checker.getTypeAtLocation((prop as PropertyAssignment).initializer);
if (isSubtypeOf(targetTypeStr, type, checker)) {
return type;
}
}
return undefined;
}
return undefined;
}
function findNodeByText(node: Node, text: string): Node | undefined {
const children = Array.from(node.getChildren());
for (const child of children) {
const childText = child.getFullText().trim();
if (childText === text) {
return child;
} else if (childText.match(new RegExp('\\b' + text + '\\b'))) {
return findNodeByText(child, text);
findNodeByText(node: Node, text: string): Node | undefined {
const children = Array.from(node.getChildren());
for (const child of children) {
const childText = child.getText();
if (childText === text) {
return child;
} else if (childText.match(new RegExp('\\b' + text + '\\b'))) {
return this.findNodeByText(child, text);
}
}
return undefined;
}
return undefined;
}
function findTargetTypeInParentType(
targetTypeString: string,
parentType: Type,
checker: TypeChecker
): Type | undefined {
let targetType: Type | undefined;
findTargetTypeInParentType(
targetTypeString: string,
parentType: Type,
checker: TypeChecker
): Type | undefined {
let targetType: Type | undefined;
if (parentType.symbol) {
const parentTypeDeclaration = getTypeDeclarationFromTypeSymbol(parentType);
const targetTypeNode =
parentTypeDeclaration && findNodeByText(parentTypeDeclaration, targetTypeString);
targetType = targetTypeNode && checker.getTypeAtLocation(targetTypeNode);
} else {
targetType = findTypeInCompositeType(parentType, targetTypeString, checker);
if (parentType.symbol) {
const parentTypeDeclaration = getTypeDeclarationFromTypeSymbol(parentType);
const targetTypeNode =
parentTypeDeclaration && this.findNodeByText(parentTypeDeclaration, targetTypeString);
targetType = targetTypeNode && checker.getTypeAtLocation(targetTypeNode);
} else {
targetType = this.findTypeInCompositeType(parentType, targetTypeString, checker);
}
return targetType;
}
return targetType;
}
function findTypeInCompositeType(
type: Type,
subTypeString: string,
checker: TypeChecker
): Type | undefined {
if (!isSubtypeOf(subTypeString, type, checker)) {
return undefined;
}
if (type.isUnionOrIntersection()) {
for (const t of type.types) {
if (isTypeMatched(subTypeString, t)) {
return t;
} else if (isSubtypeOf(subTypeString, t, checker)) {
return findTypeInCompositeType(t, subTypeString, checker);
}
findTypeInCompositeType(
type: Type,
subTypeString: string,
checker: TypeChecker
): Type | undefined {
if (!isSubtypeOf(subTypeString, type, checker)) {
return undefined;
}
} else {
const typeArguments = checker.getTypeArguments(type as TypeReference);
if (typeArguments.length > 0) {
for (const t of typeArguments) {
if (type.isUnionOrIntersection()) {
for (const t of type.types) {
if (isTypeMatched(subTypeString, t)) {
return t;
} else if (isSubtypeOf(subTypeString, t, checker)) {
return findTypeInCompositeType(t, subTypeString, checker);
return this.findTypeInCompositeType(t, subTypeString, checker);
}
}
}
} else {
const typeArguments = checker.getTypeArguments(type as TypeReference);
if (typeArguments.length > 0) {
for (const t of typeArguments) {
if (isTypeMatched(subTypeString, t)) {
return t;
} else if (isSubtypeOf(subTypeString, t, checker)) {
return this.findTypeInCompositeType(t, subTypeString, checker);
}
}
}
const aliasTypeArguments = type.aliasTypeArguments;
if (aliasTypeArguments && aliasTypeArguments.length > 0) {
for (const t of aliasTypeArguments) {
if (isTypeMatched(subTypeString, t)) {
return t;
} else if (isSubtypeOf(subTypeString, t, checker)) {
return findTypeInCompositeType(t, subTypeString, checker);
const aliasTypeArguments = type.aliasTypeArguments;
if (aliasTypeArguments && aliasTypeArguments.length > 0) {
for (const t of aliasTypeArguments) {
if (isTypeMatched(subTypeString, t)) {
return t;
} else if (isSubtypeOf(subTypeString, t, checker)) {
return this.findTypeInCompositeType(t, subTypeString, checker);
}
}
}
}
return undefined;
}
return undefined;
}

@@ -1,90 +0,16 @@

import { getTypeNameFromVariable, isVariableOfCatchClause } from '@rehearsal/utils';
import { isFunctionDeclaration, isIdentifier, isParameter, isReturnStatement } from 'typescript';
import { BaseCodeFixCollection } from './base-codefix-collection';
import { CodeFixesProvider } from './codefixes-provider';
import { TypescriptCodeFixCollection } from './typescript-codefix-collection';
import { FixTransform2571 } from './2571';
import { FixTransform2790 } from './2790';
import { FixTransform4082 } from './4082';
import { FixTransform6133 } from './6133';
import { FixTransform7006 } from './7006';
import { CodeFixCollection } from './codefix-collection';
import { Fix2571 } from './2571';
import { Fix2790 } from './2790';
import { Fix4082 } from './4082';
export const codefixes = new CodeFixCollection({
2322: {
hint: `Type '{0}' is being returned or assigned, but type '{1}' is expected. Please convert type '{0}' to type '{1}', or return or assign a variable of type '{1}'`,
helpUrl:
'https://stackoverflow.com/questions/72139358/ts2322-type-typeof-statusenum-is-not-assignable-to-type-statusenum',
hints: [
{
when: (n) => isReturnStatement(n),
hint: `The function expects to return '{1}', but '{0}' is returned. Please convert '{0}' value to '{1}' or update the function's return type.`,
},
{
when: (n) => isIdentifier(n),
hint: `The variable '{node.escapedText}' has type '{1}', but '{0}' is assigned. Please convert '{0}' to '{1}' or change variable's type.`,
},
],
},
2345: {
hint: `Argument of type '{0}' is not assignable to parameter of type '{1}'.`,
hints: [
{
when: (n, _, c) => getTypeNameFromVariable(n, c) === 'unknown',
hint: `Argument of type '{0}' is not assignable to parameter of type '{1}'. Consider specifying type of argument to be '{1}', using type assertion: '({node.fullText} as {1})', or using type guard: 'if ({node.fullText} instanceof {1}) { ... }'.`,
},
{
when: (n, _, c) => getTypeNameFromVariable(n, c) !== 'unknown',
hint: `Argument of type '{0}' is not assignable to parameter of type '{1}'. Consider verifying both types, using type assertion: '({node.fullText} as string)', or using type guard: 'if ({node.fullText} instanceof string) { ... }'.`,
},
],
helpUrl:
'https://stackoverflow.com/questions/42421501/error-ts2345-argument-of-type-t-is-not-assignable-to-parameter-of-type-objec',
},
2571: {
codefix: new FixTransform2571(),
helpUrl:
'https://stackoverflow.com/questions/65603803/typescript-object-is-of-type-unknown-ts2571',
hint: `Object is of type '{0}'. Specify a type of variable, use type assertion: \`(variable as DesiredType)\` or type guard: \`if (variable instanceof DesiredType) { ... }\``,
hints: [
{
when: (n) => !isIdentifier(n) || !isVariableOfCatchClause(n),
hint: `Object is of type '{0}'. Specify a type of {node.text}, use type assertion: \`({node.text} as DesiredType)\` or type guard: \`if ({node.text} instanceof DesiredType) { ... }\``,
},
],
},
2790: {
codefix: new FixTransform2790(),
hint: `The operand of a 'delete' operator must be optional.`,
helpUrl:
'https://stackoverflow.com/questions/67266323/the-operand-of-a-delete-operator-must-be-optional-ts2790-while-creating-a-fo',
},
4082: {
codefix: new FixTransform4082(),
hint: `Default export of the module has or is using private name {0}.`,
helpUrl: 'https://github.com/microsoft/TypeScript/issues/6307',
},
6133: {
codefix: new FixTransform6133(),
hint: `The declaration '{0}' is never read or used. Remove the declaration or use it.`,
helpUrl: 'https://stackoverflow.com/search?tab=votes&q=TS6133',
hints: [
{
when: (n) => isIdentifier(n) && isFunctionDeclaration(n.parent),
hint: `The function '{0}' is never called. Remove the function or use it.`,
},
{
when: (n) => isIdentifier(n) && isParameter(n.parent),
hint: `The parameter '{0}' is never used. Remove the parameter from function definition or use it.`,
},
{
when: (n) => isIdentifier(n),
hint: `The variable '{0}' is never read or used. Remove the variable or use it.`,
},
],
},
7006: {
codefix: new FixTransform7006(),
hint: `Parameter '{0}' implicitly has an '{1}' type.`,
helpUrl:
'https://stackoverflow.com/questions/43064221/typescript-ts7006-parameter-xxx-implicitly-has-an-any-type',
},
});
export const codefixes = new CodeFixesProvider([
new BaseCodeFixCollection({
2571: new Fix2571(),
2790: new Fix2790(),
4082: new Fix4082(),
}),
new TypescriptCodeFixCollection(),
]);

@@ -1,3 +0,3 @@

export * from './codefix-collection';
export * from './codefixes';
export * from './fix-transform';
export { codefixes } from './codefixes';
export { hints } from './hints';
export * from './types';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc