@@ -444,6 +444,7 @@ import {
444
444
Pattern ,
445
445
PostfixUnaryExpression ,
446
446
PrefixUnaryExpression ,
447
+ PrimitiveLiteral ,
447
448
PrinterOptions ,
448
449
PrintHandlers ,
449
450
PrivateIdentifier ,
@@ -2343,6 +2344,14 @@ export function isLet(node: Node): boolean {
2343
2344
return ( getCombinedNodeFlags ( node ) & NodeFlags . BlockScoped ) === NodeFlags . Let ;
2344
2345
}
2345
2346
2347
+ /** @internal */
2348
+ export function isVarConstLike ( node : VariableDeclaration | VariableDeclarationList ) {
2349
+ const blockScopeKind = getCombinedNodeFlags ( node ) & NodeFlags . BlockScoped ;
2350
+ return blockScopeKind === NodeFlags . Const ||
2351
+ blockScopeKind === NodeFlags . Using ||
2352
+ blockScopeKind === NodeFlags . AwaitUsing ;
2353
+ }
2354
+
2346
2355
/** @internal */
2347
2356
export function isSuperCall ( n : Node ) : n is SuperCall {
2348
2357
return n . kind === SyntaxKind . CallExpression && ( n as CallExpression ) . expression . kind === SyntaxKind . SuperKeyword ;
@@ -10639,3 +10648,37 @@ export function replaceFirstStar(s: string, replacement: string): string {
10639
10648
export function getNameFromImportAttribute ( node : ImportAttribute ) {
10640
10649
return isIdentifier ( node . name ) ? node . name . escapedText : escapeLeadingUnderscores ( node . name . text ) ;
10641
10650
}
10651
+
10652
+ /** @internal */
10653
+ export function isPrimitiveLiteralValue ( node : Expression ) : node is PrimitiveLiteral {
10654
+ Debug . type < PrimitiveLiteral > ( node ) ;
10655
+ switch ( node . kind ) {
10656
+ case SyntaxKind . TrueKeyword :
10657
+ case SyntaxKind . FalseKeyword :
10658
+ case SyntaxKind . NumericLiteral :
10659
+ case SyntaxKind . StringLiteral :
10660
+ case SyntaxKind . NoSubstitutionTemplateLiteral :
10661
+ case SyntaxKind . BigIntLiteral :
10662
+ return true ;
10663
+ case SyntaxKind . PrefixUnaryExpression :
10664
+ if ( node . operator === SyntaxKind . MinusToken ) {
10665
+ return node . operand . kind === SyntaxKind . NumericLiteral ||
10666
+ node . operand . kind === SyntaxKind . BigIntLiteral ;
10667
+ }
10668
+ if ( node . operator === SyntaxKind . PlusToken ) {
10669
+ return node . operand . kind === SyntaxKind . NumericLiteral ;
10670
+ }
10671
+ return false ;
10672
+ default :
10673
+ assertType < never > ( node ) ;
10674
+ return false ;
10675
+ }
10676
+ }
10677
+
10678
+ /** @internal */
10679
+ export function unwrapParenthesizedExpression ( o : Expression ) {
10680
+ while ( o . kind === SyntaxKind . ParenthesizedExpression ) {
10681
+ o = ( o as ParenthesizedExpression ) . expression ;
10682
+ }
10683
+ return o ;
10684
+ }
0 commit comments