5 * added `getWellKnownSymbolPropertyOfType` to reliably get symbol named properties due to changes in typescript@4.3
6 * `getPropertyNameOfWellKnownSymbol` is now deprecated
12 * `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.
16 * `getJsDoc` for `EndOfFileToken` now returns `JSDoc` comments whose contents are usable with the type checker
22 * `getSymbolOfClassLikeDeclaration` no longer crashes on anonymous mixin classes
28 * `getSymbolOfClassLikeDeclaration` to retrieve the symbol of class declarations and expressions regardless whether they have a name or not
29 * `getBaseOfClassLikeDeclaration` to conventiently get the expression after `extends`
30 * `getBaseClassMemberOfClassElement` to look up the declaration of a class member in the base class
34 * `getConstructorTypeOfClassLikeDeclaration` now really returns the constructor type (the static side of the class), previously it returned the instance type
35 * `hasExhaustiveCaseClauses` allows additional case clauses with `null`, `undefined` and `never`
41 * Source maps for easier debugging
42 * JSDoc is preserved in declaration files
43 * Comments are presered in transpiled code
44 * Everything you need to handle the control flow changes of TypeScript@3.7
45 * `callExpressionAffectsControlFlow` to determine whether a CallExpression affects control flow by returning `never` or `asserts`
46 * `hasExhaustiveCaseClauses` to determine whether a SwitchStatement's CaseClauses handle every possible value
47 * `endsControlFlow` and `getControlFlowEnd` take an optional `checker` parameter to recognize exhaustive SwitchStatements and control flow effects of CallExpressions
48 * `formatPseudoBigInt` converts TypeScript's representation of a BigInt to its literal representation as you would write it in your source code
49 * `getAstNodeAtPosition` similar to `getTokenAtPosition`, but only operates on AST Nodes
50 * `removeOptionalChainingUndefinedMarkerType` and `isOptionalChainingUndefinedMarkerType` to handle types originating in an optional chain
51 * `findImports` and `findImportLikeNodes`: prepare for import assertions
52 * `getTsCheckDirective` as new name for `getCheckJsDirective`
53 * `getCheckJsDirective` is now deprecated
57 * `getUsageDomain`: handles NamespaceExport and NamedTupleMember
58 * `getPropertyName`: handles parentheses and negative numeric literals, excludes RegExp literals and private identifiers
59 * `getSingleLateBoundPropertyNameOfPropertyName` and `getLateBoundPropertyNamesOfPropertyName`: handles private identifiers
60 * `hasAccessModifier`: handles JSDoc access modifier
61 * `hasSideEffects`: correctly determines side effects of (static) property initializers
62 * `isExpressionValueUsed`: handle nullish coalescing and conditional assignment operators
63 * `canHaveJsDoc`: aligned with upstream changes in TypeScript
64 * `isCompilerOptionEnabled`:
65 * `noUncheckedIndexedAccess` requires `strictNullChecks`
66 * `checkJs` implies `allowJs`
67 * `emitDeclarationOnly` requires `declaration`
68 * `isInConstContext`: handle template string interpolations
69 * excluded unnecessary files from npm package
75 * `isValidJsxIdentifier`, `isValidPropertyAccess`, `isValidPropertyName`: fix unicode character width handling
81 * `isValidJsxIdentifier` added an optional parameter to specify the target ECMAScript version
85 * `isValidJsxIdentifier` now handles astral plane characters
91 * added `getIteratorYieldResultFromIteratorResult` to extract the `yield`ed type from `IteratorResult<TYield, TReturn, TNext>`
97 * `isValidIdentifier`, `isValidPropertyName`, `isValidPropertyAccess`, `isValidNumericLiteral` added an optional parameter to specify the target ECMAScript version
101 * `isValidPropertyName`, `isValidPropertyAccess` now handle astral plane characters
107 * `findImports`: fixed crash on nested namespaces
113 * added `getInstanceTypeOfClassLikeDeclaration` and `getConstructorTypeOfClassLikeDeclaration`
114 * added `AccessKind.Delete` to `getAccessKind`: `getAccessKind(node) & AccessKind.Modification` can now be used to restore the old behavior of `isReassignmentTarget(node)`
120 * `getAccessKind` determines whether an expression is read from, written to or both
121 * optimized `getPropertyOfType` for unambiguous property names to partially work around https://github.com/microsoft/TypeScript/issues/31565
125 * `isReassignmentTarget` no longer returns `true` for `DeleteExpression` as it doesn't **assign** a value to the operand
131 * `getLateBoundPropertyNamesOfPropertyName` returns all statically analyzable names of a property, method, ...
132 * `getSingleLateBoundPropertyNameOfPropertyName` returns the literal name of a property, method, ... if statically analyzable
136 * fixed circular import
142 * typeguards: `isNumericOrStringLikeLiteral`, `isTupleTypeReference`
143 * `intersectionTypeParts` as counterpart to `unionTypeParts`
144 * `someTypePart` to execute a callback for each union or intersection constituent until the callback returns true
145 * `getPropertyOfType` looks up a property by its escaped name
146 * `isPropertyReadonlyInType` determines whether a property in a given type cannot be written to
147 * `symbolHasReadonlyDeclaration` determines if a Symbol has any readonly or constant declaration
148 * `isNumericPropertyName` determines whether a property name would match an index signature
149 * `isBindableObjectDefinePropertyCall` returns true for statically analyzable forms of `Object.defineProperty(o, 'p', {value, writable})`
150 * `isReadonlyAssignmentDeclaration` determines whether an `Object.defineProperty` call is known to result in a readonly property
151 * `getLateBoundPropertyNames` returns all known property names of an expression
152 * `getPropertyNameFromType` extracts the property name of literal types
153 * `isWellKnownSymbolLiterally` to recognize expressions in the form of `Symbol.<name>`
154 * `getPropertyNameOfWellKnownSymbol` returns the escaped name for a well known symbol literal
155 * `unwrapParentheses` returns the first child expression that is not a `ParenthesizedExpression`
161 * `isCompilerOptionEnabled`: `incremental` is implicitly enabled by `composite`
165 * `collectVariableUsage`/`getUsageDomain`: no longer treat `as const` as type usage
171 * reverted invalid deprecation of `canHaveJsdoc`
172 * fixed condition in `parseJsdocOfNode`
178 * added typeguards: `isNullLiteral` and `isBooleanLiteral`
184 * exposes typeguards for typescript@3.2 by default
185 * added utilities: `isConstAssertion` and `isInConstContext`
191 * added `isBlockScopedDeclarationStatement`
192 * added `isInSingleStatementContext`
198 * added `getCheckJsDirective` utility to parse `// @ts-check` and `// @ts-nocheck` pragmas
204 * Published declaration files no longer contain `const enum`. They are now declared as regular enums instead.
210 * `isThenableType` allows `Node` instead of `Expression` as parameter
211 * `isBlockScopeBoundary` and `isScopeBoundary` consider `WithStatement` as scope boundary
217 * correctly handle BigInt literals
218 * added typeguard `isBigIntLiteral`
219 * `isLiteralType` recognises BigInt
220 * `getPropertyName` adds special handling for BigInt
226 * added utility `commentText` to get the actual text content of a comment excluding the characters needed to start and end the comment
232 * `findImports`: fixed handling of ImportEqualsDeclaration
238 * `isCompilerOptionEnabled`: recognizes `strictBindCallApply`
239 * `getTokenAtPosition`: optionally includes JSDoc during lookup
243 * `isCompilerOptionEnabled`: correctly implements logic for `allowSyntheticDefaultImports`
244 * `findImportLikeNodes`: correctly finds imports in namespaces
245 * `findImportLikeNodes` / `findImports`: finds import types in JSDoc of JS files
251 * added utility `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 specifiers
257 * added utilities: `isKeywordKind` and `isValidJsxIdentifier`
258 * exposes typeguards for typescript@3.0 by default
262 :warning: **Breaking Changes:**
264 * Dropped support for `typescript@<2.8.0`
265 * Dropped support for Node.js 4
266 * Removed deprecated APIs:
267 * `getIdentifierText`, `isJsxFramgment`, `ImportOptions`
268 * deprected overloads of `isModifierFlagSet`, `findImports` and `getControlFlowEnd`
269 * control flow related symbols can no longer be imported from `'tsutils/util/util'`, import directly from `'tsutils/util/control-flow'` or `'tsutils/util'`
270 * `isFunctionScopeBoundary` and `isBlockScopeBoundary` now return a enum member of `ScopeBoundary` instead of a boolean
271 * `isFunctionScopeBoundary` no longer returns a truthy value for `InterfaceDeclaration`, `TypeAliasDeclaration`
275 * added utility `isTypeScopeBoundary` returning `ScopeBoundary.Type` or `ScopeBoundary.ConditionalType`
276 * added enum `ScopeBoundarySelector` whose members can be used to determine if a declaration belongs to a given `ScopeBoundary` by using bitwise AND
280 * `collectVariableUsage` now correctly handles `infer T` nested inside function signatures or mapped types
281 * `isCompilerOptionEnabled` correctly handles `skipDefaultLibCHeck` and `suppressImplicitAnyIndexErrors`
287 * added utility `isCompilerOptionEnabled`
291 Typeguards are now split into multiple submodules for each version of TypeScript (starting with 2.8.0).
292 That means you can now import directly from `"tsutils/typeguard/2.8"` to get compatible declaraton files for TypeScript@2.8.
293 For more information please read the relevant section in [README.md](README.md).
297 * added typeguards: `isTupleType`, `isOptionalTypeNode`, `isRestTypeNode`, `isSyntheticExpression` (currently available from `"tsutils/typeguard/3.0"`)
298 * added utility `isStrictCompilerOptionEnabled`
302 Avoid crash caused by removed function in `typescript@3.0.0`.
306 Added support for TypeScript@3.0.0 nightly builds.
312 * added `getIIFE` utility
318 * `forEachComment` and `forEachTokenWithTrivia` no longer duplicate comments around missing nodes
324 * fixed crash in `hasSideEffects` with tagged template literal without substitution: ``tag`template` ``
330 * added typeguard `isLiteralTypeNode`
331 * added support for type imports (`type T = import('foo')`) to `findImports` via `ImportKind.ImportType`
337 * `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](https://github.com/Microsoft/TypeScript/issues/22825) and [Microsoft/TypeScript#22769](https://github.com/Microsoft/TypeScript/issues/22769)
343 * added utilities: `isStatementInAmbientContext` and `isAmbientModuleBlock`
349 * added typeguards for typescript@2.8: `isConditionalTypeNode`, `isInferTypeNode`, `isConditionalType`, `isInstantiableType`, `isSubstitutionType`
355 * added typeguard `isForInOrOfStatement`
359 * correctly handle comments in generic JSX elements: `<MyComponent<string>/*comment*/></MyComponent>`
360 * fixed a bug with false positive trailing comments at the end of JSX self closing element: `<div><br/>/*no comment*/</div>`
366 * `collectVariableUsage`: handle ConditionalTypes and `infer T`, which will be introduced in TypeScript@2.8.0 and are already available in nightly builds
367 * `isLiteralType` no longer returns true for `ts.TypeFlags.BooleanLiteral` as this is not a `ts.LiteralType`
374 * handle loops that might not even run a single iteration
375 * handle constant boolean conditions in loops and if
381 * added `isFalsyType` utility
387 * fixed compile error with `typescript@2.8.0-dev`
393 * `isReassignmentTarget`: handle type assertions and non-null assertion
399 * `forEachDeclaredVariable` uses a more precise type for the callback parameter to make it useable again with typescript@2.7.1
403 * added `isUniqueESSymbolType` typeguard
409 * added `isThenableType` utility
410 * added `unionTypeParts` utility
416 * `forEachComment`, `getCommentAtPosition` and `isPositionInComment`: skip shebang (`#! something`) to not miss following comments at the start of the file
422 * added `WrappedAst` interface that models the type of a wrapped SourceFile more accurate
423 * added `getWrappedNodeAtPosition` utiltiy that takes a `NodeWrap` and returns the most deeply nested NodeWrap that contains the given position
429 * `getControlFlowEnd` accepts BlockLike as argument
433 * `getControlFlowEnd` and `endsControlFlow`: correctly handle nested LabeledStatements
434 * `endsControlFlow` removed erroneous special case when an IterationStatement is passed as argument whose parent is a LabeledStatement.
435 * if you want labels of an IterationStatement (or SwitchStatement) to be handled, you need to pass the LabeledStatement as argument.
436 * :warning: this fix may change the returned value if you relied on the buggy behavior
440 * deprecated overload of `getControlFlowEnd` that contains the `label` parameter. This parameter is no longer used and should no longer be passed to the function.
446 * `getControlFlowEnd` and `endsControlFlow` (#22)
447 * ThrowStatements inside `try` are filtered out if there is a `catch` clause
448 * TryStatements with `catch` only end control flow if `try` AND `catch` definitely end control flow
454 * added `kind` property to `NodeWrap`
455 * added `getControlFlowEnd` to public API
461 * added `isDecorator` and `isCallLikeExpression` typeguards
467 * added `convertAst` utility to produce a flattened and wrapped version of the AST
473 * added `isDeleteExpression`
474 * added `getLineBreakStyle`
480 * fixed name of `isJsxFragment`
486 * added support for `JsxFragment` introduced in typescript@2.6.2
487 * added corresponding typeguard functions
494 * added missing logic for labeled statement, iteration statements and try-catch
495 * added missing logic for `break` and `continue` with labels
496 * take all jump statements into account, not only the last statement
497 * `isValidIdentifier` and `isValidNumericLiteral` handle irregular whitespace
498 * `findImports` searches in ambient modules inside regular `.ts` files (not only `.d.ts`)
499 * `canHaveJsDoc` is now a typeguard
505 * `forEachTokenWithTrivia`
506 * handles irregular whitespace and no longer visits some tokens twice
507 * correctly calculates the range of JsxText
513 * deprecated `ImportOptions` if favor of the new `ImportKind` enum
519 * `parseJsDocOfNode`: set correct `pos`, `end` and `parent` properties. Also affects `getJsDoc` of `EndOfFileToken`
525 * `collectVariableUsage`: correctly consider catch binding as block scoped declaration inside catch block
531 * `getJsDoc` now correctly returns JsDoc for `EndOfFileToken`
535 * added utility `parseJsDocOfNode`
541 * added utility `findImports` to find all kinds of imports in a source file
547 * added typeguard `isMappedTypeNode`
548 * added utilities `canHaveJsDoc` and `getJsDoc`
554 * `collectVariableUsage`: handle global augmentation like other module augmentations
560 * Support `typescript@2.5.1` with optional catch binding
561 * `collectVariableUsage` fixed a bug where method decorator had method's parameters in scope
565 * Compatibility with the latest typescript nightly
566 * Added `getIdentifierText` to unescape identifiers across typescript versions
572 * `isReassignmentTarget` don't return `true` for right side of assignment
578 * Added `isReassignmentTarget` utility
584 * `getDeclarationDomain` now returns `undefined` for Parameter in IndexSignature
585 * `collectVariableUsage` ignores Parameter in IndexSignature
591 * `collectVariableUsage`:
592 * don't merge imports with global declarations
593 * treat everything in a declaration file as exported if there is no explicit `export {};`
594 * `isExpressionValueUsed`: handle destructuring in `for...of`
598 * Added `getModifier` utility
599 * Added `DeclarationDomain.Import` to distinguish imports from other declarations
605 * `collectVariableUsage` ignore jump labels as in `break label;`
611 * `isFunctionWithBody` handles constructor overload correctly.
615 * Implemented `isExpressionValueUsed` to check whether the result of an expression is actually used.
616 * Implemented `getDeclarationDomain` to determine if a given declaration introduces a new symbol in the value or type domain.
618 **`collectVariableUses` is now usable**
620 * no longer ignores signatures and its parameters
621 * don't merge declarations and uses across domains
622 * no longer marks exceptions in catch clause or parameter properties as exported
623 * fixed exports of namespaces
624 * fixed scoping of ClassExpression name
625 * correcly handle ambient namespaces and module augmentations
626 * fixed how `: typeof foo` is handled for parameters and function return type
627 * **still WIP**: `export {Foo as Bar}` inside ambient namespaces and modules
633 * `getLineRanges`: `contentLength` now contains the correct line length when there are multiple consecutive line break characters
634 * `getTokenAtPosition`: don't match tokens that end at the specified position (because that's already outside of their range)
635 * deprecated the misnamed `isModfierFlagSet`, use the new `isModifierFlagSet` instead
639 * Added typeguard: `isJsDoc`
640 * Added experimental scope and usage analysis (`getUsageDomain` and `collectVariableUsage`)
646 * `forEachComment` no longer omits some comments when callback returns a truthy value
647 * `isPositionInComment` fixed false positive inside JSXText
651 * Added utility: `getCommentAtPosition`
657 * Fixed bit value of `SideEffectOptions.JsxElement` to be a power of 2
661 * Added utilities: `getTokenAtPosition` and `isPositionInComment`
667 * Added typeguard `isExpression`
668 * Added utilities: `hasSideEffects`, `getDeclarationOfBindingElement`
672 **Breaking Changes:**
674 * Dropped compatibility with `typescript@<2.1.0`
675 * Removed misnamed `isNumericliteral`, use `isNumericLiteral` instead (notice the uppercase L)
676 * Removed `isEnumLiteralType` which will cause compile errors with typescript@2.4.0
677 * Refactored directory structure: all imports that referenced subdirectories (e.g. `require('tsutils/src/typeguard')` will be broken
681 * New directory structure allows imports of typeguards or utils independently, e.g. (`require('tsutils/typeguard')`)
687 * `isObjectFlagSet` now uses the correct `objectFlags` property
693 * `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`
697 * Added typeguards for types
698 * Added utilities for flag checking: `isNodeFlagSet`, `isTypeFlagSet`, `isSymbolFlagSet`,`isObjectFlagSet`, `isModifierFlagSet`
704 * Support peer dependency of typescript nightlies of 2.4.0
705 * Added typeguards: `isJsxAttributes`, `isIntersectionTypeNode`, `isTypeOperatorNode`, `isTypePredicateNode`, `isTypeQueryNode`, `isUnionTypeNode`
711 * `isFunctionScopeBoundary` now handles Interfaces, TypeAliases, FunctionSignatures, etc
715 * Added utilities: `isThisParameter`, `isSameLine` and `isFunctionWithBody`
721 * Add `isValidPropertyAccess`, `isValidNumericLiteral` and `isValidPropertyName`
727 * Add `isValidIdentifier`
733 * Add `contentLength` property to the result of `getLineRanges`
739 * `canHaveLeadingTrivia`:
740 * Fix property access on undefined parent reference
741 * Fixes: [palantir/tslint#2330](https://github.com/palantir/tslint/issues/2330)
742 * `hasOwnThisReference`: now includes accessors on object literals
747 * isTypeParameterDeclaration
754 * `hasOwnThisReference`:
755 * exclude overload signatures of function declarations
756 * add method declarations on object literals
762 * Fix name of `isNumericLiteral`
770 * isExpressionWithTypeArguments
773 * isJsDocKind, isTypeNodeKind
774 * Allow typescript@next in peerDependencies
780 * Fix isBlockScopeBoundary: Remove WithStatement, IfStatment, DoStatement and WhileStatement because they are no scope boundary whitout a block.
784 * Added more typeguards:
785 * isAssertionExpression
788 * isJsxOpeningLikeElement
789 * isNonNullExpression
792 * getNextToken, getPreviousToken
793 * hasOwnThisReference
800 * Initial implementation of typeguards
803 * isNodeKind, isAssignmentKind
804 * hasModifier, isParameterProperty, hasAccessModifier
805 * getPreviousStatement, getNextStatement
807 * forEachDestructuringIdentifier, forEachDeclaredVariable
808 * getVariableDeclarationKind, isBlockScopedVariableDeclarationList, isBlockScopedVariableDeclaration
809 * isScopeBoundary, isFunctionScopeBoundary, isBlockScopeBoundary
810 * forEachToken, forEachTokenWithTrivia, forEachComment