def file for object export and types

前端 未结 2 1402
花落未央
花落未央 2021-01-20 10:04

Alright, so we have a Node module string-similarity who exports two functions like this (see: https://github.com/aceakash/string-similarity/blob/master/compare-

相关标签:
2条回答
  • 2021-01-20 10:46

    It looks like the export { ... } line is limiting the exports. (I was unaware that it is possible to do that in a declare module block!) If I delete that line, then by default everything is exported and I'm able to access the types.

    0 讨论(0)
  • 2021-01-20 10:58

    To access your methods under a common parent (e.g. similarity), you need to import them under the similarity alias:

    import * as similarity from "string-similarity"; 
    
    similarity.compareTwoStrings("potato", "tomato");
    
    0 讨论(0)
提交回复
热议问题