ts-api-utils
Advanced tools
Comparing version 0.0.25 to 0.0.26
import * as ts from 'typescript'; | ||
import ts__default from 'typescript'; | ||
@@ -211,16 +212,28 @@ type ForEachCommentCallback = (fullText: string, comment: ts.CommentRange) => void; | ||
declare function isConditionalType(type: ts.Type): type is ts.ConditionalType; | ||
declare function isIntersectionType(type: ts.Type): type is ts.IntersectionType; | ||
declare function isLiteralType(type: ts.Type): type is ts.LiteralType; | ||
declare function isObjectType(type: ts.Type): type is ts.ObjectType; | ||
declare function isUnionOrIntersectionType(type: ts.Type): type is ts.UnionOrIntersectionType; | ||
declare function isUniqueESSymbolType(type: ts.Type): type is ts.UniqueESSymbolType; | ||
declare function isUnionType(type: ts.Type): type is ts.UnionType; | ||
declare function isTupleTypeReference(type: ts.Type): type is ts.TupleTypeReference; | ||
declare function isEvolvingArrayType(type: ts.Type): type is ts.EvolvingArrayType; | ||
declare function isTupleType(type: ts.Type): type is ts.TupleType; | ||
type TupleTypeReference = ts.TypeReference & { | ||
target: ts.TupleType; | ||
}; | ||
declare function isTupleTypeReference(type: ts.Type): type is TupleTypeReference; | ||
declare function isTypeReference(type: ts.Type): type is ts.TypeReference; | ||
declare function isBigIntLiteralType(type: ts__default.Type): type is ts__default.BigIntLiteralType; | ||
declare function isConditionalType(type: ts__default.Type): type is ts__default.ConditionalType; | ||
declare function isEnumType(type: ts__default.Type): type is ts__default.EnumType; | ||
declare function isIndexType(type: ts__default.Type): type is ts__default.IndexType; | ||
declare function isIndexedAccessType(type: ts__default.Type): type is ts__default.IndexedAccessType; | ||
declare function isInstantiableType(type: ts__default.Type): type is ts__default.InstantiableType; | ||
declare function isIntersectionType(type: ts__default.Type): type is ts__default.IntersectionType; | ||
declare function isLiteralType(type: ts__default.Type): type is ts__default.LiteralType; | ||
declare function isNumberLiteralType(type: ts__default.Type): type is ts__default.NumberLiteralType; | ||
declare function isObjectType(type: ts__default.Type): type is ts__default.ObjectType; | ||
declare function isStringLiteralType(type: ts__default.Type): type is ts__default.StringLiteralType; | ||
declare function isStringMappingType(type: ts__default.Type): type is ts__default.StringMappingType; | ||
declare function isSubstitutionType(type: ts__default.Type): type is ts__default.SubstitutionType; | ||
declare function isTemplateLiteralType(type: ts__default.Type): type is ts__default.TemplateLiteralType; | ||
declare function isTypeParameter(type: ts__default.Type): type is ts__default.TypeParameter; | ||
declare function isTypeVariable(type: ts__default.Type): type is ts__default.TypeVariable; | ||
declare function isUnionType(type: ts__default.Type): type is ts__default.UnionType; | ||
declare function isUnionOrIntersectionType(type: ts__default.Type): type is ts__default.UnionOrIntersectionType; | ||
declare function isUniqueESSymbolType(type: ts__default.Type): type is ts__default.UniqueESSymbolType; | ||
/** Determines whether the given type is a boolean literal type and matches the given boolean literal. */ | ||
@@ -242,2 +255,2 @@ declare function isBooleanLiteralType(type: ts.Type, literal: boolean): boolean; | ||
export { AnyKeyword, BigIntKeyword, BooleanCompilerOptions, BooleanKeyword, ConstAssertionExpression, ConstAssertionIdentifier, FalseKeyword, ForEachCommentCallback, ForEachTokenCallback, ImportKeyword, NamedDeclarationWithName, NeverKeyword, NullKeyword, NumberKeyword, NumericOrStringLikeLiteral, ObjectKeyword, ScopeBoundary, SomeTypePartCallback, SomeTypePartPredicate, StrictCompilerOption, StringKeyword, SuperKeyword, SymbolKeyword, ThisKeyword, TrueKeyword, TupleTypeReference, UndefinedKeyword, UnknownKeyword, VoidKeyword, forEachComment, forEachToken, getCallSignaturesOfType, getPropertyOfType, getWellKnownSymbolPropertyOfType, hasModifier, isAbstractKeyword, isAccessExpression, isAccessibilityModifier, isAccessorDeclaration, isAccessorKeyword, isAnyKeyword, isArrayBindingElement, isArrayBindingOrAssignmentPattern, isAssertKeyword, isAssertsKeyword, isAssignmentKind, isAssignmentPattern, isAsyncKeyword, isAwaitKeyword, isBigIntKeyword, isBindingOrAssignmentElementRestIndicator, isBindingOrAssignmentElementTarget, isBindingOrAssignmentPattern, isBindingPattern, isBlockLike, isBooleanKeyword, isBooleanLiteral, isBooleanLiteralType, isClassLikeDeclaration, isClassMemberModifier, isColonToken, isCompilerOptionEnabled, isConditionalType, isConstAssertionExpression, isConstKeyword, isDeclarationName, isDeclarationWithTypeParameterChildren, isDeclarationWithTypeParameters, isDeclareKeyword, isDefaultKeyword, isDestructuringPattern, isDotToken, isEndOfFileToken, isEntityNameExpression, isEntityNameOrEntityNameExpression, isEqualsGreaterThanToken, isEqualsToken, isExclamationToken, isExportKeyword, isFalseKeyword, isFalseLiteral, isFalsyType, isForInOrOfStatement, isFunctionLikeDeclaration, isFunctionScopeBoundary, isHasDecorators, isHasExpressionInitializer, isHasInitializer, isHasJSDoc, isHasModifiers, isHasType, isHasTypeArguments, isImportExpression, isImportKeyword, isInKeyword, isInputFiles, isIntersectionType, isIterationStatement, isJSDocComment, isJSDocNamespaceBody, isJSDocNamespaceDeclaration, isJSDocText, isJSDocTypeReferencingNode, isJsonMinusNumericLiteral, isJsonObjectExpression, isJsxAttributeLike, isJsxAttributeValue, isJsxChild, isJsxTagNameExpression, isJsxTagNamePropertyAccess, isLiteralToken, isLiteralType, isModifierFlagSet, isModuleBody, isModuleName, isModuleReference, isNamedDeclarationWithName, isNamedImportBindings, isNamedImportsOrExports, isNamespaceBody, isNamespaceDeclaration, isNeverKeyword, isNodeFlagSet, isNullKeyword, isNullLiteral, isNumberKeyword, isNumericOrStringLikeLiteral, isNumericPropertyName, isObjectBindingOrAssignmentElement, isObjectBindingOrAssignmentPattern, isObjectFlagSet, isObjectKeyword, isObjectType, isObjectTypeDeclaration, isOutKeyword, isOverrideKeyword, isParameterPropertyModifier, isPrivateKeyword, isPropertyAccessEntityNameExpression, isPropertyNameLiteral, isPropertyReadonlyInType, isProtectedKeyword, isPseudoLiteralToken, isPublicKeyword, isQuestionDotToken, isQuestionToken, isReadonlyKeyword, isSignatureDeclaration, isStaticKeyword, isStrictCompilerOptionEnabled, isStringKeyword, isSuperElementAccessExpression, isSuperExpression, isSuperKeyword, isSuperProperty, isSuperPropertyAccessExpression, isSymbolFlagSet, isSymbolKeyword, isSyntaxList, isThenableType, isThisExpression, isThisKeyword, isTrueKeyword, isTrueLiteral, isTupleType, isTupleTypeReference, isTypeFlagSet, isTypeOnlyCompatibleAliasDeclaration, isTypeReference, isTypeReferenceType, isUndefinedKeyword, isUnionOrIntersectionType, isUnionOrIntersectionTypeNode, isUnionType, isUniqueESSymbolType, isUnknownKeyword, isUnparsedPrologue, isUnparsedSourceText, isUnparsedSyntheticReference, isValidPropertyAccess, isVariableLikeDeclaration, isVoidKeyword, someTypePart, symbolHasReadonlyDeclaration, unionTypeParts }; | ||
export { AnyKeyword, BigIntKeyword, BooleanCompilerOptions, BooleanKeyword, ConstAssertionExpression, ConstAssertionIdentifier, FalseKeyword, ForEachCommentCallback, ForEachTokenCallback, ImportKeyword, NamedDeclarationWithName, NeverKeyword, NullKeyword, NumberKeyword, NumericOrStringLikeLiteral, ObjectKeyword, ScopeBoundary, SomeTypePartCallback, SomeTypePartPredicate, StrictCompilerOption, StringKeyword, SuperKeyword, SymbolKeyword, ThisKeyword, TrueKeyword, UndefinedKeyword, UnknownKeyword, VoidKeyword, forEachComment, forEachToken, getCallSignaturesOfType, getPropertyOfType, getWellKnownSymbolPropertyOfType, hasModifier, isAbstractKeyword, isAccessExpression, isAccessibilityModifier, isAccessorDeclaration, isAccessorKeyword, isAnyKeyword, isArrayBindingElement, isArrayBindingOrAssignmentPattern, isAssertKeyword, isAssertsKeyword, isAssignmentKind, isAssignmentPattern, isAsyncKeyword, isAwaitKeyword, isBigIntKeyword, isBigIntLiteralType, isBindingOrAssignmentElementRestIndicator, isBindingOrAssignmentElementTarget, isBindingOrAssignmentPattern, isBindingPattern, isBlockLike, isBooleanKeyword, isBooleanLiteral, isBooleanLiteralType, isClassLikeDeclaration, isClassMemberModifier, isColonToken, isCompilerOptionEnabled, isConditionalType, isConstAssertionExpression, isConstKeyword, isDeclarationName, isDeclarationWithTypeParameterChildren, isDeclarationWithTypeParameters, isDeclareKeyword, isDefaultKeyword, isDestructuringPattern, isDotToken, isEndOfFileToken, isEntityNameExpression, isEntityNameOrEntityNameExpression, isEnumType, isEqualsGreaterThanToken, isEqualsToken, isEvolvingArrayType, isExclamationToken, isExportKeyword, isFalseKeyword, isFalseLiteral, isFalsyType, isForInOrOfStatement, isFunctionLikeDeclaration, isFunctionScopeBoundary, isHasDecorators, isHasExpressionInitializer, isHasInitializer, isHasJSDoc, isHasModifiers, isHasType, isHasTypeArguments, isImportExpression, isImportKeyword, isInKeyword, isIndexType, isIndexedAccessType, isInputFiles, isInstantiableType, isIntersectionType, isIterationStatement, isJSDocComment, isJSDocNamespaceBody, isJSDocNamespaceDeclaration, isJSDocText, isJSDocTypeReferencingNode, isJsonMinusNumericLiteral, isJsonObjectExpression, isJsxAttributeLike, isJsxAttributeValue, isJsxChild, isJsxTagNameExpression, isJsxTagNamePropertyAccess, isLiteralToken, isLiteralType, isModifierFlagSet, isModuleBody, isModuleName, isModuleReference, isNamedDeclarationWithName, isNamedImportBindings, isNamedImportsOrExports, isNamespaceBody, isNamespaceDeclaration, isNeverKeyword, isNodeFlagSet, isNullKeyword, isNullLiteral, isNumberKeyword, isNumberLiteralType, isNumericOrStringLikeLiteral, isNumericPropertyName, isObjectBindingOrAssignmentElement, isObjectBindingOrAssignmentPattern, isObjectFlagSet, isObjectKeyword, isObjectType, isObjectTypeDeclaration, isOutKeyword, isOverrideKeyword, isParameterPropertyModifier, isPrivateKeyword, isPropertyAccessEntityNameExpression, isPropertyNameLiteral, isPropertyReadonlyInType, isProtectedKeyword, isPseudoLiteralToken, isPublicKeyword, isQuestionDotToken, isQuestionToken, isReadonlyKeyword, isSignatureDeclaration, isStaticKeyword, isStrictCompilerOptionEnabled, isStringKeyword, isStringLiteralType, isStringMappingType, isSubstitutionType, isSuperElementAccessExpression, isSuperExpression, isSuperKeyword, isSuperProperty, isSuperPropertyAccessExpression, isSymbolFlagSet, isSymbolKeyword, isSyntaxList, isTemplateLiteralType, isThenableType, isThisExpression, isThisKeyword, isTrueKeyword, isTrueLiteral, isTupleType, isTupleTypeReference, isTypeFlagSet, isTypeOnlyCompatibleAliasDeclaration, isTypeParameter, isTypeReference, isTypeReferenceType, isTypeVariable, isUndefinedKeyword, isUnionOrIntersectionType, isUnionOrIntersectionTypeNode, isUnionType, isUniqueESSymbolType, isUnknownKeyword, isUnparsedPrologue, isUnparsedSourceText, isUnparsedSyntheticReference, isValidPropertyAccess, isVariableLikeDeclaration, isVoidKeyword, someTypePart, symbolHasReadonlyDeclaration, unionTypeParts }; |
154
lib/index.js
@@ -119,14 +119,17 @@ // src/comments.ts | ||
import * as ts4 from "typescript"; | ||
function isFlagSet(obj, flag) { | ||
return (obj.flags & flag) !== 0; | ||
function isFlagSet(allFlags, flag) { | ||
return (allFlags & flag) !== 0; | ||
} | ||
function isFlagSetOnObject(obj, flag) { | ||
return isFlagSet(obj.flags, flag); | ||
} | ||
function isModifierFlagSet(node, flag) { | ||
return (ts4.getCombinedModifierFlags(node) & flag) !== 0; | ||
return isFlagSet(ts4.getCombinedModifierFlags(node), flag); | ||
} | ||
var isNodeFlagSet = isFlagSet; | ||
var isNodeFlagSet = isFlagSetOnObject; | ||
function isObjectFlagSet(objectType, flag) { | ||
return (objectType.objectFlags & flag) !== 0; | ||
return isFlagSet(objectType.objectFlags, flag); | ||
} | ||
var isSymbolFlagSet = isFlagSet; | ||
var isTypeFlagSet = isFlagSet; | ||
var isSymbolFlagSet = isFlagSetOnObject; | ||
var isTypeFlagSet = isFlagSetOnObject; | ||
@@ -594,34 +597,80 @@ // src/modifiers.ts | ||
// src/types/typeGuards.ts | ||
import * as ts10 from "typescript"; | ||
// src/types/typeGuards/objects.ts | ||
import * as ts11 from "typescript"; | ||
// src/types/typeGuards/simple.ts | ||
import ts10 from "typescript"; | ||
function isBigIntLiteralType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.BigIntLiteral); | ||
} | ||
function isConditionalType(type) { | ||
return (type.flags & ts10.TypeFlags.Conditional) !== 0; | ||
return isTypeFlagSet(type, ts10.TypeFlags.Conditional); | ||
} | ||
function isEnumType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.Enum); | ||
} | ||
function isIndexType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.Index); | ||
} | ||
function isIndexedAccessType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.IndexedAccess); | ||
} | ||
function isInstantiableType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.Instantiable); | ||
} | ||
function isIntersectionType(type) { | ||
return (type.flags & ts10.TypeFlags.Intersection) !== 0; | ||
return isTypeFlagSet(type, ts10.TypeFlags.Intersection); | ||
} | ||
function isLiteralType(type) { | ||
return (type.flags & (ts10.TypeFlags.StringOrNumberLiteral | ts10.TypeFlags.BigIntLiteral)) !== 0; | ||
return isTypeFlagSet(type, ts10.TypeFlags.Literal); | ||
} | ||
function isNumberLiteralType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.NumberLiteral); | ||
} | ||
function isObjectType(type) { | ||
return (type.flags & ts10.TypeFlags.Object) !== 0; | ||
return isTypeFlagSet(type, ts10.TypeFlags.Object); | ||
} | ||
function isStringLiteralType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.StringLiteral); | ||
} | ||
function isStringMappingType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.StringMapping); | ||
} | ||
function isSubstitutionType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.Substitution); | ||
} | ||
function isTemplateLiteralType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.TemplateLiteral); | ||
} | ||
function isTypeParameter(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.TypeParameter); | ||
} | ||
function isTypeVariable(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.TypeVariable); | ||
} | ||
function isUnionType(type) { | ||
return isTypeFlagSet(type, ts10.TypeFlags.Union); | ||
} | ||
function isUnionOrIntersectionType(type) { | ||
return (type.flags & ts10.TypeFlags.UnionOrIntersection) !== 0; | ||
return isTypeFlagSet(type, ts10.TypeFlags.UnionOrIntersection); | ||
} | ||
function isUniqueESSymbolType(type) { | ||
return (type.flags & ts10.TypeFlags.UniqueESSymbol) !== 0; | ||
return isTypeFlagSet(type, ts10.TypeFlags.UniqueESSymbol); | ||
} | ||
function isUnionType(type) { | ||
return (type.flags & ts10.TypeFlags.Union) !== 0; | ||
// src/types/typeGuards/objects.ts | ||
function isEvolvingArrayType(type) { | ||
return isObjectType(type) && isObjectFlagSet(type, ts11.ObjectFlags.EvolvingArray); | ||
} | ||
function isTupleType(type) { | ||
return (type.flags & ts10.TypeFlags.Object && type.objectFlags & ts10.ObjectFlags.Tuple) !== 0; | ||
return isObjectType(type) && isObjectFlagSet(type, ts11.ObjectFlags.Tuple); | ||
} | ||
function isTypeReference(type) { | ||
return isObjectType(type) && isObjectFlagSet(type, ts11.ObjectFlags.Reference); | ||
} | ||
// src/types/typeGuards/compound.ts | ||
function isTupleTypeReference(type) { | ||
return isTypeReference(type) && isTupleType(type.target); | ||
} | ||
function isTypeReference(type) { | ||
return (type.flags & ts10.TypeFlags.Object) !== 0 && (type.objectFlags & ts10.ObjectFlags.Reference) !== 0; | ||
} | ||
@@ -691,8 +740,8 @@ // src/types/getters.ts | ||
// src/types/utilities.ts | ||
import * as ts12 from "typescript"; | ||
import * as ts13 from "typescript"; | ||
// src/nodes/utilities.ts | ||
import * as ts11 from "typescript"; | ||
import * as ts12 from "typescript"; | ||
function isBindableObjectDefinePropertyCall(node) { | ||
return node.arguments.length === 3 && isEntityNameExpression(node.arguments[0]) && isNumericOrStringLikeLiteral(node.arguments[1]) && ts11.isPropertyAccessExpression(node.expression) && node.expression.name.escapedText === "defineProperty" && ts11.isIdentifier(node.expression.expression) && node.expression.expression.escapedText === "Object"; | ||
return node.arguments.length === 3 && isEntityNameExpression(node.arguments[0]) && isNumericOrStringLikeLiteral(node.arguments[1]) && ts12.isPropertyAccessExpression(node.expression) && node.expression.name.escapedText === "defineProperty" && ts12.isIdentifier(node.expression.expression) && node.expression.expression.escapedText === "Object"; | ||
} | ||
@@ -705,11 +754,11 @@ function isInConstContext(node) { | ||
switch (parent.kind) { | ||
case ts11.SyntaxKind.TypeAssertionExpression: | ||
case ts11.SyntaxKind.AsExpression: | ||
case ts12.SyntaxKind.TypeAssertionExpression: | ||
case ts12.SyntaxKind.AsExpression: | ||
return isConstAssertionExpression(parent); | ||
case ts11.SyntaxKind.PrefixUnaryExpression: | ||
if (current.kind !== ts11.SyntaxKind.NumericLiteral) | ||
case ts12.SyntaxKind.PrefixUnaryExpression: | ||
if (current.kind !== ts12.SyntaxKind.NumericLiteral) | ||
return false; | ||
switch (parent.operator) { | ||
case ts11.SyntaxKind.PlusToken: | ||
case ts11.SyntaxKind.MinusToken: | ||
case ts12.SyntaxKind.PlusToken: | ||
case ts12.SyntaxKind.MinusToken: | ||
current = parent; | ||
@@ -720,3 +769,3 @@ break outer; | ||
} | ||
case ts11.SyntaxKind.PropertyAssignment: | ||
case ts12.SyntaxKind.PropertyAssignment: | ||
if (parent.initializer !== current) | ||
@@ -726,9 +775,9 @@ return false; | ||
break; | ||
case ts11.SyntaxKind.ShorthandPropertyAssignment: | ||
case ts12.SyntaxKind.ShorthandPropertyAssignment: | ||
current = parent.parent; | ||
break; | ||
case ts11.SyntaxKind.ParenthesizedExpression: | ||
case ts11.SyntaxKind.ArrayLiteralExpression: | ||
case ts11.SyntaxKind.ObjectLiteralExpression: | ||
case ts11.SyntaxKind.TemplateExpression: | ||
case ts12.SyntaxKind.ParenthesizedExpression: | ||
case ts12.SyntaxKind.ArrayLiteralExpression: | ||
case ts12.SyntaxKind.ObjectLiteralExpression: | ||
case ts12.SyntaxKind.TemplateExpression: | ||
current = parent; | ||
@@ -744,6 +793,6 @@ break; | ||
function isBooleanLiteralType(type, literal) { | ||
return isTypeFlagSet(type, ts12.TypeFlags.BooleanLiteral) && type.intrinsicName === (literal ? "true" : "false"); | ||
return isTypeFlagSet(type, ts13.TypeFlags.BooleanLiteral) && type.intrinsicName === (literal ? "true" : "false"); | ||
} | ||
function isFalsyType(type) { | ||
if (type.flags & (ts12.TypeFlags.Undefined | ts12.TypeFlags.Null | ts12.TypeFlags.Void)) | ||
if (type.flags & (ts13.TypeFlags.Undefined | ts13.TypeFlags.Null | ts13.TypeFlags.Void)) | ||
return true; | ||
@@ -759,3 +808,3 @@ if (isLiteralType(type)) | ||
return false; | ||
if (prop.flags & ts12.SymbolFlags.Transient) { | ||
if (prop.flags & ts13.SymbolFlags.Transient) { | ||
if (/^(?:[1-9]\d*|0)$/.test(name) && isTupleTypeReference(subType)) | ||
@@ -771,11 +820,11 @@ return subType.target.readonly; | ||
} | ||
return !!(isSymbolFlagSet(prop, ts12.SymbolFlags.ValueModule) || symbolHasReadonlyDeclaration(prop, typeChecker)); | ||
return !!(isSymbolFlagSet(prop, ts13.SymbolFlags.ValueModule) || symbolHasReadonlyDeclaration(prop, typeChecker)); | ||
}); | ||
} | ||
function isReadonlyPropertyFromMappedType(type, name, typeChecker) { | ||
if (!isObjectType(type) || !isObjectFlagSet(type, ts12.ObjectFlags.Mapped)) | ||
if (!isObjectType(type) || !isObjectFlagSet(type, ts13.ObjectFlags.Mapped)) | ||
return; | ||
const declaration = type.symbol.declarations[0]; | ||
if (declaration.readonlyToken !== void 0 && !/^__@[^@]+$/.test(name)) | ||
return declaration.readonlyToken.kind !== ts12.SyntaxKind.MinusToken; | ||
return declaration.readonlyToken.kind !== ts13.SyntaxKind.MinusToken; | ||
const { modifiersType } = type; | ||
@@ -804,3 +853,3 @@ return modifiersType && isPropertyReadonlyInType(modifiersType, name, typeChecker); | ||
if (getPropertyOfType(subType, name) === void 0) { | ||
const index = (isNumericPropertyName(name) ? typeChecker.getIndexInfoOfType(subType, ts12.IndexKind.Number) : void 0) ?? typeChecker.getIndexInfoOfType(subType, ts12.IndexKind.String); | ||
const index = (isNumericPropertyName(name) ? typeChecker.getIndexInfoOfType(subType, ts13.IndexKind.Number) : void 0) ?? typeChecker.getIndexInfoOfType(subType, ts13.IndexKind.String); | ||
if (index?.isReadonly) { | ||
@@ -828,3 +877,3 @@ if (seenProperty) | ||
return false; | ||
const writableType = writableProp.valueDeclaration !== void 0 && ts12.isPropertyAssignment(writableProp.valueDeclaration) ? typeChecker.getTypeAtLocation(writableProp.valueDeclaration.initializer) : typeChecker.getTypeOfSymbolAtLocation(writableProp, node.arguments[2]); | ||
const writableType = writableProp.valueDeclaration !== void 0 && ts13.isPropertyAssignment(writableProp.valueDeclaration) ? typeChecker.getTypeAtLocation(writableProp.valueDeclaration.initializer) : typeChecker.getTypeOfSymbolAtLocation(writableProp, node.arguments[2]); | ||
return isBooleanLiteralType(writableType, false); | ||
@@ -849,4 +898,4 @@ } | ||
function symbolHasReadonlyDeclaration(symbol, typeChecker) { | ||
return !!((symbol.flags & ts12.SymbolFlags.Accessor) === ts12.SymbolFlags.GetAccessor || symbol.declarations?.some( | ||
(node) => isModifierFlagSet(node, ts12.ModifierFlags.Readonly) || ts12.isVariableDeclaration(node) && isNodeFlagSet(node.parent, ts12.NodeFlags.Const) || ts12.isCallExpression(node) && isReadonlyAssignmentDeclaration(node, typeChecker) || ts12.isEnumMember(node) || (ts12.isPropertyAssignment(node) || ts12.isShorthandPropertyAssignment(node)) && isInConstContext(node.parent) | ||
return !!((symbol.flags & ts13.SymbolFlags.Accessor) === ts13.SymbolFlags.GetAccessor || symbol.declarations?.some( | ||
(node) => isModifierFlagSet(node, ts13.ModifierFlags.Readonly) || ts13.isVariableDeclaration(node) && isNodeFlagSet(node.parent, ts13.NodeFlags.Const) || ts13.isCallExpression(node) && isReadonlyAssignmentDeclaration(node, typeChecker) || ts13.isEnumMember(node) || (ts13.isPropertyAssignment(node) || ts13.isShorthandPropertyAssignment(node)) && isInConstContext(node.parent) | ||
)); | ||
@@ -880,2 +929,3 @@ } | ||
isBigIntKeyword, | ||
isBigIntLiteralType, | ||
isBindingOrAssignmentElementRestIndicator, | ||
@@ -906,4 +956,6 @@ isBindingOrAssignmentElementTarget, | ||
isEntityNameOrEntityNameExpression, | ||
isEnumType, | ||
isEqualsGreaterThanToken, | ||
isEqualsToken, | ||
isEvolvingArrayType, | ||
isExclamationToken, | ||
@@ -927,3 +979,6 @@ isExportKeyword, | ||
isInKeyword, | ||
isIndexType, | ||
isIndexedAccessType, | ||
isInputFiles, | ||
isInstantiableType, | ||
isIntersectionType, | ||
@@ -959,2 +1014,3 @@ isIterationStatement, | ||
isNumberKeyword, | ||
isNumberLiteralType, | ||
isNumericOrStringLikeLiteral, | ||
@@ -985,2 +1041,5 @@ isNumericPropertyName, | ||
isStringKeyword, | ||
isStringLiteralType, | ||
isStringMappingType, | ||
isSubstitutionType, | ||
isSuperElementAccessExpression, | ||
@@ -994,2 +1053,3 @@ isSuperExpression, | ||
isSyntaxList, | ||
isTemplateLiteralType, | ||
isThenableType, | ||
@@ -1004,4 +1064,6 @@ isThisExpression, | ||
isTypeOnlyCompatibleAliasDeclaration, | ||
isTypeParameter, | ||
isTypeReference, | ||
isTypeReferenceType, | ||
isTypeVariable, | ||
isUndefinedKeyword, | ||
@@ -1008,0 +1070,0 @@ isUnionOrIntersectionType, |
{ | ||
"name": "ts-api-utils", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "Utility functions for working with TypeScript's API. Successor to the wonderful tsutils.", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137576
2574