@@ -2595,16 +2595,6 @@ namespace ts {
25952595 return node ;
25962596 }
25972597
2598- export function skipPartiallyEmittedExpressions ( node : Expression ) : Expression ;
2599- export function skipPartiallyEmittedExpressions ( node : Node ) : Node ;
2600- export function skipPartiallyEmittedExpressions ( node : Node ) {
2601- while ( node . kind === SyntaxKind . PartiallyEmittedExpression ) {
2602- node = ( < PartiallyEmittedExpression > node ) . expression ;
2603- }
2604-
2605- return node ;
2606- }
2607-
26082598 export function startOnNewLine < T extends Node > ( node : T ) : T {
26092599 node . startsOnNewLine = true ;
26102600 return node ;
@@ -3264,165 +3254,4 @@ namespace ts {
32643254 Debug . assertNode ( node , isExpression ) ;
32653255 return < Expression > node ;
32663256 }
3267-
3268- export interface ExternalModuleInfo {
3269- externalImports : ( ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration ) [ ] ; // imports of other external modules
3270- externalHelpersImportDeclaration : ImportDeclaration | undefined ; // import of external helpers
3271- exportSpecifiers : Map < ExportSpecifier [ ] > ; // export specifiers by name
3272- exportedBindings : Map < Identifier [ ] > ; // exported names of local declarations
3273- exportedNames : Identifier [ ] ; // all exported names local to module
3274- exportEquals : ExportAssignment | undefined ; // an export= declaration if one was present
3275- hasExportStarsToExportValues : boolean ; // whether this module contains export*
3276- }
3277-
3278- export function collectExternalModuleInfo ( sourceFile : SourceFile , resolver : EmitResolver , compilerOptions : CompilerOptions ) : ExternalModuleInfo {
3279- const externalImports : ( ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration ) [ ] = [ ] ;
3280- const exportSpecifiers = createMap < ExportSpecifier [ ] > ( ) ;
3281- const exportedBindings = createMap < Identifier [ ] > ( ) ;
3282- const uniqueExports = createMap < boolean > ( ) ;
3283- let exportedNames : Identifier [ ] ;
3284- let hasExportDefault = false ;
3285- let exportEquals : ExportAssignment = undefined ;
3286- let hasExportStarsToExportValues = false ;
3287-
3288- const externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded ( sourceFile , compilerOptions ) ;
3289- const externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration (
3290- /*decorators*/ undefined ,
3291- /*modifiers*/ undefined ,
3292- createImportClause ( /*name*/ undefined , createNamespaceImport ( externalHelpersModuleName ) ) ,
3293- createLiteral ( externalHelpersModuleNameText ) ) ;
3294-
3295- if ( externalHelpersImportDeclaration ) {
3296- externalImports . push ( externalHelpersImportDeclaration ) ;
3297- }
3298-
3299- for ( const node of sourceFile . statements ) {
3300- switch ( node . kind ) {
3301- case SyntaxKind . ImportDeclaration :
3302- // import "mod"
3303- // import x from "mod"
3304- // import * as x from "mod"
3305- // import { x, y } from "mod"
3306- externalImports . push ( < ImportDeclaration > node ) ;
3307- break ;
3308-
3309- case SyntaxKind . ImportEqualsDeclaration :
3310- if ( ( < ImportEqualsDeclaration > node ) . moduleReference . kind === SyntaxKind . ExternalModuleReference ) {
3311- // import x = require("mod")
3312- externalImports . push ( < ImportEqualsDeclaration > node ) ;
3313- }
3314-
3315- break ;
3316-
3317- case SyntaxKind . ExportDeclaration :
3318- if ( ( < ExportDeclaration > node ) . moduleSpecifier ) {
3319- if ( ! ( < ExportDeclaration > node ) . exportClause ) {
3320- // export * from "mod"
3321- externalImports . push ( < ExportDeclaration > node ) ;
3322- hasExportStarsToExportValues = true ;
3323- }
3324- else {
3325- // export { x, y } from "mod"
3326- externalImports . push ( < ExportDeclaration > node ) ;
3327- }
3328- }
3329- else {
3330- // export { x, y }
3331- for ( const specifier of ( < ExportDeclaration > node ) . exportClause . elements ) {
3332- if ( ! uniqueExports [ specifier . name . text ] ) {
3333- const name = specifier . propertyName || specifier . name ;
3334- multiMapAdd ( exportSpecifiers , name . text , specifier ) ;
3335-
3336- const decl = resolver . getReferencedImportDeclaration ( name )
3337- || resolver . getReferencedValueDeclaration ( name ) ;
3338-
3339- if ( decl ) {
3340- multiMapAdd ( exportedBindings , getOriginalNodeId ( decl ) , specifier . name ) ;
3341- }
3342-
3343- uniqueExports [ specifier . name . text ] = true ;
3344- exportedNames = append ( exportedNames , specifier . name ) ;
3345- }
3346- }
3347- }
3348- break ;
3349-
3350- case SyntaxKind . ExportAssignment :
3351- if ( ( < ExportAssignment > node ) . isExportEquals && ! exportEquals ) {
3352- // export = x
3353- exportEquals = < ExportAssignment > node ;
3354- }
3355- break ;
3356-
3357- case SyntaxKind . VariableStatement :
3358- if ( hasModifier ( node , ModifierFlags . Export ) ) {
3359- for ( const decl of ( < VariableStatement > node ) . declarationList . declarations ) {
3360- exportedNames = collectExportedVariableInfo ( decl , uniqueExports , exportedNames ) ;
3361- }
3362- }
3363- break ;
3364-
3365- case SyntaxKind . FunctionDeclaration :
3366- if ( hasModifier ( node , ModifierFlags . Export ) ) {
3367- if ( hasModifier ( node , ModifierFlags . Default ) ) {
3368- // export default function() { }
3369- if ( ! hasExportDefault ) {
3370- multiMapAdd ( exportedBindings , getOriginalNodeId ( node ) , getDeclarationName ( < FunctionDeclaration > node ) ) ;
3371- hasExportDefault = true ;
3372- }
3373- }
3374- else {
3375- // export function x() { }
3376- const name = ( < FunctionDeclaration > node ) . name ;
3377- if ( ! uniqueExports [ name . text ] ) {
3378- multiMapAdd ( exportedBindings , getOriginalNodeId ( node ) , name ) ;
3379- uniqueExports [ name . text ] = true ;
3380- exportedNames = append ( exportedNames , name ) ;
3381- }
3382- }
3383- }
3384- break ;
3385-
3386- case SyntaxKind . ClassDeclaration :
3387- if ( hasModifier ( node , ModifierFlags . Export ) ) {
3388- if ( hasModifier ( node , ModifierFlags . Default ) ) {
3389- // export default class { }
3390- if ( ! hasExportDefault ) {
3391- multiMapAdd ( exportedBindings , getOriginalNodeId ( node ) , getDeclarationName ( < ClassDeclaration > node ) ) ;
3392- hasExportDefault = true ;
3393- }
3394- }
3395- else {
3396- // export class x { }
3397- const name = ( < ClassDeclaration > node ) . name ;
3398- if ( ! uniqueExports [ name . text ] ) {
3399- multiMapAdd ( exportedBindings , getOriginalNodeId ( node ) , name ) ;
3400- uniqueExports [ name . text ] = true ;
3401- exportedNames = append ( exportedNames , name ) ;
3402- }
3403- }
3404- }
3405- break ;
3406- }
3407- }
3408-
3409- return { externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues, exportedBindings, exportedNames, externalHelpersImportDeclaration } ;
3410- }
3411-
3412- function collectExportedVariableInfo ( decl : VariableDeclaration | BindingElement , uniqueExports : Map < boolean > , exportedNames : Identifier [ ] ) {
3413- if ( isBindingPattern ( decl . name ) ) {
3414- for ( const element of decl . name . elements ) {
3415- if ( ! isOmittedExpression ( element ) ) {
3416- exportedNames = collectExportedVariableInfo ( element , uniqueExports , exportedNames ) ;
3417- }
3418- }
3419- }
3420- else if ( ! isGeneratedIdentifier ( decl . name ) ) {
3421- if ( ! uniqueExports [ decl . name . text ] ) {
3422- uniqueExports [ decl . name . text ] = true ;
3423- exportedNames = append ( exportedNames , decl . name ) ;
3424- }
3425- }
3426- return exportedNames ;
3427- }
34283257}
0 commit comments