@ts-bridge/cli
Version:
Bridge the gap between ES modules and CommonJS modules with an easy-to-use alternative to `tsc`.
25 lines • 853 B
TypeScript
import typescript from 'typescript';
/**
* Get the AST for the `importDefault` helper function, i.e.:
*
* ```ts
* function importDefault(module?: any): any {
* if (module?.__esModule) {
* return module.default;
* }
*
* return module;
* }
* ```
*
* This is based on the `__importDefault` function that TypeScript generates
* when compiling ES modules to CommonJS. It is used to import the default
* export from a (CommonJS) module. This checks if the module has a `__esModule`
* property, and if so, returns `module.default`. Otherwise, it returns the
* module itself.
*
* @param functionName - The name of the function.
* @returns The AST for the `importDefault` helper function.
*/
export declare function getImportDefaultHelper(functionName: string): typescript.FunctionDeclaration;
//# sourceMappingURL=helpers.d.ts.map