requireFileExtension()function

requireFileExtension(file: string, caller: AnyCaller = requireFileExtension): string
ParamType
filestring
The filename to read the extension from. required
callerAnyCaller
Function to attribute a thrown error to (defaults to requireFileExtension). Defaults to requireFileExtension
Return
string
The extension (no leading dot).
Throws
unknown
RequiredError if the input has no extension.

Get the file extension from a file path e.g. "tsx", or throw RequiredError if the input has no extension.

Examples

requireFileExtension("component.tsx") // "tsx"