@@ -27,20 +27,6 @@ namespace ts {
2727 return undefined ;
2828 }
2929
30- export function findDeclaration < T extends Declaration > ( symbol : Symbol , predicate : ( node : Declaration ) => node is T ) : T | undefined ;
31- export function findDeclaration ( symbol : Symbol , predicate : ( node : Declaration ) => boolean ) : Declaration | undefined ;
32- export function findDeclaration ( symbol : Symbol , predicate : ( node : Declaration ) => boolean ) : Declaration | undefined {
33- const declarations = symbol . declarations ;
34- if ( declarations ) {
35- for ( const declaration of declarations ) {
36- if ( predicate ( declaration ) ) {
37- return declaration ;
38- }
39- }
40- }
41- return undefined ;
42- }
43-
4430 export interface StringSymbolWriter extends SymbolWriter {
4531 string ( ) : string ;
4632 }
@@ -112,19 +98,16 @@ namespace ts {
11298 sourceFile . resolvedTypeReferenceDirectiveNames . set ( typeReferenceDirectiveName , resolvedTypeReferenceDirective ) ;
11399 }
114100
115- /* @internal */
116101 export function moduleResolutionIsEqualTo ( oldResolution : ResolvedModuleFull , newResolution : ResolvedModuleFull ) : boolean {
117102 return oldResolution . isExternalLibraryImport === newResolution . isExternalLibraryImport &&
118103 oldResolution . extension === newResolution . extension &&
119104 oldResolution . resolvedFileName === newResolution . resolvedFileName ;
120105 }
121106
122- /* @internal */
123107 export function typeDirectiveIsEqualTo ( oldResolution : ResolvedTypeReferenceDirective , newResolution : ResolvedTypeReferenceDirective ) : boolean {
124108 return oldResolution . resolvedFileName === newResolution . resolvedFileName && oldResolution . primary === newResolution . primary ;
125109 }
126110
127- /* @internal */
128111 export function hasChangesInResolutions < T > (
129112 names : ReadonlyArray < string > ,
130113 newResolutions : ReadonlyArray < T > ,
@@ -203,14 +186,6 @@ namespace ts {
203186 return `${ file . fileName } (${ loc . line + 1 } ,${ loc . character + 1 } )` ;
204187 }
205188
206- export function getStartPosOfNode ( node : Node ) : number {
207- return node . pos ;
208- }
209-
210- export function isDefined ( value : any ) : boolean {
211- return value !== undefined ;
212- }
213-
214189 export function getEndLinePosition ( line : number , sourceFile : SourceFileLike ) : number {
215190 Debug . assert ( line >= 0 ) ;
216191 const lineStarts = getLineStarts ( sourceFile ) ;
@@ -463,7 +438,7 @@ namespace ts {
463438 return isExternalModule ( node ) || compilerOptions . isolatedModules ;
464439 }
465440
466- export function isBlockScope ( node : Node , parentNode : Node ) {
441+ function isBlockScope ( node : Node , parentNode : Node ) {
467442 switch ( node . kind ) {
468443 case SyntaxKind . SourceFile :
469444 case SyntaxKind . CaseBlock :
@@ -664,29 +639,25 @@ namespace ts {
664639 return getLeadingCommentRanges ( sourceFileOfNode . text , node . pos ) ;
665640 }
666641
667- export function getLeadingCommentRangesOfNodeFromText ( node : Node , text : string ) {
668- return getLeadingCommentRanges ( text , node . pos ) ;
669- }
670-
671642 export function getJSDocCommentRanges ( node : Node , text : string ) {
672643 const commentRanges = ( node . kind === SyntaxKind . Parameter ||
673644 node . kind === SyntaxKind . TypeParameter ||
674645 node . kind === SyntaxKind . FunctionExpression ||
675646 node . kind === SyntaxKind . ArrowFunction ||
676647 node . kind === SyntaxKind . ParenthesizedExpression ) ?
677648 concatenate ( getTrailingCommentRanges ( text , node . pos ) , getLeadingCommentRanges ( text , node . pos ) ) :
678- getLeadingCommentRangesOfNodeFromText ( node , text ) ;
649+ getLeadingCommentRanges ( text , node . pos ) ;
679650 // True if the comment starts with '/**' but not if it is '/**/'
680651 return filter ( commentRanges , comment =>
681652 text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk &&
682653 text . charCodeAt ( comment . pos + 2 ) === CharacterCodes . asterisk &&
683654 text . charCodeAt ( comment . pos + 3 ) !== CharacterCodes . slash ) ;
684655 }
685656
686- export let fullTripleSlashReferencePathRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
687- export let fullTripleSlashReferenceTypeReferenceDirectiveRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + t y p e s \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
688- export let fullTripleSlashAMDReferencePathRegEx = / ^ ( \/ \/ \/ \s * < a m d - d e p e n d e n c y \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
689- export let defaultLibReferenceRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + n o - d e f a u l t - l i b \s * = \s * ) ( ' | " ) ( .+ ?) \2\s * \/ > / ;
657+ export const fullTripleSlashReferencePathRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
658+ const fullTripleSlashReferenceTypeReferenceDirectiveRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + t y p e s \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
659+ export const fullTripleSlashAMDReferencePathRegEx = / ^ ( \/ \/ \/ \s * < a m d - d e p e n d e n c y \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
660+ const defaultLibReferenceRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + n o - d e f a u l t - l i b \s * = \s * ) ( ' | " ) ( .+ ?) \2\s * \/ > / ;
690661
691662 export function isPartOfTypeNode ( node : Node ) : boolean {
692663 if ( SyntaxKind . FirstTypeNode <= node . kind && node . kind <= SyntaxKind . LastTypeNode ) {
@@ -2095,10 +2066,6 @@ namespace ts {
20952066 return getParseTreeNode ( sourceFile , isSourceFile ) || sourceFile ;
20962067 }
20972068
2098- export function getOriginalSourceFiles ( sourceFiles : ReadonlyArray < SourceFile > ) {
2099- return sameMap ( sourceFiles , getOriginalSourceFile ) ;
2100- }
2101-
21022069 export const enum Associativity {
21032070 Left ,
21042071 Right
@@ -3090,24 +3057,6 @@ namespace ts {
30903057 return false ;
30913058 }
30923059
3093- // Returns false if this heritage clause element's expression contains something unsupported
3094- // (i.e. not a name or dotted name).
3095- export function isSupportedExpressionWithTypeArguments ( node : ExpressionWithTypeArguments ) : boolean {
3096- return isSupportedExpressionWithTypeArgumentsRest ( node . expression ) ;
3097- }
3098-
3099- function isSupportedExpressionWithTypeArgumentsRest ( node : Expression ) : boolean {
3100- if ( node . kind === SyntaxKind . Identifier ) {
3101- return true ;
3102- }
3103- else if ( isPropertyAccessExpression ( node ) ) {
3104- return isSupportedExpressionWithTypeArgumentsRest ( node . expression ) ;
3105- }
3106- else {
3107- return false ;
3108- }
3109- }
3110-
31113060 export function isExpressionWithTypeArgumentsInClassExtendsClause ( node : Node ) : boolean {
31123061 return tryGetClassExtendingExpressionWithTypeArguments ( node ) !== undefined ;
31133062 }
@@ -3244,81 +3193,6 @@ namespace ts {
32443193 return carriageReturnLineFeed ;
32453194 }
32463195
3247- /**
3248- * Tests whether a node and its subtree is simple enough to have its position
3249- * information ignored when emitting source maps in a destructuring assignment.
3250- *
3251- * @param node The expression to test.
3252- */
3253- export function isSimpleExpression ( node : Expression ) : boolean {
3254- return isSimpleExpressionWorker ( node , 0 ) ;
3255- }
3256-
3257- function isSimpleExpressionWorker ( node : Expression , depth : number ) : boolean {
3258- if ( depth <= 5 ) {
3259- const kind = node . kind ;
3260- if ( kind === SyntaxKind . StringLiteral
3261- || kind === SyntaxKind . NumericLiteral
3262- || kind === SyntaxKind . RegularExpressionLiteral
3263- || kind === SyntaxKind . NoSubstitutionTemplateLiteral
3264- || kind === SyntaxKind . Identifier
3265- || kind === SyntaxKind . ThisKeyword
3266- || kind === SyntaxKind . SuperKeyword
3267- || kind === SyntaxKind . TrueKeyword
3268- || kind === SyntaxKind . FalseKeyword
3269- || kind === SyntaxKind . NullKeyword ) {
3270- return true ;
3271- }
3272- else if ( kind === SyntaxKind . PropertyAccessExpression ) {
3273- return isSimpleExpressionWorker ( ( < PropertyAccessExpression > node ) . expression , depth + 1 ) ;
3274- }
3275- else if ( kind === SyntaxKind . ElementAccessExpression ) {
3276- return isSimpleExpressionWorker ( ( < ElementAccessExpression > node ) . expression , depth + 1 )
3277- && isSimpleExpressionWorker ( ( < ElementAccessExpression > node ) . argumentExpression , depth + 1 ) ;
3278- }
3279- else if ( kind === SyntaxKind . PrefixUnaryExpression
3280- || kind === SyntaxKind . PostfixUnaryExpression ) {
3281- return isSimpleExpressionWorker ( ( < PrefixUnaryExpression | PostfixUnaryExpression > node ) . operand , depth + 1 ) ;
3282- }
3283- else if ( kind === SyntaxKind . BinaryExpression ) {
3284- return ( < BinaryExpression > node ) . operatorToken . kind !== SyntaxKind . AsteriskAsteriskToken
3285- && isSimpleExpressionWorker ( ( < BinaryExpression > node ) . left , depth + 1 )
3286- && isSimpleExpressionWorker ( ( < BinaryExpression > node ) . right , depth + 1 ) ;
3287- }
3288- else if ( kind === SyntaxKind . ConditionalExpression ) {
3289- return isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . condition , depth + 1 )
3290- && isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . whenTrue , depth + 1 )
3291- && isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . whenFalse , depth + 1 ) ;
3292- }
3293- else if ( kind === SyntaxKind . VoidExpression
3294- || kind === SyntaxKind . TypeOfExpression
3295- || kind === SyntaxKind . DeleteExpression ) {
3296- return isSimpleExpressionWorker ( ( < VoidExpression | TypeOfExpression | DeleteExpression > node ) . expression , depth + 1 ) ;
3297- }
3298- else if ( kind === SyntaxKind . ArrayLiteralExpression ) {
3299- return ( < ArrayLiteralExpression > node ) . elements . length === 0 ;
3300- }
3301- else if ( kind === SyntaxKind . ObjectLiteralExpression ) {
3302- return ( < ObjectLiteralExpression > node ) . properties . length === 0 ;
3303- }
3304- else if ( kind === SyntaxKind . CallExpression ) {
3305- if ( ! isSimpleExpressionWorker ( ( < CallExpression > node ) . expression , depth + 1 ) ) {
3306- return false ;
3307- }
3308-
3309- for ( const argument of ( < CallExpression > node ) . arguments ) {
3310- if ( ! isSimpleExpressionWorker ( argument , depth + 1 ) ) {
3311- return false ;
3312- }
3313- }
3314-
3315- return true ;
3316- }
3317- }
3318-
3319- return false ;
3320- }
3321-
33223196 /**
33233197 * Formats an enum value as a string for debugging and debug assertions.
33243198 */
@@ -3391,24 +3265,6 @@ namespace ts {
33913265 return formatEnum ( flags , ( < any > ts ) . ObjectFlags , /*isFlags*/ true ) ;
33923266 }
33933267
3394- export function getRangePos ( range : TextRange | undefined ) {
3395- return range ? range . pos : - 1 ;
3396- }
3397-
3398- export function getRangeEnd ( range : TextRange | undefined ) {
3399- return range ? range . end : - 1 ;
3400- }
3401-
3402- /**
3403- * Increases (or decreases) a position by the provided amount.
3404- *
3405- * @param pos The position.
3406- * @param value The delta.
3407- */
3408- export function movePos ( pos : number , value : number ) {
3409- return positionIsSynthesized ( pos ) ? - 1 : pos + value ;
3410- }
3411-
34123268 /**
34133269 * Creates a new TextRange from the provided pos and end.
34143270 *
@@ -3466,26 +3322,6 @@ namespace ts {
34663322 return range . pos === range . end ;
34673323 }
34683324
3469- /**
3470- * Creates a new TextRange from a provided range with its end position collapsed to its
3471- * start position.
3472- *
3473- * @param range A TextRange.
3474- */
3475- export function collapseRangeToStart ( range : TextRange ) : TextRange {
3476- return isCollapsedRange ( range ) ? range : moveRangeEnd ( range , range . pos ) ;
3477- }
3478-
3479- /**
3480- * Creates a new TextRange from a provided range with its start position collapsed to its
3481- * end position.
3482- *
3483- * @param range A TextRange.
3484- */
3485- export function collapseRangeToEnd ( range : TextRange ) : TextRange {
3486- return isCollapsedRange ( range ) ? range : moveRangePos ( range , range . end ) ;
3487- }
3488-
34893325 /**
34903326 * Creates a new TextRange for a token at the provides start position.
34913327 *
@@ -3549,31 +3385,6 @@ namespace ts {
35493385 return node . initializer !== undefined ;
35503386 }
35513387
3552- /**
3553- * Gets a value indicating whether a node is merged with a class declaration in the same scope.
3554- */
3555- export function isMergedWithClass ( node : Node ) {
3556- if ( node . symbol ) {
3557- for ( const declaration of node . symbol . declarations ) {
3558- if ( declaration . kind === SyntaxKind . ClassDeclaration && declaration !== node ) {
3559- return true ;
3560- }
3561- }
3562- }
3563-
3564- return false ;
3565- }
3566-
3567- /**
3568- * Gets a value indicating whether a node is the first declaration of its kind.
3569- *
3570- * @param node A Declaration node.
3571- * @param kind The SyntaxKind to find among related declarations.
3572- */
3573- export function isFirstDeclarationOfKind ( node : Node , kind : SyntaxKind ) {
3574- return node . symbol && getDeclarationOfKind ( node . symbol , kind ) === node ;
3575- }
3576-
35773388 export function isWatchSet ( options : CompilerOptions ) {
35783389 // Firefox has Object.prototype.watch
35793390 return options . watch && options . hasOwnProperty ( "watch" ) ;
0 commit comments