MCPcopy Index your code
hub / github.com/TypeStrong/ts-node / getEmitExtension

Function getEmitExtension

src/index.ts:881–901  ·  view source on GitHub ↗

* Get the extension for a transpiled file. * [MUST_UPDATE_FOR_NEW_FILE_EXTENSIONS]

(path: string)

Source from the content-addressed store, hash-verified

879 * [MUST_UPDATE_FOR_NEW_FILE_EXTENSIONS]
880 */
881 function getEmitExtension(path: string) {
882 const lastDotIndex = path.lastIndexOf('.');
883 if (lastDotIndex >= 0) {
884 const ext = path.slice(lastDotIndex);
885 switch (ext) {
886 case '.js':
887 case '.ts':
888 return '.js';
889 case '.jsx':
890 case '.tsx':
891 return jsxEmitPreserve ? '.jsx' : '.js';
892 case '.mjs':
893 case '.mts':
894 return '.mjs';
895 case '.cjs':
896 case '.cts':
897 return '.cjs';
898 }
899 }
900 return '.js';
901 }
902
903 type GetOutputFunction = (code: string, fileName: string) => SourceOutput;
904 /**

Callers 1

updateOutputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…