tsutils
Advanced tools
Comparing version 3.6.0 to 3.7.0
@@ -0,1 +1,8 @@ | ||
# 3.7.0 | ||
**Features:** | ||
* added `isBlockScopedDeclarationStatement` | ||
* added `isInSingleStatementContext` | ||
# 3.6.0 | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "tsutils", | ||
"version": "3.6.0", | ||
"version": "3.7.0", | ||
"description": "utilities for working with typescript's AST", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -44,2 +44,4 @@ import * as ts from 'typescript'; | ||
export declare function isBlockScopedVariableDeclaration(declaration: ts.VariableDeclaration): boolean; | ||
export declare function isBlockScopedDeclarationStatement(statement: ts.Statement): statement is ts.DeclarationStatement; | ||
export declare function isInSingleStatementContext(statement: ts.Statement): boolean; | ||
export declare enum ScopeBoundary { | ||
@@ -46,0 +48,0 @@ None = 0, |
@@ -256,2 +256,32 @@ "use strict"; | ||
exports.isBlockScopedVariableDeclaration = isBlockScopedVariableDeclaration; | ||
function isBlockScopedDeclarationStatement(statement) { | ||
switch (statement.kind) { | ||
case ts.SyntaxKind.VariableStatement: | ||
return isBlockScopedVariableDeclarationList(statement.declarationList); | ||
case ts.SyntaxKind.ClassDeclaration: | ||
case ts.SyntaxKind.EnumDeclaration: | ||
case ts.SyntaxKind.InterfaceDeclaration: | ||
case ts.SyntaxKind.TypeAliasDeclaration: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
exports.isBlockScopedDeclarationStatement = isBlockScopedDeclarationStatement; | ||
function isInSingleStatementContext(statement) { | ||
switch (statement.parent.kind) { | ||
case ts.SyntaxKind.ForStatement: | ||
case ts.SyntaxKind.ForInStatement: | ||
case ts.SyntaxKind.ForOfStatement: | ||
case ts.SyntaxKind.WhileStatement: | ||
case ts.SyntaxKind.DoStatement: | ||
case ts.SyntaxKind.IfStatement: | ||
case ts.SyntaxKind.WithStatement: | ||
case ts.SyntaxKind.LabeledStatement: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
exports.isInSingleStatementContext = isInSingleStatementContext; | ||
var ScopeBoundary; | ||
@@ -258,0 +288,0 @@ (function (ScopeBoundary) { |
287133
3455