Features:
getWellKnownSymbolPropertyOfType
to reliably get symbol named properties due to changes in typescript@4.3getPropertyNameOfWellKnownSymbol
is now deprecatedFeatures:
findImports
and findImportLikeNodes
take an additional parameter ignoreFileName
. The default value for this paramter is true
to remain backwards compatible. When set to false
, it matches the behavior of TypeScript, i.e. only looks for require
in JavaScript files.Bugfixes:
getJsDoc
for EndOfFileToken
now returns JSDoc
comments whose contents are usable with the type checkerBugfixes:
getSymbolOfClassLikeDeclaration
no longer crashes on anonymous mixin classesFeatures:
getSymbolOfClassLikeDeclaration
to retrieve the symbol of class declarations and expressions regardless whether they have a name or notgetBaseOfClassLikeDeclaration
to conventiently get the expression after extends
getBaseClassMemberOfClassElement
to look up the declaration of a class member in the base classBugfixes:
getConstructorTypeOfClassLikeDeclaration
now really returns the constructor type (the static side of the class), previously it returned the instance typehasExhaustiveCaseClauses
allows additional case clauses with null
, undefined
and never
Features:
callExpressionAffectsControlFlow
to determine whether a CallExpression affects control flow by returning never
or asserts
hasExhaustiveCaseClauses
to determine whether a SwitchStatement’s CaseClauses handle every possible valueendsControlFlow
and getControlFlowEnd
take an optional checker
parameter to recognize exhaustive SwitchStatements and control flow effects of CallExpressionsformatPseudoBigInt
converts TypeScript’s representation of a BigInt to its literal representation as you would write it in your source codegetAstNodeAtPosition
similar to getTokenAtPosition
, but only operates on AST NodesremoveOptionalChainingUndefinedMarkerType
and isOptionalChainingUndefinedMarkerType
to handle types originating in an optional chainfindImports
and findImportLikeNodes
: prepare for import assertionsgetTsCheckDirective
as new name for getCheckJsDirective
getCheckJsDirective
is now deprecatedBugfixes:
getUsageDomain
: handles NamespaceExport and NamedTupleMembergetPropertyName
: handles parentheses and negative numeric literals, excludes RegExp literals and private identifiersgetSingleLateBoundPropertyNameOfPropertyName
and getLateBoundPropertyNamesOfPropertyName
: handles private identifiershasAccessModifier
: handles JSDoc access modifierhasSideEffects
: correctly determines side effects of (static) property initializersisExpressionValueUsed
: handle nullish coalescing and conditional assignment operatorscanHaveJsDoc
: aligned with upstream changes in TypeScriptisCompilerOptionEnabled
:
noUncheckedIndexedAccess
requires strictNullChecks
checkJs
implies allowJs
emitDeclarationOnly
requires declaration
isInConstContext
: handle template string interpolationsBugfixes:
isValidJsxIdentifier
, isValidPropertyAccess
, isValidPropertyName
: fix unicode character width handlingFeatures:
isValidJsxIdentifier
added an optional parameter to specify the target ECMAScript versionBugfixes:
isValidJsxIdentifier
now handles astral plane charactersFeatures:
getIteratorYieldResultFromIteratorResult
to extract the yield
ed type from IteratorResult<TYield, TReturn, TNext>
Features:
isValidIdentifier
, isValidPropertyName
, isValidPropertyAccess
, isValidNumericLiteral
added an optional parameter to specify the target ECMAScript versionBugfixes:
isValidPropertyName
, isValidPropertyAccess
now handle astral plane charactersBugfixes:
findImports
: fixed crash on nested namespacesFeatures:
getInstanceTypeOfClassLikeDeclaration
and getConstructorTypeOfClassLikeDeclaration
AccessKind.Delete
to getAccessKind
: getAccessKind(node) & AccessKind.Modification
can now be used to restore the old behavior of isReassignmentTarget(node)
Features:
getAccessKind
determines whether an expression is read from, written to or bothgetPropertyOfType
for unambiguous property names to partially work around https://github.com/microsoft/TypeScript/issues/31565Bugfixes:
isReassignmentTarget
no longer returns true
for DeleteExpression
as it doesn’t assign a value to the operandFeatures:
getLateBoundPropertyNamesOfPropertyName
returns all statically analyzable names of a property, method, …getSingleLateBoundPropertyNameOfPropertyName
returns the literal name of a property, method, … if statically analyzableBugfixes:
Features:
isNumericOrStringLikeLiteral
, isTupleTypeReference
intersectionTypeParts
as counterpart to unionTypeParts
someTypePart
to execute a callback for each union or intersection constituent until the callback returns truegetPropertyOfType
looks up a property by its escaped nameisPropertyReadonlyInType
determines whether a property in a given type cannot be written tosymbolHasReadonlyDeclaration
determines if a Symbol has any readonly or constant declarationisNumericPropertyName
determines whether a property name would match an index signatureisBindableObjectDefinePropertyCall
returns true for statically analyzable forms of Object.defineProperty(o, 'p', {value, writable})
isReadonlyAssignmentDeclaration
determines whether an Object.defineProperty
call is known to result in a readonly propertygetLateBoundPropertyNames
returns all known property names of an expressiongetPropertyNameFromType
extracts the property name of literal typesisWellKnownSymbolLiterally
to recognize expressions in the form of Symbol.<name>
getPropertyNameOfWellKnownSymbol
returns the escaped name for a well known symbol literalunwrapParentheses
returns the first child expression that is not a ParenthesizedExpression
Features:
isCompilerOptionEnabled
: incremental
is implicitly enabled by composite
Bugfixes:
collectVariableUsage
/getUsageDomain
: no longer treat as const
as type usageBugfixes:
canHaveJsdoc
parseJsdocOfNode
Features:
isNullLiteral
and isBooleanLiteral
Features:
isConstAssertion
and isInConstContext
Features:
isBlockScopedDeclarationStatement
isInSingleStatementContext
Features:
getCheckJsDirective
utility to parse // @ts-check
and // @ts-nocheck
pragmasBugfixes:
const enum
. They are now declared as regular enums instead.Bugfixes:
isThenableType
allows Node
instead of Expression
as parameterisBlockScopeBoundary
and isScopeBoundary
consider WithStatement
as scope boundaryFeatures:
isBigIntLiteral
isLiteralType
recognises BigIntgetPropertyName
adds special handling for BigIntFeatures:
commentText
to get the actual text content of a comment excluding the characters needed to start and end the commentBugfixes:
findImports
: fixed handling of ImportEqualsDeclarationFeatures:
isCompilerOptionEnabled
: recognizes strictBindCallApply
getTokenAtPosition
: optionally includes JSDoc during lookupBugfixes:
isCompilerOptionEnabled
: correctly implements logic for allowSyntheticDefaultImports
findImportLikeNodes
: correctly finds imports in namespacesfindImportLikeNodes
/ findImports
: finds import types in JSDoc of JS filesFeatures:
findImportLikeNodes
that works similar to findImports
but returns the import statement or expression instead of the module specifier and doesn’t filter non-string module specifiersFeatures:
isKeywordKind
and isValidJsxIdentifier
:warning: Breaking Changes:
typescript@<2.8.0
getIdentifierText
, isJsxFramgment
, ImportOptions
isModifierFlagSet
, findImports
and getControlFlowEnd
'tsutils/util/util'
, import directly from 'tsutils/util/control-flow'
or 'tsutils/util'
isFunctionScopeBoundary
and isBlockScopeBoundary
now return a enum member of ScopeBoundary
instead of a booleanisFunctionScopeBoundary
no longer returns a truthy value for InterfaceDeclaration
, TypeAliasDeclaration
Features:
isTypeScopeBoundary
returning ScopeBoundary.Type
or ScopeBoundary.ConditionalType
ScopeBoundarySelector
whose members can be used to determine if a declaration belongs to a given ScopeBoundary
by using bitwise ANDBugfixes:
collectVariableUsage
now correctly handles infer T
nested inside function signatures or mapped typesisCompilerOptionEnabled
correctly handles skipDefaultLibCHeck
and suppressImplicitAnyIndexErrors
Features:
isCompilerOptionEnabled
Typeguards are now split into multiple submodules for each version of TypeScript (starting with 2.8.0).
That means you can now import directly from "tsutils/typeguard/2.8"
to get compatible declaraton files for TypeScript@2.8.
For more information please read the relevant section in README.md.
Features:
isTupleType
, isOptionalTypeNode
, isRestTypeNode
, isSyntheticExpression
(currently available from "tsutils/typeguard/3.0"
)isStrictCompilerOptionEnabled
Avoid crash caused by removed function in typescript@3.0.0
.
Added support for TypeScript@3.0.0 nightly builds.
Features:
getIIFE
utilityBugfixes:
forEachComment
and forEachTokenWithTrivia
no longer duplicate comments around missing nodesBugfixes:
hasSideEffects
with tagged template literal without substitution: tag`template`
Features:
isLiteralTypeNode
type T = import('foo')
) to findImports
via ImportKind.ImportType
Bugfixes:
collectVariableUsage
: fixed name lookup in function signatures to match runtime behavior. Note that this is not completely fixed in TypeScript, yet. See: Microsoft/TypeScript#22825 and Microsoft/TypeScript#22769Features:
isStatementInAmbientContext
and isAmbientModuleBlock
Features:
isConditionalTypeNode
, isInferTypeNode
, isConditionalType
, isInstantiableType
, isSubstitutionType
Features:
isForInOrOfStatement
Bugfixes:
<MyComponent<string>/*comment*/></MyComponent>
<div><br/>/*no comment*/</div>
Bugfixes:
collectVariableUsage
: handle ConditionalTypes and infer T
, which will be introduced in TypeScript@2.8.0 and are already available in nightly buildsisLiteralType
no longer returns true for ts.TypeFlags.BooleanLiteral
as this is not a ts.LiteralType
Bugfixes:
endsControlFlow
:
Features:
isFalsyType
utilityBugfixes:
typescript@2.8.0-dev
Bugfixes:
isReassignmentTarget
: handle type assertions and non-null assertionBugfixes:
forEachDeclaredVariable
uses a more precise type for the callback parameter to make it useable again with typescript@2.7.1Features:
isUniqueESSymbolType
typeguardFeatures:
isThenableType
utilityunionTypeParts
utilityBugfixes:
forEachComment
, getCommentAtPosition
and isPositionInComment
: skip shebang (#! something
) to not miss following comments at the start of the fileFeatures:
WrappedAst
interface that models the type of a wrapped SourceFile more accurategetWrappedNodeAtPosition
utiltiy that takes a NodeWrap
and returns the most deeply nested NodeWrap that contains the given positionFeatures:
getControlFlowEnd
accepts BlockLike as argumentBugfixes:
getControlFlowEnd
and endsControlFlow
: correctly handle nested LabeledStatementsendsControlFlow
removed erroneous special case when an IterationStatement is passed as argument whose parent is a LabeledStatement.
Deprecations:
getControlFlowEnd
that contains the label
parameter. This parameter is no longer used and should no longer be passed to the function.Bugfixes:
getControlFlowEnd
and endsControlFlow
(#22)
try
are filtered out if there is a catch
clausecatch
only end control flow if try
AND catch
definitely end control flowFeatures:
kind
property to NodeWrap
getControlFlowEnd
to public APIFeatures:
isDecorator
and isCallLikeExpression
typeguardsFeatures:
convertAst
utility to produce a flattened and wrapped version of the ASTFeatures:
isDeleteExpression
getLineBreakStyle
Bugfixes:
isJsxFragment
Features:
JsxFragment
introduced in typescript@2.6.2Bugfixes:
endsControlFlow
break
and continue
with labelsisValidIdentifier
and isValidNumericLiteral
handle irregular whitespacefindImports
searches in ambient modules inside regular .ts
files (not only .d.ts
)canHaveJsDoc
is now a typeguardBugfixes:
forEachTokenWithTrivia
API-Changes:
ImportOptions
if favor of the new ImportKind
enumBugfixes:
parseJsDocOfNode
: set correct pos
, end
and parent
properties. Also affects getJsDoc
of EndOfFileToken
Bugfixes:
collectVariableUsage
: correctly consider catch binding as block scoped declaration inside catch blockBugfixes:
getJsDoc
now correctly returns JsDoc for EndOfFileToken
Features:
parseJsDocOfNode
Features:
findImports
to find all kinds of imports in a source fileFeatures:
isMappedTypeNode
canHaveJsDoc
and getJsDoc
Bugfixes:
collectVariableUsage
: handle global augmentation like other module augmentationsBugfixes:
typescript@2.5.1
with optional catch bindingcollectVariableUsage
fixed a bug where method decorator had method’s parameters in scopegetIdentifierText
to unescape identifiers across typescript versionsBugfixes:
isReassignmentTarget
don’t return true
for right side of assignmentFeatures:
isReassignmentTarget
utilityBugfixes:
getDeclarationDomain
now returns undefined
for Parameter in IndexSignaturecollectVariableUsage
ignores Parameter in IndexSignatureBugfixes:
collectVariableUsage
:
export {};
isExpressionValueUsed
: handle destructuring in for...of
Features:
getModifier
utilityDeclarationDomain.Import
to distinguish imports from other declarationsBugfixes:
collectVariableUsage
ignore jump labels as in break label;
Bugfixes:
isFunctionWithBody
handles constructor overload correctly.Features:
isExpressionValueUsed
to check whether the result of an expression is actually used.getDeclarationDomain
to determine if a given declaration introduces a new symbol in the value or type domain.collectVariableUses
is now usable
: typeof foo
is handled for parameters and function return typeexport {Foo as Bar}
inside ambient namespaces and modulesBugfixes:
getLineRanges
: contentLength
now contains the correct line length when there are multiple consecutive line break charactersgetTokenAtPosition
: don’t match tokens that end at the specified position (because that’s already outside of their range)isModfierFlagSet
, use the new isModifierFlagSet
insteadFeatures:
isJsDoc
getUsageDomain
and collectVariableUsage
)Bugfixes:
forEachComment
no longer omits some comments when callback returns a truthy valueisPositionInComment
fixed false positive inside JSXTextFeatures:
getCommentAtPosition
Bugfixes:
SideEffectOptions.JsxElement
to be a power of 2Features:
getTokenAtPosition
and isPositionInComment
Features:
isExpression
hasSideEffects
, getDeclarationOfBindingElement
Breaking Changes:
typescript@<2.1.0
isNumericliteral
, use isNumericLiteral
instead (notice the uppercase L)isEnumLiteralType
which will cause compile errors with typescript@2.4.0require('tsutils/src/typeguard')
will be brokenFeatures:
require('tsutils/typeguard')
)Bugfixes:
isObjectFlagSet
now uses the correct objectFlags
propertyBugfixes:
getNextToken
no longer omits EndOfFileToken
when there is no trivia before EOF. That means the only inputs where getNextToken
returns undefined
are SourceFile
and EndOfFileToken
Features:
isNodeFlagSet
, isTypeFlagSet
, isSymbolFlagSet
,isObjectFlagSet
, isModifierFlagSet
Features:
isJsxAttributes
, isIntersectionTypeNode
, isTypeOperatorNode
, isTypePredicateNode
, isTypeQueryNode
, isUnionTypeNode
Bugfixes:
isFunctionScopeBoundary
now handles Interfaces, TypeAliases, FunctionSignatures, etcFeatures:
isThisParameter
, isSameLine
and isFunctionWithBody
Features:
isValidPropertyAccess
, isValidNumericLiteral
and isValidPropertyName
Features:
isValidIdentifier
Features:
contentLength
property to the result of getLineRanges
Bugfixes:
canHaveLeadingTrivia
:
hasOwnThisReference
: now includes accessors on object literalsFeatures:
Bugfixes:
hasOwnThisReference
:
Bugfixes:
isNumericLiteral
Features:
Bugfixes:
Features:
Features: