参考定义

实际上与以前的类似,只是使用上不一样而已

declare module "myhashids" {
interface Hashids {
encode(...args: number[]):string
decode(hashid:string):number[]
}
interface myHashidsConstructor {
new: (this: void, saltKey: string,length?:number) => Hashids;
}
var id: myHashidsConstructor
export = {
...id
}
}

使用

import myid = require("myhashids")
let infoid = myid.new("ddd")

参考资料

​https://typescripttolua.github.io/docs/external-lua-code​

​https://typescripttolua.github.io/docs/advanced/writing-declarations​

​https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require​