Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

feat: typescript module declaration, part 1 #908

Merged
merged 13 commits into from
Sep 12, 2020
Merged

feat: typescript module declaration, part 1 #908

merged 13 commits into from
Sep 12, 2020

Conversation

greenhat616
Copy link
Contributor

@greenhat616 greenhat616 commented Sep 3, 2020

此声明为第一版,只增加了参数的类型、自动补全功能
像这样的函数注解可能得等下一次更新了、

/**
* Foo Function
* @params {string} a doSomethong
* @returns
*/

@vercel
Copy link

vercel bot commented Sep 3, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/binaryify/netease-cloud-music-api/epxe0d48r
✅ Preview: https://netease-cloud-music-api-git-fork-greenhat616-master.binaryify.vercel.app

@greenhat616 greenhat616 changed the title feat: typescript moudle declaration feat: typescript module declaration Sep 3, 2020
@greenhat616 greenhat616 changed the title feat: typescript module declaration feat: typescript module declaration, part 1 Sep 5, 2020
@greenhat616
Copy link
Contributor Author

话说要不要引入 Github Actions 做 Lints?

@greenhat616
Copy link
Contributor Author

@Binaryify Ready for review

@greenhat616
Copy link
Contributor Author

greenhat616 commented Sep 5, 2020

除了 TS 之外,我将 prettier 集成进了项目,同时加了个 .editorconfig 文件。

@Binaryify
Copy link
Owner

好,我看看

@Binaryify
Copy link
Owner

Binaryify commented Sep 5, 2020

感觉还有些问题
image
image
image
image

@greenhat616
Copy link
Contributor Author

greenhat616 commented Sep 5, 2020

试试这样?

import sdk from 'NeteaseCloudMusicApi'
sdk.someOperation(params)

image

学术性的我就不献丑啦,转某博主的总结:
image
image

@Binaryify
Copy link
Owner

image

@greenhat616
Copy link
Contributor Author

我看看

@Binaryify
Copy link
Owner

你试试
image

@greenhat616
Copy link
Contributor Author

image

有点奇怪,不过确实存在 import { specificModule } from 'xxx' 不能用的问题,我改进下导出

@Binaryify
Copy link
Owner

@greenhat616
Copy link
Contributor Author

greenhat616 commented Sep 5, 2020 via email

@Binaryify
Copy link
Owner

不急

@greenhat616
Copy link
Contributor Author

greenhat616 commented Sep 7, 2020

有点麻烦,貌似要实现这个 import { specificModule } from 'xxx' 只能使用 export = SDK 然后使用 namescpae merge (把所有接口都放到 SDK 这个命名空间里)

但是现在令我困惑的是不知道怎么处理不同声明文件的namescpae 合并(相同命名的),TS 文件里倒是可以使用三斜线算法搞,但是声明文件貌似不行,哎

https://www.typescriptlang.org/docs/handbook/declaration-merging.html
https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html

@greenhat616
Copy link
Contributor Author

或者我们干脆丢弃掉暴露的接口?(只是可能会对开发造成一定的不便)

@greenhat616
Copy link
Contributor Author

image
image
image
image
我先采用楼上说的方法把,先不暴露接口了

@Binaryify
Copy link
Owner

可以

@Binaryify Binaryify merged commit 7499616 into Binaryify:master Sep 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants