@@ -29,7 +29,6 @@ import {
29
29
CompilerOptions ,
30
30
ConditionalExpression ,
31
31
contains ,
32
- ContextFlags ,
33
32
createPrinterWithRemoveCommentsOmitTrailingSemicolon ,
34
33
createRange ,
35
34
createScanner ,
@@ -59,7 +58,6 @@ import {
59
58
EndOfFileToken ,
60
59
endsWith ,
61
60
ensureScriptKind ,
62
- EqualityOperator ,
63
61
escapeString ,
64
62
ExportAssignment ,
65
63
ExportDeclaration ,
@@ -88,6 +86,7 @@ import {
88
86
FunctionLikeDeclaration ,
89
87
getAssignmentDeclarationKind ,
90
88
getCombinedNodeFlagsAlwaysIncludeJSDoc ,
89
+ getContextualTypeFromParent ,
91
90
getDirectoryPath ,
92
91
getEmitModuleKind ,
93
92
getEmitScriptTarget ,
@@ -371,7 +370,6 @@ import {
371
370
VariableDeclaration ,
372
371
visitEachChild ,
373
372
VoidExpression ,
374
- walkUpParenthesizedExpressions ,
375
373
YieldExpression ,
376
374
} from "./_namespaces/ts" ;
377
375
@@ -3359,25 +3357,6 @@ export function needsParentheses(expression: Expression): boolean {
3359
3357
|| ( isAsExpression ( expression ) || isSatisfiesExpression ( expression ) ) && isObjectLiteralExpression ( expression . expression ) ;
3360
3358
}
3361
3359
3362
- /** @internal */
3363
- export function getContextualTypeFromParent ( node : Expression , checker : TypeChecker , contextFlags ?: ContextFlags ) : Type | undefined {
3364
- const parent = walkUpParenthesizedExpressions ( node . parent ) ;
3365
- switch ( parent . kind ) {
3366
- case SyntaxKind . NewExpression :
3367
- return checker . getContextualType ( parent as NewExpression , contextFlags ) ;
3368
- case SyntaxKind . BinaryExpression : {
3369
- const { left, operatorToken, right } = parent as BinaryExpression ;
3370
- return isEqualityOperatorKind ( operatorToken . kind )
3371
- ? checker . getTypeAtLocation ( node === right ? left : right )
3372
- : checker . getContextualType ( node , contextFlags ) ;
3373
- }
3374
- case SyntaxKind . CaseClause :
3375
- return getSwitchedType ( parent as CaseClause , checker ) ;
3376
- default :
3377
- return checker . getContextualType ( node , contextFlags ) ;
3378
- }
3379
- }
3380
-
3381
3360
/** @internal */
3382
3361
export function quote ( sourceFile : SourceFile , preferences : UserPreferences , text : string ) : string {
3383
3362
// Editors can pass in undefined or empty string - we want to infer the preference in those cases.
@@ -3386,19 +3365,6 @@ export function quote(sourceFile: SourceFile, preferences: UserPreferences, text
3386
3365
return quotePreference === QuotePreference . Single ? `'${ stripQuotes ( quoted ) . replace ( / ' / g, "\\'" ) . replace ( / \\ " / g, '"' ) } '` : quoted ;
3387
3366
}
3388
3367
3389
- /** @internal */
3390
- export function isEqualityOperatorKind ( kind : SyntaxKind ) : kind is EqualityOperator {
3391
- switch ( kind ) {
3392
- case SyntaxKind . EqualsEqualsEqualsToken :
3393
- case SyntaxKind . EqualsEqualsToken :
3394
- case SyntaxKind . ExclamationEqualsEqualsToken :
3395
- case SyntaxKind . ExclamationEqualsToken :
3396
- return true ;
3397
- default :
3398
- return false ;
3399
- }
3400
- }
3401
-
3402
3368
/** @internal */
3403
3369
export function isStringLiteralOrTemplate ( node : Node ) : node is StringLiteralLike | TemplateExpression | TaggedTemplateExpression {
3404
3370
switch ( node . kind ) {
@@ -3417,11 +3383,6 @@ export function hasIndexSignature(type: Type): boolean {
3417
3383
return ! ! type . getStringIndexType ( ) || ! ! type . getNumberIndexType ( ) ;
3418
3384
}
3419
3385
3420
- /** @internal */
3421
- export function getSwitchedType ( caseClause : CaseClause , checker : TypeChecker ) : Type | undefined {
3422
- return checker . getTypeAtLocation ( caseClause . parent . parent . expression ) ;
3423
- }
3424
-
3425
3386
/** @internal */
3426
3387
export const ANONYMOUS = "anonymous function" ;
3427
3388
0 commit comments