annil 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/README.md +79 -10
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js +6 -6
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js.map +1 -1
- package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/CustomEventConstraint.d.ts +3 -3
- package/dist/api/RootComponent/CustomEvents/GetCustomEventDoc.d.ts +5 -5
- package/dist/api/RootComponent/CustomEvents/test/error.test.js +8 -8
- package/dist/api/RootComponent/CustomEvents/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/test/normal.test.d.ts +17 -17
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js +6 -6
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js +5 -5
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js +5 -5
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/properties/mormal.test.js.map +1 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/GetOptionalDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/GetPropertiesDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/GetRequiredDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/PropertiesConstraint.d.ts +12 -12
- package/dist/api/RootComponent/Properties/PropertiesValueValidator.d.ts +2 -2
- package/dist/api/RootComponent/Properties/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/test/normalOptional.test.js +8 -0
- package/dist/api/RootComponent/Properties/test/normalOptional.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/test/normalRequired.test.d.ts +21 -21
- package/dist/api/RootComponent/index.d.ts +1 -1
- package/dist/api/RootComponent/index.js.map +1 -1
- package/dist/api/SubComponent/SubComputed/GetSubComputedDoc.d.ts +1 -1
- package/dist/api/SubComponent/SubComputed/test/normal.test.js +4 -4
- package/dist/api/SubComponent/SubComputed/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/index.d.ts +1 -1
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/api/navigateTo.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/{SpecificType.d.ts → DetailedType.d.ts} +1 -1
- package/dist/types/DetailedType.js +2 -0
- package/dist/types/DetailedType.js.map +1 -0
- package/dist/types/GenerateDoc.d.ts +9 -0
- package/dist/types/GenerateDoc.js +2 -0
- package/dist/types/GenerateDoc.js.map +1 -0
- package/dist/types/InferDetailedType.d.ts +2 -0
- package/dist/types/InferDetailedType.js +2 -0
- package/dist/types/InferDetailedType.js.map +1 -0
- package/dist/types/{InferSpecificType.test.js → InferDetailedType.test.js} +1 -1
- package/dist/types/InferDetailedType.test.js.map +1 -0
- package/dist/types/OfficialTypeAlias.d.ts +4 -4
- package/package.json +2 -2
- package/src/api/DefineComponent/ReturnType/test/normalComponentDoc.test.ts +12 -12
- package/src/api/DefineComponent/ReturnType/test/normalPageDoc.test.ts +4 -4
- package/src/api/RootComponent/Computed/test/normal.test.ts +2 -2
- package/src/api/RootComponent/CustomEvents/CustomEventConstraint.ts +3 -3
- package/src/api/RootComponent/CustomEvents/CustomEventsOption.ts +2 -2
- package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +7 -7
- package/src/api/RootComponent/CustomEvents/test/error.test.ts +8 -8
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +9 -9
- package/src/api/RootComponent/Events/EventsConstraint.ts +1 -1
- package/src/api/RootComponent/Instance/test/CustomEventsDoc.test.ts +8 -8
- package/src/api/RootComponent/Instance/test/customEvents/normal.test.ts +8 -8
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +3 -3
- package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +3 -3
- package/src/api/RootComponent/Properties/GetOptionalDoc.ts +5 -5
- package/src/api/RootComponent/Properties/GetPropertiesDoc.ts +3 -3
- package/src/api/RootComponent/Properties/GetRequiredDoc.ts +5 -5
- package/src/api/RootComponent/Properties/PropertiesConstraint.ts +12 -12
- package/src/api/RootComponent/Properties/PropertiesOption.ts +1 -1
- package/src/api/RootComponent/Properties/PropertiesValueValidator.ts +2 -2
- package/src/api/RootComponent/Properties/test/error.test.ts +2 -2
- package/src/api/RootComponent/Properties/test/normalOptional.test.ts +22 -8
- package/src/api/RootComponent/Properties/test/normalRequired.test.ts +11 -11
- package/src/api/RootComponent/Watch/test/WatchComputed.test.ts +2 -2
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +4 -4
- package/src/api/RootComponent/index.ts +1 -8
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +15 -9
- package/src/api/SubComponent/index.ts +2 -1
- package/src/index.ts +11 -2
- package/src/types/DetailedType.ts +15 -0
- package/src/types/GenerateDoc.ts +19 -0
- package/src/types/InferDetailedType.test.ts +18 -0
- package/src/types/{InferSpecificType.ts → InferDetailedType.ts} +4 -4
- package/src/types/RestorePropertiesDoc.ts +3 -3
- package/tsconfig.json +2 -2
- package/dist/types/InferSpecificType.d.ts +0 -2
- package/dist/types/InferSpecificType.js +0 -2
- package/dist/types/InferSpecificType.js.map +0 -1
- package/dist/types/InferSpecificType.test.js.map +0 -1
- package/dist/types/SpecificType.js +0 -2
- package/dist/types/SpecificType.js.map +0 -1
- package/src/types/InferSpecificType.test.ts +0 -18
- package/src/types/SpecificType.ts +0 -15
- /package/dist/types/{InferSpecificType.test.d.ts → InferDetailedType.test.d.ts} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Checking, type Test } from "hry-types";
|
|
2
|
+
|
|
3
|
+
import type { DetailedType } from "./DetailedType";
|
|
4
|
+
import type { InferDetailedType } from "./InferDetailedType";
|
|
5
|
+
|
|
6
|
+
Checking<InferDetailedType<StringConstructor>, string, Test.Pass>;
|
|
7
|
+
|
|
8
|
+
Checking<InferDetailedType<NumberConstructor>, number, Test.Pass>;
|
|
9
|
+
|
|
10
|
+
Checking<InferDetailedType<BooleanConstructor>, boolean, Test.Pass>;
|
|
11
|
+
|
|
12
|
+
Checking<InferDetailedType<ArrayConstructor>, unknown[], Test.Pass>;
|
|
13
|
+
|
|
14
|
+
Checking<InferDetailedType<ObjectConstructor>, object, Test.Pass>;
|
|
15
|
+
|
|
16
|
+
Checking<InferDetailedType<DetailedType<"a" | "b">>, "a" | "b", Test.Pass>;
|
|
17
|
+
|
|
18
|
+
Checking<InferDetailedType<DetailedType<[string, number, boolean]>>, [string, number, boolean], Test.Pass>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DetailedType } from "./DetailedType";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* 解析
|
|
4
|
+
* 解析DetailedType的类型
|
|
5
5
|
*/
|
|
6
|
-
export type
|
|
6
|
+
export type InferDetailedType<T> = T extends StringConstructor ? string
|
|
7
7
|
: T extends NumberConstructor ? number
|
|
8
8
|
: T extends BooleanConstructor ? boolean
|
|
9
9
|
: T extends ArrayConstructor ? unknown[]
|
|
10
10
|
: T extends ObjectConstructor ? object
|
|
11
|
-
: T extends
|
|
11
|
+
: T extends DetailedType<infer R> ? R
|
|
12
12
|
: never;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
// import type { ListOfSamePrimitive } from "./ListOfSamePrimitive";
|
|
5
5
|
// import type { ReStorePropTypeOfList } from "./ReStorePropTypeOfList";
|
|
6
|
-
// import type {
|
|
6
|
+
// import type { DetailedType } from "./DetailedType";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* 还原properties描述
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
// type ReStorePropertiesDoc<T extends ComponentDoc> = {
|
|
18
18
|
// [k in keyof T]?: ListOfSamePrimitive<T[k]> extends infer R extends unknown[]
|
|
19
|
-
// ? R["length"] extends 1 ?
|
|
19
|
+
// ? R["length"] extends 1 ? DetailedType<R[0]> | { type: DetailedType<R[0]>; value: R[0] }
|
|
20
20
|
// : {
|
|
21
|
-
// type:
|
|
21
|
+
// type: DetailedType<R[0]>;
|
|
22
22
|
// value?: R[0];
|
|
23
23
|
// optionalTypes?: ReStorePropTypeOfList<Drop<R, R[0]>>[number][];
|
|
24
24
|
// }
|
package/tsconfig.json
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"ignoreDeprecations": "5.0",
|
|
23
23
|
"noFallthroughCasesInSwitch": true, // 报告switch语句中漏接情况的错误
|
|
24
24
|
"allowSyntheticDefaultImports": true, // esModuleInterop 为true时自动true
|
|
25
|
-
//
|
|
26
|
-
"types": ["
|
|
25
|
+
// 默认加载所有@types下的包 types指定具体的包,其他拒绝。包含上级目录
|
|
26
|
+
"types": ["hry-types", "mobx", "jest", "miniprogram-api-typings"]
|
|
27
27
|
},
|
|
28
28
|
"include": ["**/*.ts"]
|
|
29
29
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import type { SpecificType } from "./SpecificType";
|
|
2
|
-
export type InferSpecificType<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends SpecificType<infer R> ? R : never;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InferSpecificType.js","sourceRoot":"","sources":["../../src/types/InferSpecificType.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InferSpecificType.test.js","sourceRoot":"","sources":["../../src/types/InferSpecificType.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAKhD,QAAiE,CAAC;AAElE,QAAiE,CAAC;AAElE,QAAmE,CAAC;AAEpE,QAAmE,CAAC;AAEpE,QAAiE,CAAC;AAElE,QAA0E,CAAC;AAE3E,QAA0G,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpecificType.js","sourceRoot":"","sources":["../../src/types/SpecificType.ts"],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Checking, type Test } from "hry-types";
|
|
2
|
-
|
|
3
|
-
import type { InferSpecificType } from "./InferSpecificType";
|
|
4
|
-
import type { SpecificType } from "./SpecificType";
|
|
5
|
-
|
|
6
|
-
Checking<InferSpecificType<StringConstructor>, string, Test.Pass>;
|
|
7
|
-
|
|
8
|
-
Checking<InferSpecificType<NumberConstructor>, number, Test.Pass>;
|
|
9
|
-
|
|
10
|
-
Checking<InferSpecificType<BooleanConstructor>, boolean, Test.Pass>;
|
|
11
|
-
|
|
12
|
-
Checking<InferSpecificType<ArrayConstructor>, unknown[], Test.Pass>;
|
|
13
|
-
|
|
14
|
-
Checking<InferSpecificType<ObjectConstructor>, object, Test.Pass>;
|
|
15
|
-
|
|
16
|
-
Checking<InferSpecificType<SpecificType<"a" | "b">>, "a" | "b", Test.Pass>;
|
|
17
|
-
|
|
18
|
-
Checking<InferSpecificType<SpecificType<[string, number, boolean]>>, [string, number, boolean], Test.Pass>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 通过as SpecificType 指定具体类型。
|
|
3
|
-
* @remarks
|
|
4
|
-
* 在js中使用构造函数(Object,Array等)表示类型时,无法给出明确的类型,SpecificType为此而生
|
|
5
|
-
* @example
|
|
6
|
-
* ``` ts
|
|
7
|
-
* RootComponent()({
|
|
8
|
-
* properties: {
|
|
9
|
-
* gender: String as SpecificType<"male" | "female">,
|
|
10
|
-
* unionArr: Array as SpecificType<string[] | number[]>,
|
|
11
|
-
* },
|
|
12
|
-
* });
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export type SpecificType<T = unknown> = { (): T } | { new(...arg: any[]): T };
|
|
File without changes
|