After attempting to create my initial Typescript definition file, I've encountered a issue with the subject code found in filename.js (index.js):
module.exports = {
extension: extension,
basename: basename,
removeSuffix: removeSuffix,
removeSuffixWithDelimiter: removeSuffixWithDelimiter,
appendSuffix: appendSuffix,
appendSuffixWithDelimiter: appendSuffixWithDelimiter,
directoryName: directoryName
}
function extension(filename) {}
function basename(filename) {}
function removeSuffix(filename) {}
function removeSuffixWithDelimiter(delimiter, filename) {}
function appendSuffix(suffix, filename) {}
function appendSuffixWithDelimiter(suffix, delimiter, filename) {}
function directoryName(filename) {}
This is the current state of my definition file (index.d.ts):
declare module "filename.js" {
export function extension(filename: string): string;
export function basename(filename: string): string;
export function removeSuffix(filename: string): string;
export function removeSuffixWithDelimiter(delimiter: string|number, filename: string): string;
export function appendSuffix(suffix: string, filename: string): string;
export function appendSuffixWithDelimiter(suffix: string, delimiter: string|number, filename: string): string;
export function directoryName(filename: string): string;
}
Although this setup allows for auto-complete features in my editor, I am encountering a compile error:
index.ts(21,29): error TS2656: Exported external package typings file 'filename.js/index.d.ts' is not a module. Please contact the package author to update the package definition.
Being new to Typescript, I'm unsure of the meaning behind this error. Can someone provide insight on its implications and advise on any necessary adjustments to refine my definition?