5 * `isValidJsxIdentifier`, `isValidPropertyAccess`, `isValidPropertyName`: fix unicode character width handling
11 * `isValidJsxIdentifier` added an optional parameter to specify the target ECMAScript version
15 * `isValidJsxIdentifier` now handles astral plane characters
21 * added `getIteratorYieldResultFromIteratorResult` to extract the `yield`ed type from `IteratorResult<TYield, TReturn, TNext>`
27 * `isValidIdentifier`, `isValidPropertyName`, `isValidPropertyAccess`, `isValidNumericLiteral` added an optional parameter to specify the target ECMAScript version
31 * `isValidPropertyName`, `isValidPropertyAccess` now handle astral plane characters
37 * `findImports`: fixed crash on nested namespaces
43 * added `getInstanceTypeOfClassLikeDeclaration` and `getConstructorTypeOfClassLikeDeclaration`
44 * added `AccessKind.Delete` to `getAccessKind`: `getAccessKind(node) & AccessKind.Modification` can now be used to restore the old behavior of `isReassignmentTarget(node)`
50 * `getAccessKind` determines whether an expression is read from, written to or both
51 * optimized `getPropertyOfType` for unambiguous property names to partially work around https://github.com/microsoft/TypeScript/issues/31565
55 * `isReassignmentTarget` no longer returns `true` for `DeleteExpression` as it doesn't **assign** a value to the operand
61 * `getLateBoundPropertyNamesOfPropertyName` returns all statically analyzable names of a property, method, ...
62 * `getSingleLateBoundPropertyNameOfPropertyName` returns the literal name of a property, method, ... if statically analyzable
66 * fixed circular import
72 * typeguards: `isNumericOrStringLikeLiteral`, `isTupleTypeReference`
73 * `intersectionTypeParts` as counterpart to `unionTypeParts`
74 * `someTypePart` to execute a callback for each union or intersection constituent until the callback returns true
75 * `getPropertyOfType` looks up a property by its escaped name
76 * `isPropertyReadonlyInType` determines whether a property in a given type cannot be written to
77 * `symbolHasReadonlyDeclaration` determines if a Symbol has any readonly or constant declaration
78 * `isNumericPropertyName` determines whether a property name would match an index signature
79 * `isBindableObjectDefinePropertyCall` returns true for statically analyzable forms of `Object.defineProperty(o, 'p', {value, writable})`
80 * `isReadonlyAssignmentDeclaration` determines whether an `Object.defineProperty` call is known to result in a readonly property
81 * `getLateBoundPropertyNames` returns all known property names of an expression
82 * `getPropertyNameFromType` extracts the property name of literal types
83 * `isWellKnownSymbolLiterally` to recognize expressions in the form of `Symbol.<name>`
84 * `getPropertyNameOfWellKnownSymbol` returns the escaped name for a well known symbol literal
85 * `unwrapParentheses` returns the first child expression that is not a `ParenthesizedExpression`
91 * `isCompilerOptionEnabled`: `incremental` is implicitly enabled by `composite`
95 * `collectVariableUsage`/`getUsageDomain`: no longer treat `as const` as type usage
101 * reverted invalid deprecation of `canHaveJsdoc`
102 * fixed condition in `parseJsdocOfNode`
108 * added typeguards: `isNullLiteral` and `isBooleanLiteral`
114 * exposes typeguards for typescript@3.2 by default
115 * added utilities: `isConstAssertion` and `isInConstContext`
121 * added `isBlockScopedDeclarationStatement`
122 * added `isInSingleStatementContext`
128 * added `getCheckJsDirective` utility to parse `// @ts-check` and `// @ts-nocheck` pragmas
134 * Published declaration files no longer contain `const enum`. They are now declared as regular enums instead.
140 * `isThenableType` allows `Node` instead of `Expression` as parameter
141 * `isBlockScopeBoundary` and `isScopeBoundary` consider `WithStatement` as scope boundary
147 * correctly handle BigInt literals
148 * added typeguard `isBigIntLiteral`
149 * `isLiteralType` recognises BigInt
150 * `getPropertyName` adds special handling for BigInt
156 * added utility `commentText` to get the actual text content of a comment excluding the characters needed to start and end the comment
162 * `findImports`: fixed handling of ImportEqualsDeclaration
168 * `isCompilerOptionEnabled`: recognizes `strictBindCallApply`
169 * `getTokenAtPosition`: optionally includes JSDoc during lookup
173 * `isCompilerOptionEnabled`: correctly implements logic for `allowSyntheticDefaultImports`
174 * `findImportLikeNodes`: correctly finds imports in namespaces
175 * `findImportLikeNodes` / `findImports`: finds import types in JSDoc of JS files
181 * 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
187 * added utilities: `isKeywordKind` and `isValidJsxIdentifier`
188 * exposes typeguards for typescript@3.0 by default
192 :warning: **Breaking Changes:**
194 * Dropped support for `typescript@<2.8.0`
195 * Dropped support for Node.js 4
196 * Removed deprecated APIs:
197 * `getIdentifierText`, `isJsxFramgment`, `ImportOptions`
198 * deprected overloads of `isModifierFlagSet`, `findImports` and `getControlFlowEnd`
199 * control flow related symbols can no longer be imported from `'tsutils/util/util'`, import directly from `'tsutils/util/control-flow'` or `'tsutils/util'`
200 * `isFunctionScopeBoundary` and `isBlockScopeBoundary` now return a enum member of `ScopeBoundary` instead of a boolean
201 * `isFunctionScopeBoundary` no longer returns a truthy value for `InterfaceDeclaration`, `TypeAliasDeclaration`
205 * added utility `isTypeScopeBoundary` returning `ScopeBoundary.Type` or `ScopeBoundary.ConditionalType`
206 * added enum `ScopeBoundarySelector` whose members can be used to determine if a declaration belongs to a given `ScopeBoundary` by using bitwise AND
210 * `collectVariableUsage` now correctly handles `infer T` nested inside function signatures or mapped types
211 * `isCompilerOptionEnabled` correctly handles `skipDefaultLibCHeck` and `suppressImplicitAnyIndexErrors`
217 * added utility `isCompilerOptionEnabled`
221 Typeguards are now split into multiple submodules for each version of TypeScript (starting with 2.8.0).
222 That means you can now import directly from `"tsutils/typeguard/2.8"` to get compatible declaraton files for TypeScript@2.8.
223 For more information please read the relevant section in [README.md](README.md).
227 * added typeguards: `isTupleType`, `isOptionalTypeNode`, `isRestTypeNode`, `isSyntheticExpression` (currently available from `"tsutils/typeguard/3.0"`)
228 * added utility `isStrictCompilerOptionEnabled`
232 Avoid crash caused by removed function in `typescript@3.0.0`.
236 Added support for TypeScript@3.0.0 nightly builds.
242 * added `getIIFE` utility
248 * `forEachComment` and `forEachTokenWithTrivia` no longer duplicate comments around missing nodes
254 * fixed crash in `hasSideEffects` with tagged template literal without substitution: ``tag`template` ``
260 * added typeguard `isLiteralTypeNode`
261 * added support for type imports (`type T = import('foo')`) to `findImports` via `ImportKind.ImportType`
267 * `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)
273 * added utilities: `isStatementInAmbientContext` and `isAmbientModuleBlock`
279 * added typeguards for typescript@2.8: `isConditionalTypeNode`, `isInferTypeNode`, `isConditionalType`, `isInstantiableType`, `isSubstitutionType`
285 * added typeguard `isForInOrOfStatement`
289 * correctly handle comments in generic JSX elements: `<MyComponent<string>/*comment*/></MyComponent>`
290 * fixed a bug with false positive trailing comments at the end of JSX self closing element: `<div><br/>/*no comment*/</div>`
296 * `collectVariableUsage`: handle ConditionalTypes and `infer T`, which will be introduced in TypeScript@2.8.0 and are already available in nightly builds
297 * `isLiteralType` no longer returns true for `ts.TypeFlags.BooleanLiteral` as this is not a `ts.LiteralType`
304 * handle loops that might not even run a single iteration
305 * handle constant boolean conditions in loops and if
311 * added `isFalsyType` utility
317 * fixed compile error with `typescript@2.8.0-dev`
323 * `isReassignmentTarget`: handle type assertions and non-null assertion
329 * `forEachDeclaredVariable` uses a more precise type for the callback parameter to make it useable again with typescript@2.7.1
333 * added `isUniqueESSymbolType` typeguard
339 * added `isThenableType` utility
340 * added `unionTypeParts` utility
346 * `forEachComment`, `getCommentAtPosition` and `isPositionInComment`: skip shebang (`#! something`) to not miss following comments at the start of the file
352 * added `WrappedAst` interface that models the type of a wrapped SourceFile more accurate
353 * added `getWrappedNodeAtPosition` utiltiy that takes a `NodeWrap` and returns the most deeply nested NodeWrap that contains the given position
359 * `getControlFlowEnd` accepts BlockLike as argument
363 * `getControlFlowEnd` and `endsControlFlow`: correctly handle nested LabeledStatements
364 * `endsControlFlow` removed erroneous special case when an IterationStatement is passed as argument whose parent is a LabeledStatement.
365 * if you want labels of an IterationStatement (or SwitchStatement) to be handled, you need to pass the LabeledStatement as argument.
366 * :warning: this fix may change the returned value if you relied on the buggy behavior
370 * deprecated overload of `getControlFlowEnd` that contains the `label` parameter. This parameter is no longer used and should no longer be passed to the function.
376 * `getControlFlowEnd` and `endsControlFlow` (#22)
377 * ThrowStatements inside `try` are filtered out if there is a `catch` clause
378 * TryStatements with `catch` only end control flow if `try` AND `catch` definitely end control flow
384 * added `kind` property to `NodeWrap`
385 * added `getControlFlowEnd` to public API
391 * added `isDecorator` and `isCallLikeExpression` typeguards
397 * added `convertAst` utility to produce a flattened and wrapped version of the AST
403 * added `isDeleteExpression`
404 * added `getLineBreakStyle`
410 * fixed name of `isJsxFragment`
416 * added support for `JsxFragment` introduced in typescript@2.6.2
417 * added corresponding typeguard functions
424 * added missing logic for labeled statement, iteration statements and try-catch
425 * added missing logic for `break` and `continue` with labels
426 * take all jump statements into account, not only the last statement
427 * `isValidIdentifier` and `isValidNumericLiteral` handle irregular whitespace
428 * `findImports` searches in ambient modules inside regular `.ts` files (not only `.d.ts`)
429 * `canHaveJsDoc` is now a typeguard
435 * `forEachTokenWithTrivia`
436 * handles irregular whitespace and no longer visits some tokens twice
437 * correctly calculates the range of JsxText
443 * deprecated `ImportOptions` if favor of the new `ImportKind` enum
449 * `parseJsDocOfNode`: set correct `pos`, `end` and `parent` properties. Also affects `getJsDoc` of `EndOfFileToken`
455 * `collectVariableUsage`: correctly consider catch binding as block scoped declaration inside catch block
461 * `getJsDoc` now correctly returns JsDoc for `EndOfFileToken`
465 * added utility `parseJsDocOfNode`
471 * added utility `findImports` to find all kinds of imports in a source file
477 * added typeguard `isMappedTypeNode`
478 * added utilities `canHaveJsDoc` and `getJsDoc`
484 * `collectVariableUsage`: handle global augmentation like other module augmentations
490 * Support `typescript@2.5.1` with optional catch binding
491 * `collectVariableUsage` fixed a bug where method decorator had method's parameters in scope
495 * Compatibility with the latest typescript nightly
496 * Added `getIdentifierText` to unescape identifiers across typescript versions
502 * `isReassignmentTarget` don't return `true` for right side of assignment
508 * Added `isReassignmentTarget` utility
514 * `getDeclarationDomain` now returns `undefined` for Parameter in IndexSignature
515 * `collectVariableUsage` ignores Parameter in IndexSignature
521 * `collectVariableUsage`:
522 * don't merge imports with global declarations
523 * treat everything in a declaration file as exported if there is no explicit `export {};`
524 * `isExpressionValueUsed`: handle destructuring in `for...of`
528 * Added `getModifier` utility
529 * Added `DeclarationDomain.Import` to distinguish imports from other declarations
535 * `collectVariableUsage` ignore jump labels as in `break label;`
541 * `isFunctionWithBody` handles constructor overload correctly.
545 * Implemented `isExpressionValueUsed` to check whether the result of an expression is actually used.
546 * Implemented `getDeclarationDomain` to determine if a given declaration introduces a new symbol in the value or type domain.
548 **`collectVariableUses` is now usable**
550 * no longer ignores signatures and its parameters
551 * don't merge declarations and uses across domains
552 * no longer marks exceptions in catch clause or parameter properties as exported
553 * fixed exports of namespaces
554 * fixed scoping of ClassExpression name
555 * correcly handle ambient namespaces and module augmentations
556 * fixed how `: typeof foo` is handled for parameters and function return type
557 * **still WIP**: `export {Foo as Bar}` inside ambient namespaces and modules
563 * `getLineRanges`: `contentLength` now contains the correct line length when there are multiple consecutive line break characters
564 * `getTokenAtPosition`: don't match tokens that end at the specified position (because that's already outside of their range)
565 * deprecated the misnamed `isModfierFlagSet`, use the new `isModifierFlagSet` instead
569 * Added typeguard: `isJsDoc`
570 * Added experimental scope and usage analysis (`getUsageDomain` and `collectVariableUsage`)
576 * `forEachComment` no longer omits some comments when callback returns a truthy value
577 * `isPositionInComment` fixed false positive inside JSXText
581 * Added utility: `getCommentAtPosition`
587 * Fixed bit value of `SideEffectOptions.JsxElement` to be a power of 2
591 * Added utilities: `getTokenAtPosition` and `isPositionInComment`
597 * Added typeguard `isExpression`
598 * Added utilities: `hasSideEffects`, `getDeclarationOfBindingElement`
602 **Breaking Changes:**
604 * Dropped compatibility with `typescript@<2.1.0`
605 * Removed misnamed `isNumericliteral`, use `isNumericLiteral` instead (notice the uppercase L)
606 * Removed `isEnumLiteralType` which will cause compile errors with typescript@2.4.0
607 * Refactored directory structure: all imports that referenced subdirectories (e.g. `require('tsutils/src/typeguard')` will be broken
611 * New directory structure allows imports of typeguards or utils independently, e.g. (`require('tsutils/typeguard')`)
617 * `isObjectFlagSet` now uses the correct `objectFlags` property
623 * `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`
627 * Added typeguards for types
628 * Added utilities for flag checking: `isNodeFlagSet`, `isTypeFlagSet`, `isSymbolFlagSet`,`isObjectFlagSet`, `isModifierFlagSet`
634 * Support peer dependency of typescript nightlies of 2.4.0
635 * Added typeguards: `isJsxAttributes`, `isIntersectionTypeNode`, `isTypeOperatorNode`, `isTypePredicateNode`, `isTypeQueryNode`, `isUnionTypeNode`
641 * `isFunctionScopeBoundary` now handles Interfaces, TypeAliases, FunctionSignatures, etc
645 * Added utilities: `isThisParameter`, `isSameLine` and `isFunctionWithBody`
651 * Add `isValidPropertyAccess`, `isValidNumericLiteral` and `isValidPropertyName`
657 * Add `isValidIdentifier`
663 * Add `contentLength` property to the result of `getLineRanges`
669 * `canHaveLeadingTrivia`:
670 * Fix property access on undefined parent reference
671 * Fixes: [palantir/tslint#2330](https://github.com/palantir/tslint/issues/2330)
672 * `hasOwnThisReference`: now includes accessors on object literals
677 * isTypeParameterDeclaration
684 * `hasOwnThisReference`:
685 * exclude overload signatures of function declarations
686 * add method declarations on object literals
692 * Fix name of `isNumericLiteral`
700 * isExpressionWithTypeArguments
703 * isJsDocKind, isTypeNodeKind
704 * Allow typescript@next in peerDependencies
710 * Fix isBlockScopeBoundary: Remove WithStatement, IfStatment, DoStatement and WhileStatement because they are no scope boundary whitout a block.
714 * Added more typeguards:
715 * isAssertionExpression
718 * isJsxOpeningLikeElement
719 * isNonNullExpression
722 * getNextToken, getPreviousToken
723 * hasOwnThisReference
730 * Initial implementation of typeguards
733 * isNodeKind, isAssignmentKind
734 * hasModifier, isParameterProperty, hasAccessModifier
735 * getPreviousStatement, getNextStatement
737 * forEachDestructuringIdentifier, forEachDeclaredVariable
738 * getVariableDeclarationKind, isBlockScopedVariableDeclarationList, isBlockScopedVariableDeclaration
739 * isScopeBoundary, isFunctionScopeBoundary, isBlockScopeBoundary
740 * forEachToken, forEachTokenWithTrivia, forEachComment