requireFileExtension()function
requireFileExtension(file: string, caller: AnyCaller = requireFileExtension): string
| Param | Type | |
|---|---|---|
file | string | The filename to read the extension from. required |
caller | AnyCaller | 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"