22 KiB
3.21.0
Features:
- added
getWellKnownSymbolPropertyOfTypeto reliably get symbol named properties due to changes in typescript@4.3 getPropertyNameOfWellKnownSymbolis now deprecated
3.20.0
Features:
findImportsandfindImportLikeNodestake an additional parameterignoreFileName. The default value for this paramter istrueto remain backwards compatible. When set tofalse, it matches the behavior of TypeScript, i.e. only looks forrequirein JavaScript files.
Bugfixes:
getJsDocforEndOfFileTokennow returnsJSDoccomments whose contents are usable with the type checker
3.19.1
Bugfixes:
getSymbolOfClassLikeDeclarationno longer crashes on anonymous mixin classes
3.19.0
Features:
getSymbolOfClassLikeDeclarationto retrieve the symbol of class declarations and expressions regardless whether they have a name or notgetBaseOfClassLikeDeclarationto conventiently get the expression afterextendsgetBaseClassMemberOfClassElementto look up the declaration of a class member in the base class
Bugfixes:
getConstructorTypeOfClassLikeDeclarationnow really returns the constructor type (the static side of the class), previously it returned the instance typehasExhaustiveCaseClausesallows additional case clauses withnull,undefinedandnever
3.18.0
Features:
- Source maps for easier debugging
- JSDoc is preserved in declaration files
- Comments are presered in transpiled code
- Everything you need to handle the control flow changes of TypeScript@3.7
callExpressionAffectsControlFlowto determine whether a CallExpression affects control flow by returningneverorassertshasExhaustiveCaseClausesto determine whether a SwitchStatement's CaseClauses handle every possible valueendsControlFlowandgetControlFlowEndtake an optionalcheckerparameter to recognize exhaustive SwitchStatements and control flow effects of CallExpressions
formatPseudoBigIntconverts TypeScript's representation of a BigInt to its literal representation as you would write it in your source codegetAstNodeAtPositionsimilar togetTokenAtPosition, but only operates on AST NodesremoveOptionalChainingUndefinedMarkerTypeandisOptionalChainingUndefinedMarkerTypeto handle types originating in an optional chainfindImportsandfindImportLikeNodes: prepare for import assertionsgetTsCheckDirectiveas new name forgetCheckJsDirectivegetCheckJsDirectiveis now deprecated
Bugfixes:
getUsageDomain: handles NamespaceExport and NamedTupleMembergetPropertyName: handles parentheses and negative numeric literals, excludes RegExp literals and private identifiersgetSingleLateBoundPropertyNameOfPropertyNameandgetLateBoundPropertyNamesOfPropertyName: 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:noUncheckedIndexedAccessrequiresstrictNullCheckscheckJsimpliesallowJsemitDeclarationOnlyrequiresdeclaration
isInConstContext: handle template string interpolations- excluded unnecessary files from npm package
3.17.1
Bugfixes:
isValidJsxIdentifier,isValidPropertyAccess,isValidPropertyName: fix unicode character width handling
3.17.0
Features:
isValidJsxIdentifieradded an optional parameter to specify the target ECMAScript version
Bugfixes:
isValidJsxIdentifiernow handles astral plane characters
3.16.0
Features:
- added
getIteratorYieldResultFromIteratorResultto extract theyielded type fromIteratorResult<TYield, TReturn, TNext>
3.15.0
Features:
isValidIdentifier,isValidPropertyName,isValidPropertyAccess,isValidNumericLiteraladded an optional parameter to specify the target ECMAScript version
Bugfixes:
isValidPropertyName,isValidPropertyAccessnow handle astral plane characters
3.14.1
Bugfixes:
findImports: fixed crash on nested namespaces
3.14.0
Features:
- added
getInstanceTypeOfClassLikeDeclarationandgetConstructorTypeOfClassLikeDeclaration - added
AccessKind.DeletetogetAccessKind:getAccessKind(node) & AccessKind.Modificationcan now be used to restore the old behavior ofisReassignmentTarget(node)
3.13.0
Features:
getAccessKinddetermines whether an expression is read from, written to or both- optimized
getPropertyOfTypefor unambiguous property names to partially work around https://github.com/microsoft/TypeScript/issues/31565
Bugfixes:
isReassignmentTargetno longer returnstrueforDeleteExpressionas it doesn't assign a value to the operand
3.12.0
Features:
getLateBoundPropertyNamesOfPropertyNamereturns all statically analyzable names of a property, method, ...getSingleLateBoundPropertyNameOfPropertyNamereturns the literal name of a property, method, ... if statically analyzable
Bugfixes:
- fixed circular import
3.11.0
Features:
- typeguards:
isNumericOrStringLikeLiteral,isTupleTypeReference intersectionTypePartsas counterpart tounionTypePartssomeTypePartto execute a callback for each union or intersection constituent until the callback returns truegetPropertyOfTypelooks up a property by its escaped nameisPropertyReadonlyInTypedetermines whether a property in a given type cannot be written tosymbolHasReadonlyDeclarationdetermines if a Symbol has any readonly or constant declarationisNumericPropertyNamedetermines whether a property name would match an index signatureisBindableObjectDefinePropertyCallreturns true for statically analyzable forms ofObject.defineProperty(o, 'p', {value, writable})isReadonlyAssignmentDeclarationdetermines whether anObject.definePropertycall is known to result in a readonly propertygetLateBoundPropertyNamesreturns all known property names of an expressiongetPropertyNameFromTypeextracts the property name of literal typesisWellKnownSymbolLiterallyto recognize expressions in the form ofSymbol.<name>getPropertyNameOfWellKnownSymbolreturns the escaped name for a well known symbol literalunwrapParenthesesreturns the first child expression that is not aParenthesizedExpression
3.10.0
Features:
isCompilerOptionEnabled:incrementalis implicitly enabled bycomposite
Bugfixes:
collectVariableUsage/getUsageDomain: no longer treatas constas type usage
3.9.1
Bugfixes:
- reverted invalid deprecation of
canHaveJsdoc - fixed condition in
parseJsdocOfNode
3.9.0
Features:
- added typeguards:
isNullLiteralandisBooleanLiteral
3.8.0
Features:
- exposes typeguards for typescript@3.2 by default
- added utilities:
isConstAssertionandisInConstContext
3.7.0
Features:
- added
isBlockScopedDeclarationStatement - added
isInSingleStatementContext
3.6.0
Features:
- added
getCheckJsDirectiveutility to parse// @ts-checkand// @ts-nocheckpragmas
3.5.2
Bugfixes:
- Published declaration files no longer contain
const enum. They are now declared as regular enums instead.
3.5.1
Bugfixes:
isThenableTypeallowsNodeinstead ofExpressionas parameterisBlockScopeBoundaryandisScopeBoundaryconsiderWithStatementas scope boundary
3.5.0
Features:
- correctly handle BigInt literals
- added typeguard
isBigIntLiteral isLiteralTyperecognises BigIntgetPropertyNameadds special handling for BigInt
- added typeguard
3.4.0
Features:
- added utility
commentTextto get the actual text content of a comment excluding the characters needed to start and end the comment
3.3.1
Bugfixes:
findImports: fixed handling of ImportEqualsDeclaration
3.3.0
Features:
isCompilerOptionEnabled: recognizesstrictBindCallApplygetTokenAtPosition: optionally includes JSDoc during lookup
Bugfixes:
isCompilerOptionEnabled: correctly implements logic forallowSyntheticDefaultImportsfindImportLikeNodes: correctly finds imports in namespacesfindImportLikeNodes/findImports: finds import types in JSDoc of JS files
3.2.0
Features:
- added utility
findImportLikeNodesthat works similar tofindImportsbut returns the import statement or expression instead of the module specifier and doesn't filter non-string module specifiers
3.1.0
Features:
- added utilities:
isKeywordKindandisValidJsxIdentifier - exposes typeguards for typescript@3.0 by default
3.0.0
⚠️ Breaking Changes:
- Dropped support for
typescript@<2.8.0 - Dropped support for Node.js 4
- Removed deprecated APIs:
getIdentifierText,isJsxFramgment,ImportOptions- deprected overloads of
isModifierFlagSet,findImportsandgetControlFlowEnd
- control flow related symbols can no longer be imported from
'tsutils/util/util', import directly from'tsutils/util/control-flow'or'tsutils/util' isFunctionScopeBoundaryandisBlockScopeBoundarynow return a enum member ofScopeBoundaryinstead of a booleanisFunctionScopeBoundaryno longer returns a truthy value forInterfaceDeclaration,TypeAliasDeclaration
Features:
- added utility
isTypeScopeBoundaryreturningScopeBoundary.TypeorScopeBoundary.ConditionalType - added enum
ScopeBoundarySelectorwhose members can be used to determine if a declaration belongs to a givenScopeBoundaryby using bitwise AND
Bugfixes:
collectVariableUsagenow correctly handlesinfer Tnested inside function signatures or mapped typesisCompilerOptionEnabledcorrectly handlesskipDefaultLibCHeckandsuppressImplicitAnyIndexErrors
2.29.0
Features:
- added utility
isCompilerOptionEnabled
2.28.0
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:
- added typeguards:
isTupleType,isOptionalTypeNode,isRestTypeNode,isSyntheticExpression(currently available from"tsutils/typeguard/3.0") - added utility
isStrictCompilerOptionEnabled
2.27.2
Avoid crash caused by removed function in typescript@3.0.0.
2.27.1
Added support for TypeScript@3.0.0 nightly builds.
2.27.0
Features:
- added
getIIFEutility
2.26.2
Bugfixes:
forEachCommentandforEachTokenWithTriviano longer duplicate comments around missing nodes
2.26.1
Bugfixes:
- fixed crash in
hasSideEffectswith tagged template literal without substitution:tag`template`
2.26.0
Features:
- added typeguard
isLiteralTypeNode - added support for type imports (
type T = import('foo')) tofindImportsviaImportKind.ImportType
2.25.1
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#22769
2.25.0
Features:
- added utilities:
isStatementInAmbientContextandisAmbientModuleBlock
2.24.0
Features:
- added typeguards for typescript@2.8:
isConditionalTypeNode,isInferTypeNode,isConditionalType,isInstantiableType,isSubstitutionType
2.23.0
Features:
- added typeguard
isForInOrOfStatement
Bugfixes:
- correctly handle comments in generic JSX elements:
<MyComponent<string>/*comment*/></MyComponent> - fixed a bug with false positive trailing comments at the end of JSX self closing element:
<div><br/>/*no comment*/</div>
2.22.2
Bugfixes:
collectVariableUsage: handle ConditionalTypes andinfer T, which will be introduced in TypeScript@2.8.0 and are already available in nightly buildsisLiteralTypeno longer returns true forts.TypeFlags.BooleanLiteralas this is not ats.LiteralType
2.22.1
Bugfixes:
endsControlFlow:- handle loops that might not even run a single iteration
- handle constant boolean conditions in loops and if
2.22.0
Features:
- added
isFalsyTypeutility
2.21.2
Bugfixes:
- fixed compile error with
typescript@2.8.0-dev
2.21.1
Bugfixes:
isReassignmentTarget: handle type assertions and non-null assertion
2.21.0
Bugfixes:
forEachDeclaredVariableuses a more precise type for the callback parameter to make it useable again with typescript@2.7.1
Features:
- added
isUniqueESSymbolTypetypeguard
2.20.0
Features:
- added
isThenableTypeutility - added
unionTypePartsutility
2.19.1
Bugfixes:
forEachComment,getCommentAtPositionandisPositionInComment: skip shebang (#! something) to not miss following comments at the start of the file
2.19.0
Features:
- added
WrappedAstinterface that models the type of a wrapped SourceFile more accurate - added
getWrappedNodeAtPositionutiltiy that takes aNodeWrapand returns the most deeply nested NodeWrap that contains the given position
2.18.0
Features:
getControlFlowEndaccepts BlockLike as argument
Bugfixes:
getControlFlowEndandendsControlFlow: correctly handle nested LabeledStatementsendsControlFlowremoved erroneous special case when an IterationStatement is passed as argument whose parent is a LabeledStatement.- if you want labels of an IterationStatement (or SwitchStatement) to be handled, you need to pass the LabeledStatement as argument.
- ⚠️ this fix may change the returned value if you relied on the buggy behavior
Deprecations:
- deprecated overload of
getControlFlowEndthat contains thelabelparameter. This parameter is no longer used and should no longer be passed to the function.
2.17.1
Bugfixes:
getControlFlowEndandendsControlFlow(#22)- ThrowStatements inside
tryare filtered out if there is acatchclause - TryStatements with
catchonly end control flow iftryANDcatchdefinitely end control flow
- ThrowStatements inside
2.17.0
Features:
- added
kindproperty toNodeWrap - added
getControlFlowEndto public API
2.16.0
Features:
- added
isDecoratorandisCallLikeExpressiontypeguards
2.15.0
Features:
- added
convertAstutility to produce a flattened and wrapped version of the AST
2.14.0
Features:
- added
isDeleteExpression - added
getLineBreakStyle
2.13.1
Bugfixes:
- fixed name of
isJsxFragment
2.13.0
Features:
- added support for
JsxFragmentintroduced in typescript@2.6.2 - added corresponding typeguard functions
2.12.2
Bugfixes:
endsControlFlow- added missing logic for labeled statement, iteration statements and try-catch
- added missing logic for
breakandcontinuewith labels - take all jump statements into account, not only the last statement
isValidIdentifierandisValidNumericLiteralhandle irregular whitespacefindImportssearches in ambient modules inside regular.tsfiles (not only.d.ts)canHaveJsDocis now a typeguard
2.12.1
Bugfixes:
forEachTokenWithTrivia- handles irregular whitespace and no longer visits some tokens twice
- correctly calculates the range of JsxText
2.12.0
API-Changes:
- deprecated
ImportOptionsif favor of the newImportKindenum
2.11.2
Bugfixes:
parseJsDocOfNode: set correctpos,endandparentproperties. Also affectsgetJsDocofEndOfFileToken
2.11.1
Bugfixes:
collectVariableUsage: correctly consider catch binding as block scoped declaration inside catch block
2.11.0
Bugfixes:
getJsDocnow correctly returns JsDoc forEndOfFileToken
Features:
- added utility
parseJsDocOfNode
2.10.0
Features:
- added utility
findImportsto find all kinds of imports in a source file
2.9.0
Features:
- added typeguard
isMappedTypeNode - added utilities
canHaveJsDocandgetJsDoc
2.8.2
Bugfixes:
collectVariableUsage: handle global augmentation like other module augmentations
2.8.1
Bugfixes:
- Support
typescript@2.5.1with optional catch binding collectVariableUsagefixed a bug where method decorator had method's parameters in scope
2.8.0
- Compatibility with the latest typescript nightly
- Added
getIdentifierTextto unescape identifiers across typescript versions
2.7.1
Bugfixes:
isReassignmentTargetdon't returntruefor right side of assignment
2.7.0
Features:
- Added
isReassignmentTargetutility
2.6.1
Bugfixes:
getDeclarationDomainnow returnsundefinedfor Parameter in IndexSignaturecollectVariableUsageignores Parameter in IndexSignature
2.6.0
Bugfixes:
collectVariableUsage:- don't merge imports with global declarations
- treat everything in a declaration file as exported if there is no explicit
export {};
isExpressionValueUsed: handle destructuring infor...of
Features:
- Added
getModifierutility - Added
DeclarationDomain.Importto distinguish imports from other declarations
2.5.1
Bugfixes:
collectVariableUsageignore jump labels as inbreak label;
2.5.0
Bugfixes:
isFunctionWithBodyhandles constructor overload correctly.
Features:
- Implemented
isExpressionValueUsedto check whether the result of an expression is actually used. - Implemented
getDeclarationDomainto determine if a given declaration introduces a new symbol in the value or type domain.
collectVariableUses is now usable
- no longer ignores signatures and its parameters
- don't merge declarations and uses across domains
- no longer marks exceptions in catch clause or parameter properties as exported
- fixed exports of namespaces
- fixed scoping of ClassExpression name
- correcly handle ambient namespaces and module augmentations
- fixed how
: typeof foois handled for parameters and function return type - still WIP:
export {Foo as Bar}inside ambient namespaces and modules
2.4.0
Bugfixes:
getLineRanges:contentLengthnow 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)- deprecated the misnamed
isModfierFlagSet, use the newisModifierFlagSetinstead
Features:
- Added typeguard:
isJsDoc - Added experimental scope and usage analysis (
getUsageDomainandcollectVariableUsage)
2.3.0
Bugfixes:
forEachCommentno longer omits some comments when callback returns a truthy valueisPositionInCommentfixed false positive inside JSXText
Features:
- Added utility:
getCommentAtPosition
2.2.0
Bugfixes:
- Fixed bit value of
SideEffectOptions.JsxElementto be a power of 2
Features:
- Added utilities:
getTokenAtPositionandisPositionInComment
2.1.0
Features:
- Added typeguard
isExpression - Added utilities:
hasSideEffects,getDeclarationOfBindingElement
2.0.0
Breaking Changes:
- Dropped compatibility with
typescript@<2.1.0 - Removed misnamed
isNumericliteral, useisNumericLiteralinstead (notice the uppercase L) - Removed
isEnumLiteralTypewhich will cause compile errors with typescript@2.4.0 - Refactored directory structure: all imports that referenced subdirectories (e.g.
require('tsutils/src/typeguard')will be broken
Features:
- New directory structure allows imports of typeguards or utils independently, e.g. (
require('tsutils/typeguard'))
1.9.1
Bugfixes:
isObjectFlagSetnow uses the correctobjectFlagsproperty
1.9.0
Bugfixes:
getNextTokenno longer omitsEndOfFileTokenwhen there is no trivia before EOF. That means the only inputs wheregetNextTokenreturnsundefinedareSourceFileandEndOfFileToken
Features:
- Added typeguards for types
- Added utilities for flag checking:
isNodeFlagSet,isTypeFlagSet,isSymbolFlagSet,isObjectFlagSet,isModifierFlagSet
1.8.0
Features:
- Support peer dependency of typescript nightlies of 2.4.0
- Added typeguards:
isJsxAttributes,isIntersectionTypeNode,isTypeOperatorNode,isTypePredicateNode,isTypeQueryNode,isUnionTypeNode
1.7.0
Bugfixes:
isFunctionScopeBoundarynow handles Interfaces, TypeAliases, FunctionSignatures, etc
Features:
- Added utilities:
isThisParameter,isSameLineandisFunctionWithBody
1.6.0
Features:
- Add
isValidPropertyAccess,isValidNumericLiteralandisValidPropertyName
1.5.0
Features:
- Add
isValidIdentifier
1.4.0
Features:
- Add
contentLengthproperty to the result ofgetLineRanges
1.3.0
Bugfixes:
canHaveLeadingTrivia:- Fix property access on undefined parent reference
- Fixes: palantir/tslint#2330
hasOwnThisReference: now includes accessors on object literals
Features:
- Typeguards:
- isTypeParameterDeclaration
- isEnitityName
1.2.2
Bugfixes:
hasOwnThisReference:- exclude overload signatures of function declarations
- add method declarations on object literals
1.2.1
Bugfixes:
- Fix name of
isNumericLiteral
1.2.0
Features:
- Typeguards:
- isEnumMember
- isExpressionWithTypeArguments
- isImportSpecifier
- Utilities:
- isJsDocKind, isTypeNodeKind
- Allow typescript@next in peerDependencies
1.1.0
Bugfixes:
- Fix isBlockScopeBoundary: Remove WithStatement, IfStatment, DoStatement and WhileStatement because they are no scope boundary whitout a block.
Features:
- Added more typeguards:
- isAssertionExpression
- isEmptyStatement
- isJsxAttributeLike
- isJsxOpeningLikeElement
- isNonNullExpression
- isSyntaxList
- Utilities:
- getNextToken, getPreviousToken
- hasOwnThisReference
- getLineRanges
1.0.0
Features:
- Initial implementation of typeguards
- Utilities:
- getChildOfKind
- isNodeKind, isAssignmentKind
- hasModifier, isParameterProperty, hasAccessModifier
- getPreviousStatement, getNextStatement
- getPropertyName
- forEachDestructuringIdentifier, forEachDeclaredVariable
- getVariableDeclarationKind, isBlockScopedVariableDeclarationList, isBlockScopedVariableDeclaration
- isScopeBoundary, isFunctionScopeBoundary, isBlockScopeBoundary
- forEachToken, forEachTokenWithTrivia, forEachComment
- endsControlFlow