5 * added utility `isCompilerOptionEnabled`
9 Typeguards are now split into multiple submodules for each version of TypeScript (starting with 2.8.0).
10 That means you can now import directly from `"tsutils/typeguard/2.8"` to get compatible declaraton files for TypeScript@2.8.
11 For more information please read the relevant section in [README.md](README.md).
15 * added typeguards: `isTupleType`, `isOptionalTypeNode`, `isRestTypeNode`, `isSyntheticExpression` (currently available from `"tsutils/typeguard/3.0"`)
16 * added utility `isStrictCompilerOptionEnabled`
20 Avoid crash caused by removed function in `typescript@3.0.0`.
24 Added support for TypeScript@3.0.0 nightly builds.
30 * added `getIIFE` utility
36 * `forEachComment` and `forEachTokenWithTrivia` no longer duplicate comments around missing nodes
42 * fixed crash in `hasSideEffects` with tagged template literal without substitution: ``tag`template` ``
48 * added typeguard `isLiteralTypeNode`
49 * added support for type imports (`type T = import('foo')`) to `findImports` via `ImportKind.ImportType`
55 * `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)
61 * added utilities: `isStatementInAmbientContext` and `isAmbientModuleBlock`
67 * added typeguards for typescript@2.8: `isConditionalTypeNode`, `isInferTypeNode`, `isConditionalType`, `isInstantiableType`, `isSubstitutionType`
73 * added typeguard `isForInOrOfStatement`
77 * correctly handle comments in generic JSX elements: `<MyComponent<string>/*comment*/></MyComponent>`
78 * fixed a bug with false positive trailing comments at the end of JSX self closing element: `<div><br/>/*no comment*/</div>`
84 * `collectVariableUsage`: handle ConditionalTypes and `infer T`, which will be introduced in TypeScript@2.8.0 and are already available in nightly builds
85 * `isLiteralType` no longer returns true for `ts.TypeFlags.BooleanLiteral` as this is not a `ts.LiteralType`
92 * handle loops that might not even run a single iteration
93 * handle constant boolean conditions in loops and if
99 * added `isFalsyType` utility
105 * fixed compile error with `typescript@2.8.0-dev`
111 * `isReassignmentTarget`: handle type assertions and non-null assertion
117 * `forEachDeclaredVariable` uses a more precise type for the callback parameter to make it useable again with typescript@2.7.1
121 * added `isUniqueESSymbolType` typeguard
127 * added `isThenableType` utility
128 * added `unionTypeParts` utility
134 * `forEachComment`, `getCommentAtPosition` and `isPositionInComment`: skip shebang (`#! something`) to not miss following comments at the start of the file
140 * added `WrappedAst` interface that models the type of a wrapped SourceFile more accurate
141 * added `getWrappedNodeAtPosition` utiltiy that takes a `NodeWrap` and returns the most deeply nested NodeWrap that contains the given position
147 * `getControlFlowEnd` accepts BlockLike as argument
151 * `getControlFlowEnd` and `endsControlFlow`: correctly handle nested LabeledStatements
152 * `endsControlFlow` removed erroneous special case when an IterationStatement is passed as argument whose parent is a LabeledStatement.
153 * if you want labels of an IterationStatement (or SwitchStatement) to be handled, you need to pass the LabeledStatement as argument.
154 * :warning: this fix may change the returned value if you relied on the buggy behavior
158 * deprecated overload of `getControlFlowEnd` that contains the `label` parameter. This parameter is no longer used and should no longer be passed to the function.
164 * `getControlFlowEnd` and `endsControlFlow` (#22)
165 * ThrowStatements inside `try` are filtered out if there is a `catch` clause
166 * TryStatements with `catch` only end control flow if `try` AND `catch` definitely end control flow
172 * added `kind` property to `NodeWrap`
173 * added `getControlFlowEnd` to public API
179 * added `isDecorator` and `isCallLikeExpression` typeguards
185 * added `convertAst` utility to produce a flattened and wrapped version of the AST
191 * added `isDeleteExpression`
192 * added `getLineBreakStyle`
198 * fixed name of `isJsxFragment`
204 * added support for `JsxFragment` introduced in typescript@2.6.2
205 * added corresponding typeguard functions
212 * added missing logic for labeled statement, iteration statements and try-catch
213 * added missing logic for `break` and `continue` with labels
214 * take all jump statements into account, not only the last statement
215 * `isValidIdentifier` and `isValidNumericLiteral` handle irregular whitespace
216 * `findImports` searches in ambient modules inside regular `.ts` files (not only `.d.ts`)
217 * `canHaveJsDoc` is now a typeguard
223 * `forEachTokenWithTrivia`
224 * handles irregular whitespace and no longer visits some tokens twice
225 * correctly calculates the range of JsxText
231 * deprecated `ImportOptions` if favor of the new `ImportKind` enum
237 * `parseJsDocOfNode`: set correct `pos`, `end` and `parent` properties. Also affects `getJsDoc` of `EndOfFileToken`
243 * `collectVariableUsage`: correctly consider catch binding as block scoped declaration inside catch block
249 * `getJsDoc` now correctly returns JsDoc for `EndOfFileToken`
253 * added utility `parseJsDocOfNode`
259 * added utility `findImports` to find all kinds of imports in a source file
265 * added typeguard `isMappedTypeNode`
266 * added utilities `canHaveJsDoc` and `getJsDoc`
272 * `collectVariableUsage`: handle global augmentation like other module augmentations
278 * Support `typescript@2.5.1` with optional catch binding
279 * `collectVariableUsage` fixed a bug where method decorator had method's parameters in scope
283 * Compatibility with the latest typescript nightly
284 * Added `getIdentifierText` to unescape identifiers across typescript versions
290 * `isReassignmentTarget` don't return `true` for right side of assignment
296 * Added `isReassignmentTarget` utility
302 * `getDeclarationDomain` now returns `undefined` for Parameter in IndexSignature
303 * `collectVariableUsage` ignores Parameter in IndexSignature
309 * `collectVariableUsage`:
310 * don't merge imports with global declarations
311 * treat everything in a declaration file as exported if there is no explicit `export {};`
312 * `isExpressionValueUsed`: handle destructuring in `for...of`
316 * Added `getModifier` utility
317 * Added `DeclarationDomain.Import` to distinguish imports from other declarations
323 * `collectVariableUsage` ignore jump labels as in `break label;`
329 * `isFunctionWithBody` handles constructor overload correctly.
333 * Implemented `isExpressionValueUsed` to check whether the result of an expression is actually used.
334 * Implemented `getDeclarationDomain` to determine if a given declaration introduces a new symbol in the value or type domain.
336 **`collectVariableUses` is now usable**
338 * no longer ignores signatures and its parameters
339 * don't merge declarations and uses across domains
340 * no longer marks exceptions in catch clause or parameter properties as exported
341 * fixed exports of namespaces
342 * fixed scoping of ClassExpression name
343 * correcly handle ambient namespaces and module augmentations
344 * fixed how `: typeof foo` is handled for parameters and function return type
345 * **still WIP**: `export {Foo as Bar}` inside ambient namespaces and modules
351 * `getLineRanges`: `contentLength` now contains the correct line length when there are multiple consecutive line break characters
352 * `getTokenAtPosition`: don't match tokens that end at the specified position (because that's already outside of their range)
353 * deprecated the misnamed `isModfierFlagSet`, use the new `isModifierFlagSet` instead
357 * Added typeguard: `isJsDoc`
358 * Added experimental scope and usage analysis (`getUsageDomain` and `collectVariableUsage`)
364 * `forEachComment` no longer omits some comments when callback returns a truthy value
365 * `isPositionInComment` fixed false positive inside JSXText
369 * Added utility: `getCommentAtPosition`
375 * Fixed bit value of `SideEffectOptions.JsxElement` to be a power of 2
379 * Added utilities: `getTokenAtPosition` and `isPositionInComment`
385 * Added typeguard `isExpression`
386 * Added utilities: `hasSideEffects`, `getDeclarationOfBindingElement`
390 **Breaking Changes:**
392 * Dropped compatibility with `typescript@<2.1.0`
393 * Removed misnamed `isNumericliteral`, use `isNumericLiteral` instead (notice the uppercase L)
394 * Removed `isEnumLiteralType` which will cause compile errors with typescript@2.4.0
395 * Refactored directory structure: all imports that referenced subdirectories (e.g. `require('tsutils/src/typeguard')` will be broken
399 * New directory structure allows imports of typeguards or utils independently, e.g. (`require('tsutils/typeguard')`)
405 * `isObjectFlagSet` now uses the correct `objectFlags` property
411 * `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`
415 * Added typeguards for types
416 * Added utilities for flag checking: `isNodeFlagSet`, `isTypeFlagSet`, `isSymbolFlagSet`,`isObjectFlagSet`, `isModifierFlagSet`
422 * Support peer dependency of typescript nightlies of 2.4.0
423 * Added typeguards: `isJsxAttributes`, `isIntersectionTypeNode`, `isTypeOperatorNode`, `isTypePredicateNode`, `isTypeQueryNode`, `isUnionTypeNode`
429 * `isFunctionScopeBoundary` now handles Interfaces, TypeAliases, FunctionSignatures, etc
433 * Added utilities: `isThisParameter`, `isSameLine` and `isFunctionWithBody`
439 * Add `isValidPropertyAccess`, `isValidNumericLiteral` and `isValidPropertyName`
445 * Add `isValidIdentifier`
451 * Add `contentLength` property to the result of `getLineRanges`
457 * `canHaveLeadingTrivia`:
458 * Fix property access on undefined parent reference
459 * Fixes: [palantir/tslint#2330](https://github.com/palantir/tslint/issues/2330)
460 * `hasOwnThisReference`: now includes accessors on object literals
465 * isTypeParameterDeclaration
472 * `hasOwnThisReference`:
473 * exclude overload signatures of function declarations
474 * add method declarations on object literals
480 * Fix name of `isNumericLiteral`
488 * isExpressionWithTypeArguments
491 * isJsDocKind, isTypeNodeKind
492 * Allow typescript@next in peerDependencies
498 * Fix isBlockScopeBoundary: Remove WithStatement, IfStatment, DoStatement and WhileStatement because they are no scope boundary whitout a block.
502 * Added more typeguards:
503 * isAssertionExpression
506 * isJsxOpeningLikeElement
507 * isNonNullExpression
510 * getNextToken, getPreviousToken
511 * hasOwnThisReference
518 * Initial implementation of typeguards
521 * isNodeKind, isAssignmentKind
522 * hasModifier, isParameterProperty, hasAccessModifier
523 * getPreviousStatement, getNextStatement
525 * forEachDestructuringIdentifier, forEachDeclaredVariable
526 * getVariableDeclarationKind, isBlockScopedVariableDeclarationList, isBlockScopedVariableDeclaration
527 * isScopeBoundary, isFunctionScopeBoundary, isBlockScopeBoundary
528 * forEachToken, forEachTokenWithTrivia, forEachComment