Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uni-helper/uni-cloud-types
uni-cloud 组件类型
https://github.com/uni-helper/uni-cloud-types
Last synced: 2 months ago
JSON representation
uni-cloud 组件类型
- Host: GitHub
- URL: https://github.com/uni-helper/uni-cloud-types
- Owner: uni-helper
- License: mit
- Archived: true
- Created: 2022-11-16T03:23:10.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-06T09:37:27.000Z (5 months ago)
- Last Synced: 2024-08-06T11:33:38.080Z (5 months ago)
- Language: TypeScript
- Homepage:
- Size: 398 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-uni-app - typescript - helper/uni-cloud-types) - uni-cloud 组件类型支持。 (类型)
README
# @uni-helper/uni-cloud-types
**该仓库已废弃,请查看 [@uni-helper/uni-types](https://github.com/uni-helper/uni-types) 获取最新支持。**
[![License](https://img.shields.io/github/license/uni-helper/uni-cloud-types)](https://github.com/uni-helper/uni-cloud-types/blob/main/LICENSE)
[![npm](https://img.shields.io/npm/v/@uni-helper/uni-cloud-types)](https://www.npmjs.com/package/@uni-helper/uni-cloud-types)
- [@uni-helper/uni-app-types](https://github.com/uni-helper/uni-app-types) 提供 `uni-app` 组件类型
- [@uni-helper/uni-cloud-types](https://github.com/uni-helper/uni-cloud-types) (当前仓库)提供 `uni-cloud` 组件类型
- [@uni-helper/uni-ui-types](https://github.com/uni-helper/uni-ui-types) 提供 `uni-ui` 组件类型基于 [这个 PR](https://github.com/vuejs/core/pull/3399),[Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar)(即 Volar) 已经支持。
安装之后,请参考 [这里](https://cn.vuejs.org/guide/typescript/overview.html) 配置你的 VS Code。启用或安装后需要重启 VS Code。
维护直到官方类型推出。
**类型和文档的冲突之处,请以文档为准。**
类型源代码在 [uni-helper/uni-cloud-types](https://github.com/uni-helper/uni-cloud-types)。欢迎提交 ISSUE 和 PR 改进类型。
## 使用
- 安装依赖
```shell
npm i -D @uni-helper/uni-app-types @uni-helper/uni-cloud-types
```
yarn v2/v3
请参考 文档 设置
nodeLinker
为node_modules
。
pnpm
请参考 文档 设置
shamefully-hoist
为true
。
- 配置 `tsconfig.json`,确保 `compilerOptions.types` 中含有 `@dcloudio/types`、`@uni-helper/uni-app-types` 和 `@uni-helper/uni-cloud-types`,且 `include` 包含了对应的 `vue` 文件
2.0.14 <=Vue Language Features (Volar)
&vue-tsc
<= 2.0.21```json
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"@uni-helper/uni-app-types",
"@uni-helper/uni-cloud-types"
]
},
"vueCompilerOptions": {
"plugins": ["@uni-helper/uni-app-types/volar-plugin"]
},
"include": ["src/**/*.vue"]
}
```
1.7.12 <=Vue Language Features (Volar)
&vue-tsc
< 2.0.14```json
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"@uni-helper/uni-app-types",
"@uni-helper/uni-cloud-types"
]
},
"vueCompilerOptions": {
"nativeTags": ["block", "component", "template", "slot"]
},
"include": ["src/**/*.vue"]
}
```
1.5.1 <=Vue Language Features (Volar)
&vue-tsc
< 1.7.12```json
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"@uni-helper/uni-app-types",
"@uni-helper/uni-cloud-types"
]
},
"include": ["src/**/*.vue"]
}
```
1.0.10 <=Vue Language Features (Volar)
&vue-tsc
< 1.5.1```json
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"@uni-helper/uni-app-types",
"@uni-helper/uni-cloud-types"
]
},
"vueCompilerOptions": {
"nativeTags": ["block", "component", "template", "slot"]
},
"include": ["src/**/*.vue"]
}
```
0.34.16 <=Vue Language Features (Volar)
&vue-tsc
< 1.0.10```json
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"@uni-helper/uni-app-types",
"@uni-helper/uni-cloud-types"
]
},
"vueCompilerOptions": {
"experimentalRuntimeMode": "runtime-uni-app"
},
"include": ["src/**/*.vue"]
}
```
- 重启编辑器 / IDE
### 标注类型
推荐使用 `@uni-helper/uni-cloud-types` 导出的类型为变量标注类型。
```vue
import { ref } from 'vue';
import type {
UnicloudDbOnLoad,
UnicloudDbSpaceInfoProvider,
} from '@uni-helper/uni-cloud-types';const spaceInfoProvider = ref<UnicloudDbSpaceInfoProvider>('aliyun');
const onLoad: UnicloudDbOnLoad = (event) => {
// ...
};
```
也可以直接使用命名空间来为变量标注类型。
```vue
import { ref } from 'vue';
const spaceInfoProvider = ref<UniHelper.UnicloudDbSpaceInfoProvider>(50);
const onLoad: UniHelper.UnicloudDbOnLoad = (event) => {
// ...
};
```
请查看 [src](./src) 了解所有类型。
## 致谢
最初在 [uni-base-components-types](https://github.com/satrong/uni-base-components-types) 得到了灵感。
基于 [这个 PR](https://github.com/satrong/uni-base-components-types/pull/5) 完成。