I'm trying to create my first Typescript definition file. The subject code is 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) {}
The definition (index.d.ts) file I have so far:
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;
}
This works well enough (auto complete works in my editor), but I get 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.
What does this error mean (new to Typescript), and more importantly, how should I modify my definition to make it more correct?