demo/typescript.js
function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) {
                if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) {
                    return false;
                }
                var current = node;
                while (current) {
                    if (current.kind === 248 /* SourceFile */) {
                        return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0);
                    }
                    else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) {
                        return false;
                    }
                    else {
                        current = current.parent;
                    }
                }
            }
function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) {
                if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) {
                    return false;
                }
                var current = node;
                while (current) {
                    if (current.kind === 248 /* SourceFile */) {
                        return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0);
                    }
                    else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) {
                        return false;
                    }
                    else {
                        current = current.parent;
                    }
                }
            }
function isSourceFileLevelDeclarationInSystemJsModule ( node , isExported ) { if ( ! node || languageVersion >= 2 /* ES6 */ || ! isCurrentFileSystemExternalModule ( ) ) { return false ; } var current = node ; while ( current ) { if ( current . kind === 248 /* SourceFile */ ) { return ! isExported || ( ( ts . getCombinedNodeFlags ( node ) & 1 /* Export */ ) !== 0 ) ; } else if ( ts . isFunctionLike ( current ) || current . kind === 219 /* ModuleBlock */ ) { return false ; } else { current = current . parent ; } } }
/*
Checks if given node is a source file level declaration (not nested in module/function).
If 'isExported' is true - then declaration must also be exported.
This function is used in two cases:
- check if node is a exported source file level value to determine
if we should also export the value after its it changed
- check if node is a source level declaration to emit it differently,
i.e non-exported variable statement 'var x = 1' is hoisted so
we we emit variable statement 'var' should be dropped.
/ * Checks if given node is a source file level declaration ( not nested in module / function ) . If isExported is true - then declaration must also be exported . This function is used in two cases : - check if node is a exported source file level value to determine if we should also export the value after its it changed - check if node is a source level declaration to emit it differently i . e non - exported variable statement var x = 1 is hoisted so we we emit variable statement var should be dropped .