Giter VIP home page Giter VIP logo

hamibot-types's Introduction

Hamibot 类型声明

hamibot 内置函数的类型声明

🚀 获取类型声明

通过脚本获取

这里提供四个脚本分别对应不同系统和不同来源,只需要在项目根目录下运行即可:

推荐使用 Hamibot 代理的脚本,国内获取更稳定也不会被限制访问次数。

当然你也可以手动从 Release 中下载压缩包并解压在项目目录中。

使用 Git 获取

# 添加子树
git subtree add --prefix=hamibot-types [email protected]:batu1579/hamibot-types.git main --squash

# 将修改推送到远程
git push

💪 获取更新

通过脚本更新

重复 通过脚本获取 的操作重新获取即可。

使用 Git 更新

# 拉取子树新代码
git subtree pull --prefix=hamibot-types [email protected]:batu1579/hamibot-types.git main --squash

# 将修改推送到远程
git push

🛠️ 迁移说明

如果你当前的项目正在使用老版本的模板,可以选择手动更新到新的类型声明(后续会更新模板)。你只需要完成下面几个步骤:

  1. 删除原来模板中携带的 types 文件夹

  2. 使用前文提到的方式 通过脚本获取通过 Git 获取

  3. 打开根目录中的 tsconfig.json 文件,将其中 typeRoots 数组中的 types 修改为 **\types :

    {
        "compilerOptions": {
            ...
            "typeRoots": [
                "types",    // 将这行
                "**/types", // 修改为这行
                "node_modules/@types"
            ],
            ...
        }
    }

⚠️ 注意事项

如果有用到暂时没有声明过的模块,可以使用 TS 的忽略语法:

注意:忽略会跳过所有检查,除了语法错误。使用时会有风险,请在确保肯定不会出现问题后再使用。

// 多行忽略(取消两个标记间的代码检查。)
// 可以不使用结束标记,即忽略到文件结尾。
// 注意:必须在文件顶部使用。
// @ts-nocheck
canvas.drawLine(0, 0, 1080, 1920, paint);

// @ts-check

// 单行忽略(取消下一行的代码检查。)
// @ts-ignore
canvas.drawLine(0, 0, 1080, 1920, paint);

📋 更新日志

查看 更新日志

hamibot-types's People

Contributors

batu1579 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

hamibot-types's Issues

[Bug] HttpRequestOptions 类型错误

错误描述
使用 http.request() 方法时如果使用了配置项则必须填写每个字段,但实际上只要填写需要的设置项即可。

错误复现
使用如下官网中的文档可以看到类型提示显示如下错误:

类型“{ method: "GET"; headers: { authorization: string; }; }”缺少类型“HttpRequestOptions”中的以下属性: contentType, bodyts(2345)
var res = http.request('https://api.hamibot.com/v1/robots/_id', {
    method: 'GET',
    headers: {
        authorization: 'hmp_...',
    },
});
log(res.body.json());

行为预期
其中每个配置项都应该是可选的。

缺少 getClip 函数的声明

错误描述

在脚本中使用 getClip() 函数时收到了错误的类型提示,找不到名称 getClip

截图

image

[BUG] events.addListener() 方法的提示问题

错误描述
文档中说 events.addListener()events.on() 的别名,但是在填写 eventName 参数时 events.addListener() 没有 events.on() 那样提供的备选名称。

行为预期
两者的行为应该是同样的。

截图

image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.