hashids typescript lua 定义文件另外一种写法

参考定义

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

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

posted on 2022-04-28 00:00  荣锋亮  阅读(36)  评论(0编辑  收藏  举报

导航