10000 no-any by abrahamguo · Pull Request #5 · abrahamguo/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content
8000

no-any #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/typescript-estree/src/convert.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// There's lots of funny stuff due to the typing of ts.Node
/* eslint-disable @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access */
import { TypeNode } from '@typescript-eslint/ast-spec';
import * as ts from 'typescript';

import { getDecorators, getModifiers } from './getModifiers';
Expand Down Expand Up @@ -37,7 +37,12 @@ import type {
ParserWeakMapESTreeToTSNode,
} from './parser-options';
import type { SemanticOrSyntacticError } from './semantic-or-syntactic-errors';
import type { TSESTree, TSESTreeToTSNode, TSNode } from './ts-estree';
import {
EstreeToTsNodeTypes,
TSESTree,
TSESTreeToTSNode,
TSNode,
} from './ts-estree';
import { AST_NODE_TYPES } from './ts-estree';

const SyntaxKind = ts.SyntaxKind;
Expand Down Expand Up @@ -253,7 +258,10 @@ export class Converter {
* @param parent parentNode
* @returns the converted ESTree node
*/
private convertChild(child?: ts.Node, parent?: ts.Node): any {
private convertChild<T extends TSESTree.Node>(
child?: EstreeToTsNodeTypes[T['type']],
parent?: ts.Node,
): T {
return this.converter(child, parent, false);
}

Expand Down Expand Up @@ -312,8 +320,8 @@ export class Converter {
type: AST_NODE_TYPES.TSTypeAnnotation,
loc,
range,
typeAnnotation: this.convertChild(child),
} as TSESTree.TSTypeAnnotation;
typeAnnotation: this.convertChild<TypeNode>(child),
};
}

/**
Expand Down
0