see https const RESERVED_WORDS = new Set ( [ 'await' , 'break' , 'case' , 'catch' , 'class' , 'const' , 'continue' , 'debugger' , 'default' , 'delete' , 'do' , 'else' , 'enum' , 'export' , 'extends' , 'false' , 'finally' , 'for' , 'function' , 'if' , 'import' , 'in' , 'instanceof' , 'new' , 'null' , 'return' , 'super' , 'switch' , 'this' , 'throw' , 'true' , 'try' , 'typeof' , 'var' , 'void' , 'while' , 'with' , 'yield' ] ) ; internal export function createPositionalIdentifier ( identifierName ) { if ( RESERVED_WORDS . has ( identifierName ) ) { return `_${ identifierName }` ; } return identifierName ; } internal export function getUsedIdentifiers ( identifiers , sourceFile ) { const usedIdentifiers = new Set ( ) ; identifiers . forEach ( ( identifier ) => { if ( new RegExp ( `\\W${ identifier }(\\W|$)` ) . test ( sourceFile ) ) usedIdentifiers . add ( identifier ) ; } ) ; return Array . from ( usedIdentifiers ) ; } internal function createImportDeclaration ( identifiers , moduleSpecifier ) { return identifiers . length > 0 ? `import { ${ identifiers . join ( ', ' ) } } from "${ moduleSpecifier }"` : '' ; } internal export function createImportTypeDeclaration ( identifiers , moduleSpecifier ) { return identifiers . length > 0 ? `import { ${ identifiers . join ( ', ' ) } } from "${ moduleSpecifier }"` : '' ; } type ModuleSpecifier = string ; type Identifier = string ; internal export function createImportsForUsedIdentifiers ( possibleImports , sourceFile ) { return Object . entries ( possibleImports ) . map ( ( [ moduleSpecifier , identifiers ] ) => createImportDeclaration ( getUsedIdentifiers ( identifiers , sourceFile ) , moduleSpecifier ) ) . join ( '\n' ) ; }