Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望只提示,在小程序版本设置中“基础库最低可用版本”以上的api,屏蔽较新的api #286

Open
dhlolo opened this issue May 4, 2023 · 2 comments

Comments

@dhlolo
Copy link

dhlolo commented May 4, 2023

如题,不知道现在有没有这个映射关系,或者能不能实现这个功能

@SgLy
Copy link
Contributor

SgLy commented Jun 9, 2023

之前有收到过类似的建议,后来在 cba3766 中调整了一部分注释的顺序,把支持的版本和插件支持情况放在最上面了

某个 API 对应可用版本这个信息在定义生成时是有的(因此可以输出到注释里),但印象中 TS 似乎没有类似的功能可以根据某个自定义配置来改变编译结果;TS 编译器插件我没太了解过,不确定能不能做到这个效果

只依赖定义文件的话,可行的办法可能只有另外生成一份只包含特定版本兼容接口的定义了

@dhlolo
Copy link
Author

dhlolo commented Jun 11, 2023

有没有可能做到类似:

export type LatestVersion = { someApi: ... }
export type 2_7_1 = { someOldApi: ... }
type Version = '2.7.1' | 'latest' | ...
export ActiveApi<V extends Version> = V extends '2.7.1' ? 2_7_1 : ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants