lib/rules/no-inferrable-types.js
function reportInferrableType(node, typeNode, initNode) {
            if (!typeNode || !initNode || !typeNode.typeAnnotation) {
                return;
            }

            if (!isInferrable(typeNode, initNode)) {
                return;
            }

            const typeMap = {
                TSBooleanKeyword: "boolean",
                TSNumberKeyword: "number",
                TSStringKeyword: "string",
            };

            const type = typeMap[typeNode.typeAnnotation.type];

            context.report({
                node,
                message:
                    "Type {{type}} trivially inferred from a {{type}} literal, remove type annotation.",
                data: {
                    type,
                },
                fix: fixer => fixer.remove(typeNode),
            });
        }
function reportInferrableType(node, typeNode, initNode) {
            if (!typeNode || !initNode || !typeNode.typeAnnotation) {
                return;
            }

            if (!isInferrable(typeNode, initNode)) {
                return;
            }

            const typeMap = {
                TSBooleanKeyword: "boolean",
                TSNumberKeyword: "number",
                TSStringKeyword: "string",
            };

            const type = typeMap[typeNode.typeAnnotation.type];

            context.report({
                node,
                message:
                    "Type {{type}} trivially inferred from a {{type}} literal, remove type annotation.",
                data: {
                    type,
                },
                fix: fixer => fixer.remove(typeNode),
            });
        }
function reportInferrableType ( node , typeNode , initNode ) { if ( ! typeNode || ! initNode || ! typeNode . typeAnnotation ) { return ; } if ( ! isInferrable ( typeNode , initNode ) ) { return ; } const typeMap = { TSBooleanKeyword : "boolean" , TSNumberKeyword : "number" , TSStringKeyword : "string" , } ; const type = typeMap [ typeNode . typeAnnotation . type ] ; context . report ( { node , message : "Type {{type}} trivially inferred from a {{type}} literal, remove type annotation." , data : { type , } , fix : fixer => fixer . remove ( typeNode ) , } ) ; }
Reports an inferrable type declaration, if any
@param {ASTNode} node the node being visited
@param {ASTNode} typeNode the type annotation node
@param {ASTNode} initNode the initializer node
@returns {void}
Reports an inferrable type declaration if any