0

I am working with a pure JavaScript library without any TypeScript declarations, so I have added this (which isn't working):

declare module '@drumwork/tone' {
  declare let mod = function (str: string): string
  mod.list = (str: string) => Array<string>
  export default mod
}

My functions' implementations are basically like this:

function main(str) {
  // return some newly generated string
  return str + str
}

main.list = (str) => [...str]

export default main

Given that the implementation is pure JavaScript and is somewhat like that, how do I do a declare module in TypeScript?

The documentation says to do this, but it doesn't do what I'm describing exactly:

declare module '@drumwork/tone' {
  export default function (str: string): string
  export function list(str: string): Array<{ i: string; o: string }>
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lance
  • 75,200
  • 93
  • 289
  • 503

1 Answers1

-1

You can try this example. I explained with comments.

Then you should be able to default export your function as a module.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dudă
  • 56
  • 5