@@ -29,7 +29,6 @@ import {
2929 CompilerOptions ,
3030 ConditionalExpression ,
3131 contains ,
32- ContextFlags ,
3332 createPrinterWithRemoveCommentsOmitTrailingSemicolon ,
3433 createRange ,
3534 createScanner ,
@@ -59,7 +58,6 @@ import {
5958 EndOfFileToken ,
6059 endsWith ,
6160 ensureScriptKind ,
62- EqualityOperator ,
6361 escapeString ,
6462 ExportAssignment ,
6563 ExportDeclaration ,
@@ -88,6 +86,7 @@ import {
8886 FunctionLikeDeclaration ,
8987 getAssignmentDeclarationKind ,
9088 getCombinedNodeFlagsAlwaysIncludeJSDoc ,
89+ getContextualTypeFromParent ,
9190 getDirectoryPath ,
9291 getEmitModuleKind ,
9392 getEmitScriptTarget ,
@@ -371,7 +370,6 @@ import {
371370 VariableDeclaration ,
372371 visitEachChild ,
373372 VoidExpression ,
374- walkUpParenthesizedExpressions ,
375373 YieldExpression ,
376374} from "./_namespaces/ts" ;
377375
@@ -3359,25 +3357,6 @@ export function needsParentheses(expression: Expression): boolean {
33593357 || ( isAsExpression ( expression ) || isSatisfiesExpression ( expression ) ) && isObjectLiteralExpression ( expression . expression ) ;
33603358}
33613359
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-
33813360/** @internal */
33823361export function quote ( sourceFile : SourceFile , preferences : UserPreferences , text : string ) : string {
33833362 // 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
33863365 return quotePreference === QuotePreference . Single ? `'${ stripQuotes ( quoted ) . replace ( / ' / g, "\\'" ) . replace ( / \\ " / g, '"' ) } '` : quoted ;
33873366}
33883367
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-
34023368/** @internal */
34033369export function isStringLiteralOrTemplate ( node : Node ) : node is StringLiteralLike | TemplateExpression | TaggedTemplateExpression {
34043370 switch ( node . kind ) {
@@ -3417,11 +3383,6 @@ export function hasIndexSignature(type: Type): boolean {
34173383 return ! ! type . getStringIndexType ( ) || ! ! type . getNumberIndexType ( ) ;
34183384}
34193385
3420- /** @internal */
3421- export function getSwitchedType ( caseClause : CaseClause , checker : TypeChecker ) : Type | undefined {
3422- return checker . getTypeAtLocation ( caseClause . parent . parent . expression ) ;
3423- }
3424-
34253386/** @internal */
34263387export const ANONYMOUS = "anonymous function" ;
34273388
0 commit comments