File size: 4,697 Bytes
bc20498 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
import type { RuleContext, ASTNode } from '../../types';
import type * as TS from 'typescript';
export type TypeScript = typeof TS;
export type { TS };
export type TSTools = {
service: {
esTreeNodeToTSNodeMap: ReadonlyMap<unknown, TS.Node>;
tsNodeToESTreeNodeMap: ReadonlyMap<TS.Node, ASTNode>;
program: TS.Program;
hasFullTypeInformation: boolean;
};
ts: TypeScript;
};
/**
* Get TypeScript tools
*/
export declare function getTypeScriptTools(context: RuleContext): TSTools | null;
/**
* Get TypeScript tools
*/
export declare function getTypeScript(context: RuleContext): TypeScript | null;
/**
* Check whether the given type is a truthy literal type or not.
*/
export declare function isTruthyLiteral(type: TS.Type, tsTools: TSTools): boolean;
/**
* Check whether the given type is a falsy type or not.
*/
export declare function isFalsyType(type: TS.Type, tsTools: TSTools): boolean;
/**
* Check whether the given type is a nullish type or not.
*/
export declare function isNullishType(type: TS.Type, ts: TypeScript): boolean;
/**
* Checks whether the given type is nullable or not.
*/
export declare function isNullableType(type: TS.Type, ts: TypeScript): boolean;
/**
* Check whether the given type is a boolean literal type or not.
*/
export declare function isBooleanLiteralType(type: TS.Type, ts: TypeScript): boolean;
/**
* Check whether the given type is an object type or not.
*/
export declare function isObjectType(type: TS.Type, ts: TypeScript): type is TS.ObjectType;
/**
* Check whether the given type is a reference type or not.
*/
export declare function isReferenceObjectType(type: TS.Type, ts: TypeScript): type is TS.TypeReference;
/**
* Check whether the given type is a tuple type or not.
*/
export declare function isTupleObjectType(type: TS.Type, ts: TypeScript): type is TS.TupleType;
/**
* Check whether the given type is a tuple type or not.
* Unlike isTupleObjectType, it also refers to reference types.
*/
export declare function isTupleType(type: TS.Type, ts: TypeScript): boolean;
/**
* Check whether the given type is an any type or not.
*/
export declare function isAnyType(type: TS.Type, ts: TypeScript): boolean;
/**
* Check whether the given type is an unknown type or not.
*/
export declare function isUnknownType(type: TS.Type, ts: TypeScript): boolean;
/**
* Check whether the given type is a never type or not.
*/
export declare function isNeverType(type: TS.Type, ts: TypeScript): boolean;
/**
* Check whether the given type is an undefined type or not.
*/
export declare function isUndefinedType(type: TS.Type, ts: TypeScript): boolean;
/**
* Check whether the given type is a void type or not.
*/
export declare function isVoidType(type: TS.Type, ts: TypeScript): boolean;
/**
* Check whether the given type is a null type or not.
*/
export declare function isNullType(type: TS.Type, ts: TypeScript): boolean;
/**
* Check whether the given type is a possibly falsy type or not.
*/
export declare function isPossiblyFalsyType(type: TS.Type, ts: TypeScript): boolean;
/**
* Get the call signatures from the given type.
* This method is heavily inspired by tsutils. https://github.com/ajafff/tsutils
* The MIT License (MIT) Copyright (c) 2017 Klaus Meinhardt
* https://github.com/ajafff/tsutils/blob/master/LICENSE
*/
export declare function getCallSignaturesOfType(type: TS.Type): readonly TS.Signature[];
/**
* Resolves the given node's type. Will resolve to the type's generic constraint, if it has one.
* Copied this method from @typescript-eslint/type-utils. https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/type-utils
* The MIT License (MIT) Copyright (c) 2021 TypeScript ESLint and other contributors
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/type-utils/LICENSE
*/
export declare function getConstrainedTypeAtLocation(checker: TS.TypeChecker, node: TS.Node): TS.Type;
/**
* Get the type name of a given type.
*
* Copied this method from @typescript-eslint/type-utils. https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/type-utils
* The MIT License (MIT) Copyright (c) 2021 TypeScript ESLint and other contributors
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/type-utils/LICENSE
*
* @param type The type to get the name of.
*/
export declare function getTypeName(type: TS.Type, tsTools: TSTools): string;
/**
* Return the type of the given property in the given type, or undefined if no such property exists
*/
export declare function getTypeOfPropertyOfType(type: TS.Type, name: string, checker: TS.TypeChecker): TS.Type | undefined;
|