TryGetJSExtensionForFile maps TS/JS/DTS extensions to the output JS-side extension. Returns an empty string if the extension is unsupported.
(fileName string, options *core.CompilerOptions)
| 176 | // TryGetJSExtensionForFile maps TS/JS/DTS extensions to the output JS-side extension. |
| 177 | // Returns an empty string if the extension is unsupported. |
| 178 | func TryGetJSExtensionForFile(fileName string, options *core.CompilerOptions) string { |
| 179 | ext := tspath.TryGetExtensionFromPath(fileName) |
| 180 | switch ext { |
| 181 | case tspath.ExtensionTs, tspath.ExtensionDts: |
| 182 | return tspath.ExtensionJs |
| 183 | case tspath.ExtensionTsx: |
| 184 | if options.Jsx == core.JsxEmitPreserve { |
| 185 | return tspath.ExtensionJsx |
| 186 | } |
| 187 | return tspath.ExtensionJs |
| 188 | case tspath.ExtensionJs, tspath.ExtensionJsx, tspath.ExtensionJson: |
| 189 | return ext |
| 190 | case tspath.ExtensionDmts, tspath.ExtensionMts, tspath.ExtensionMjs: |
| 191 | return tspath.ExtensionMjs |
| 192 | case tspath.ExtensionDcts, tspath.ExtensionCts, tspath.ExtensionCjs: |
| 193 | return tspath.ExtensionCjs |
| 194 | default: |
| 195 | return "" |
| 196 | } |
| 197 | } |
no test coverage detected