Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(deps): update dependency ts-api-utils to v2.1.0#11003

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JoshuaKGoldberg merged 4 commits intomainfromrenovate/ts-api-utils-2.x-lockfile
May 5, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
2 changes: 1 addition & 1 deletiondocs/maintenance/Pull_Requests.mdx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,7 +78,7 @@ If there's no backing issue:
- Thoroughness: does it handle relevant edge cases? Commonly:
- Generics and type parameters (see:`getConstrainedTypeAtLocation`).
- Parenthesis and whitespace (see:`getWrappingFixer`).
- Unions and intersections (see:`unionTypeParts` and`intersectionTypeParts`).
- Unions and intersections (see:`unionConstituents` and`intersectionConstituents`).
- Unit tests:
- All lines are covered per the Codecov /`yarn jest path/to/impacted/file --coverage` report.
- Both "positive" and "negative" ("valid" and "invalid") cases exist, if reasonably possible to test for.
Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,7 +68,7 @@
"graphemer":"^1.4.0",
"ignore":"^5.3.1",
"natural-compare":"^1.4.0",
"ts-api-utils":"^2.0.1"
"ts-api-utils":"^2.1.0"
},
"devDependencies": {
"@types/marked":"^5.0.2",
Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/rules/await-thenable.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -91,7 +91,7 @@ export default createRule<[], MessageId>({
}

consthasAsyncIteratorSymbol=tsutils
.unionTypeParts(type)
.unionConstituents(type)
.some(
typePart=>
tsutils.getWellKnownSymbolPropertyOfType(
Expand DownExpand Up@@ -137,7 +137,7 @@ export default createRule<[], MessageId>({
}

consthasAsyncDisposeSymbol=tsutils
.unionTypeParts(type)
.unionConstituents(type)
.some(
typePart=>
tsutils.getWellKnownSymbolPropertyOfType(
Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/src/rules/enum-utils/shared.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ function getBaseEnumType(typeChecker: ts.TypeChecker, type: ts.Type): ts.Type {
*/
exportfunctiongetEnumLiterals(type:ts.Type):ts.LiteralType[]{
returntsutils
.unionTypeParts(type)
.unionConstituents(type)
.filter((subType):subType ists.LiteralType=>
isTypeFlagSet(subType,ts.TypeFlags.EnumLiteral),
);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -431,7 +431,7 @@ export default createRule<Options, MessageId>({
constreturnType=signature.getReturnType();

returntsutils
.unionTypeParts(returnType)
.unionConstituents(returnType)
.some(tsutils.isIntrinsicVoidType);
});
}
Expand All@@ -455,7 +455,7 @@ export default createRule<Options, MessageId>({
constreturnType=checker.getTypeFromTypeNode(functionTSNode.type);

returntsutils
.unionTypeParts(returnType)
.unionConstituents(returnType)
.some(tsutils.isIntrinsicVoidType);
}

Expand All@@ -464,7 +464,7 @@ export default createRule<Options, MessageId>({

if(functionType){
returntsutils
.unionTypeParts(functionType)
.unionConstituents(functionType)
.some(isFunctionReturnTypeIncludesVoid);
}
}
Expand Down
10 changes: 6 additions & 4 deletionspackages/eslint-plugin/src/rules/no-floating-promises.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -399,7 +399,7 @@ export default createRule<Options, MessageId>({
function isPromiseArray(node: ts.Node): boolean {
const type = checker.getTypeAtLocation(node);
for (const ty of tsutils
.unionTypeParts(type)
.unionConstituents(type)
.map(t => checker.getApparentType(t))) {
if (checker.isArrayType(ty)) {
const arrayType = checker.getTypeArguments(ty)[0];
Expand DownExpand Up@@ -434,7 +434,9 @@ export default createRule<Options, MessageId>({
}

// Otherwise, we always consider the built-in Promise to be Promise-like...
const typeParts = tsutils.unionTypeParts(checker.getApparentType(type));
const typeParts = tsutils.unionConstituents(
checker.getApparentType(type),
);
if (
typeParts.some(typePart =>
isBuiltinSymbolLike(services.program, typePart, 'Promise'),
Expand DownExpand Up@@ -480,7 +482,7 @@ function hasMatchingSignature(
type: ts.Type,
matcher: (signature: ts.Signature) => boolean,
): boolean {
for (const t of tsutils.unionTypeParts(type)) {
for (const t of tsutils.unionConstituents(type)) {
if (t.getCallSignatures().some(matcher)) {
return true;
}
Expand All@@ -497,7 +499,7 @@ function isFunctionParam(
const type: ts.Type | undefined = checker.getApparentType(
checker.getTypeOfSymbolAtLocation(param, node),
);
for (const t of tsutils.unionTypeParts(type)) {
for (const t of tsutils.unionConstituents(type)) {
if (t.getCallSignatures().length !== 0) {
return true;
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,7 @@ export default createRule<Options, 'meaninglessVoidOperator' | 'removeVoid'>({
};

constargType=services.getTypeAtLocation(node.argument);
constunionParts=tsutils.unionTypeParts(argType);
constunionParts=tsutils.unionConstituents(argType);
if(
unionParts.every(
part=>part.flags&(ts.TypeFlags.Void|ts.TypeFlags.Undefined),
Expand Down
20 changes: 12 additions & 8 deletionspackages/eslint-plugin/src/rules/no-misused-promises.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -686,7 +686,9 @@ export default createRule<Options, MessageId>({
functionisSometimesThenable(checker:ts.TypeChecker,node:ts.Node):boolean{
consttype=checker.getTypeAtLocation(node);

for(constsubTypeoftsutils.unionTypeParts(checker.getApparentType(type))){
for(constsubTypeoftsutils.unionConstituents(
checker.getApparentType(type),
)){
if(tsutils.isThenableType(checker,node,subType)){
returntrue;
}
Expand All@@ -702,7 +704,9 @@ function isSometimesThenable(checker: ts.TypeChecker, node: ts.Node): boolean {
functionisAlwaysThenable(checker:ts.TypeChecker,node:ts.Node):boolean{
consttype=checker.getTypeAtLocation(node);

for(constsubTypeoftsutils.unionTypeParts(checker.getApparentType(type))){
for(constsubTypeoftsutils.unionConstituents(
checker.getApparentType(type),
)){
constthenProp=subType.getProperty('then');

// If one of the alternates has no then property, it is not thenable in all
Expand All@@ -716,7 +720,7 @@ function isAlwaysThenable(checker: ts.TypeChecker, node: ts.Node): boolean {
// be of the right form to consider it thenable.
constthenType=checker.getTypeOfSymbolAtLocation(thenProp,node);
lethasThenableSignature=false;
for(constsubTypeoftsutils.unionTypeParts(thenType)){
for(constsubTypeoftsutils.unionConstituents(thenType)){
for(constsignatureofsubType.getCallSignatures()){
if(
signature.parameters.length!==0&&
Expand DownExpand Up@@ -754,7 +758,7 @@ function isFunctionParam(
consttype:ts.Type|undefined=checker.getApparentType(
checker.getTypeOfSymbolAtLocation(param,node),
);
for(constsubTypeoftsutils.unionTypeParts(type)){
for(constsubTypeoftsutils.unionConstituents(type)){
if(subType.getCallSignatures().length!==0){
returntrue;
}
Expand DownExpand Up@@ -818,7 +822,7 @@ function voidFunctionArguments(
// We can't use checker.getResolvedSignature because it prefers an early '() => void' over a later '() => Promise<void>'
// See https://github.com/microsoft/TypeScript/issues/48077

for(constsubTypeoftsutils.unionTypeParts(type)){
for(constsubTypeoftsutils.unionConstituents(type)){
// Standard function calls and `new` have two different types of signatures
constsignatures=ts.isCallExpression(node)
?subType.getCallSignatures()
Expand DownExpand Up@@ -915,7 +919,7 @@ function isThenableReturningFunctionType(
node:ts.Node,
type:ts.Type,
):boolean{
for(constsubTypeoftsutils.unionTypeParts(type)){
for(constsubTypeoftsutils.unionConstituents(type)){
if(anySignatureIsThenableType(checker,node,subType)){
returntrue;
}
Expand All@@ -934,7 +938,7 @@ function isVoidReturningFunctionType(
):boolean{
lethadVoidReturn=false;

for(constsubTypeoftsutils.unionTypeParts(type)){
for(constsubTypeoftsutils.unionConstituents(type)){
for(constsignatureofsubType.getCallSignatures()){
constreturnType=signature.getReturnType();

Expand All@@ -957,7 +961,7 @@ function isVoidReturningFunctionType(
functionreturnsThenable(checker:ts.TypeChecker,node:ts.Node):boolean{
consttype=checker.getApparentType(checker.getTypeAtLocation(node));
returntsutils
.unionTypeParts(type)
.unionConstituents(type)
.some(t=>anySignatureIsThenableType(checker,node,t));
}

Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/rules/no-misused-spread.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,7 +117,7 @@ export default createRule<Options, MessageIds>({
node:TSESTree.JSXSpreadAttribute|TSESTree.SpreadElement,
type:ts.Type,
):TSESLint.ReportSuggestionArray<MessageIds>|null{
consttypes=tsutils.unionTypeParts(type);
consttypes=tsutils.unionConstituents(type);
if(types.some(t=>!isMap(services.program,t))){
returnnull;
}
Expand DownExpand Up@@ -260,7 +260,7 @@ export default createRule<Options, MessageIds>({

functionisIterable(type:ts.Type,checker:ts.TypeChecker):boolean{
returntsutils
.typeParts(type)
.typeConstituents(type)
.some(
t=>!!tsutils.getWellKnownSymbolPropertyOfType(t,'iterator',checker),
);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -187,7 +187,7 @@ function unionTypePartsUnlessBoolean(type: ts.Type): ts.Type[] {
tsutils.isFalseLiteralType(type.types[0])&&
tsutils.isTrueLiteralType(type.types[1])
?[type]
:tsutils.unionTypeParts(type);
:tsutils.unionConstituents(type);
}

exportdefaultcreateRule({
Expand Down
10 changes: 5 additions & 5 deletionspackages/eslint-plugin/src/rules/no-unnecessary-condition.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,15 +37,15 @@ function isNullishType(type: ts.Type): boolean {
}

functionisAlwaysNullish(type:ts.Type):boolean{
returntsutils.unionTypeParts(type).every(isNullishType);
returntsutils.unionConstituents(type).every(isNullishType);
}

/**
* Note that this differs from {@link isNullableType} in that it doesn't consider
* `any` or `unknown` to be nullable.
*/
functionisPossiblyNullish(type:ts.Type):boolean{
returntsutils.unionTypeParts(type).some(isNullishType);
returntsutils.unionConstituents(type).some(isNullishType);
}

functiontoStaticValue(
Expand DownExpand Up@@ -274,14 +274,14 @@ export default createRule<Options, MessageId>({
functionnodeIsArrayType(node:TSESTree.Expression):boolean{
constnodeType=getConstrainedTypeAtLocation(services,node);
returntsutils
.unionTypeParts(nodeType)
.unionConstituents(nodeType)
.some(part=>checker.isArrayType(part));
}

functionnodeIsTupleType(node:TSESTree.Expression):boolean{
constnodeType=getConstrainedTypeAtLocation(services,node);
returntsutils
.unionTypeParts(nodeType)
.unionConstituents(nodeType)
.some(part=>checker.isTupleType(part));
}

Expand All@@ -303,7 +303,7 @@ export default createRule<Options, MessageId>({
// `any` or `unknown` or a naked type variable
functionisConditionalAlwaysNecessary(type:ts.Type):boolean{
returntsutils
.unionTypeParts(type)
.unionConstituents(type)
.some(
part=>
isTypeAnyType(part)||
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ export default createRule<[], MessageId>({
}

functionisEnumMemberType(type:ts.Type):boolean{
returntsutils.typeParts(type).some(t=>{
returntsutils.typeConstituents(type).some(t=>{
constsymbol=t.getSymbol();
return!!(
symbol?.valueDeclaration&&ts.isEnumMember(symbol.valueDeclaration)
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -204,11 +204,11 @@ export default createRule<Options, MessageIds>({
)
){
constuncastParts=tsutils
.unionTypeParts(uncast)
.unionConstituents(uncast)
.filter(part=>!isTypeFlagSet(part,ts.TypeFlags.Undefined));

constcastParts=tsutils
.unionTypeParts(cast)
.unionConstituents(cast)
.filter(part=>!isTypeFlagSet(part,ts.TypeFlags.Undefined));

if(uncastParts.length!==castParts.length){
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ function typeViolates(leftTypeParts: ts.Type[], rightType: ts.Type): boolean {
}

functionisNumberLike(type:ts.Type):boolean{
consttypeParts=tsutils.intersectionTypeParts(type);
consttypeParts=tsutils.intersectionConstituents(type);

returntypeParts.some(typePart=>{
returntsutils.isTypeFlagSet(
Expand All@@ -34,7 +34,7 @@ function isNumberLike(type: ts.Type): boolean {
}

functionisStringLike(type:ts.Type):boolean{
consttypeParts=tsutils.intersectionTypeParts(type);
consttypeParts=tsutils.intersectionConstituents(type);

returntypeParts.some(typePart=>{
returntsutils.isTypeFlagSet(
Expand DownExpand Up@@ -112,8 +112,8 @@ export default createRule({
// declare const something: Fruit | Vegetable;
// something === Fruit.Apple;
// ```
constleftTypeParts=tsutils.unionTypeParts(leftType);
constrightTypeParts=tsutils.unionTypeParts(rightType);
constleftTypeParts=tsutils.unionConstituents(leftType);
constrightTypeParts=tsutils.unionConstituents(rightType);

// If a type exists in both sides, we consider this comparison safe:
//
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ export default util.createRule<Options, MessageIds>({
constchecker=services.program.getTypeChecker();
if(
tsutils
.unionTypeParts(argType)
.unionConstituents(argType)
.some(
type=>
!tsutils.isTypeFlagSet(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,7 +41,7 @@ export default createRule({
returnundefined;
}

returntsutils.unionTypeParts(type);
returntsutils.unionConstituents(type);
};

constcouldBeNullish=(type:ts.Type):boolean=>{
Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/rules/prefer-find.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,7 +114,7 @@ export default createRule({
*/
functionisArrayish(type:Type):boolean{
letisAtLeastOneArrayishComponent=false;
for(constunionPartoftsutils.unionTypeParts(type)){
for(constunionPartoftsutils.unionConstituents(type)){
if(
tsutils.isIntrinsicNullType(unionPart)||
tsutils.isIntrinsicUndefinedType(unionPart)
Expand All@@ -125,7 +125,7 @@ export default createRule({
// apparently checker.isArrayType(T[] & S[]) => false.
// so we need to check the intersection parts individually.
constisArrayOrIntersectionThereof=tsutils
.intersectionTypeParts(unionPart)
.intersectionConstituents(unionPart)
.every(
intersectionPart=>
checker.isArrayType(intersectionPart)||
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -254,10 +254,10 @@ export default createRule<Options, MessageIds>({

if(
tsutils
.typeParts(type)
.typeConstituents(type)
.some(t=>
tsutils
.intersectionTypeParts(t)
.intersectionConstituents(t)
.some(t=>tsutils.isTypeFlagSet(t,ignorableFlags)),
)
){
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import type {
}from'@typescript-eslint/utils/ts-eslint';

import{AST_NODE_TYPES}from'@typescript-eslint/utils';
import{unionTypeParts}from'ts-api-utils';
import{unionConstituents}from'ts-api-utils';
import*astsfrom'typescript';

importtype{ValidOperand}from'./gatherLogicalOperands';
Expand DownExpand Up@@ -39,7 +39,7 @@ function includesType(
typeFlagIn:ts.TypeFlags,
):boolean{
consttypeFlag=typeFlagIn|ts.TypeFlags.Any|ts.TypeFlags.Unknown;
consttypes=unionTypeParts(parserServices.getTypeAtLocation(node));
consttypes=unionConstituents(parserServices.getTypeAtLocation(node));
for(consttypeoftypes){
if(isTypeFlagSet(type,typeFlag)){
returntrue;
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp