@pawover/kit 0.2.0 → 0.2.2
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/package.json +15 -15
- package/packages/hooks/dist/alova.d.ts +7 -4
- package/packages/hooks/dist/alova.js +13 -27
- package/packages/hooks/dist/react.d.ts +2 -4
- package/packages/hooks/dist/react.js +52 -35
- package/packages/utils/dist/index.d.ts +432 -347
- package/packages/utils/dist/index.js +3 -4
- package/packages/utils/dist/math.d.ts +0 -1
- package/packages/utils/dist/math.js +1 -1
- package/packages/utils/dist/{stringUtil-CaY_wCS-.js → stringUtil-DbYpnL4l.js} +17 -0
- package/packages/utils/dist/vite.d.ts +0 -1
- package/packages/zod/dist/index.d.ts +0 -1
|
@@ -615,7 +615,6 @@ type AnyAsyncFunction<P extends any[] = any[], R = any> = (...args: P) => Promis
|
|
|
615
615
|
type AnyGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => Generator<T, R, N>;
|
|
616
616
|
/** 描述异步生成器函数类型 */
|
|
617
617
|
type AnyAsyncGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => AsyncGenerator<T, R, N>;
|
|
618
|
-
/** 描述无返回值函数 */
|
|
619
618
|
//#endregion
|
|
620
619
|
//#region src/function/functionUtil.d.ts
|
|
621
620
|
/**
|
|
@@ -699,91 +698,177 @@ declare class MimeUtil {
|
|
|
699
698
|
* 基于 IANA 注册标准和浏览器兼容性验证
|
|
700
699
|
*/
|
|
701
700
|
static readonly MIME: {
|
|
702
|
-
/** 普通文本文件 */
|
|
703
|
-
readonly
|
|
704
|
-
|
|
705
|
-
readonly
|
|
706
|
-
|
|
707
|
-
readonly
|
|
708
|
-
|
|
709
|
-
readonly
|
|
710
|
-
|
|
711
|
-
readonly
|
|
712
|
-
|
|
713
|
-
readonly
|
|
714
|
-
|
|
715
|
-
readonly
|
|
716
|
-
|
|
717
|
-
readonly
|
|
718
|
-
|
|
719
|
-
readonly
|
|
720
|
-
|
|
721
|
-
readonly
|
|
722
|
-
|
|
723
|
-
readonly
|
|
724
|
-
|
|
725
|
-
readonly
|
|
726
|
-
|
|
727
|
-
readonly
|
|
728
|
-
|
|
729
|
-
readonly
|
|
730
|
-
|
|
731
|
-
readonly
|
|
732
|
-
|
|
733
|
-
readonly
|
|
734
|
-
|
|
735
|
-
readonly
|
|
736
|
-
|
|
737
|
-
readonly
|
|
738
|
-
|
|
739
|
-
readonly
|
|
740
|
-
|
|
741
|
-
readonly
|
|
742
|
-
|
|
743
|
-
readonly
|
|
744
|
-
|
|
745
|
-
readonly
|
|
746
|
-
|
|
747
|
-
readonly
|
|
748
|
-
|
|
749
|
-
readonly
|
|
750
|
-
|
|
751
|
-
readonly
|
|
752
|
-
|
|
753
|
-
readonly
|
|
754
|
-
|
|
755
|
-
readonly
|
|
756
|
-
|
|
757
|
-
readonly
|
|
758
|
-
|
|
759
|
-
readonly
|
|
760
|
-
|
|
761
|
-
readonly
|
|
762
|
-
|
|
763
|
-
readonly
|
|
764
|
-
|
|
765
|
-
readonly
|
|
766
|
-
|
|
767
|
-
readonly
|
|
768
|
-
|
|
769
|
-
readonly
|
|
770
|
-
|
|
771
|
-
readonly
|
|
772
|
-
|
|
773
|
-
readonly
|
|
774
|
-
|
|
775
|
-
readonly
|
|
776
|
-
|
|
777
|
-
readonly
|
|
778
|
-
|
|
779
|
-
readonly
|
|
780
|
-
|
|
781
|
-
readonly
|
|
782
|
-
|
|
783
|
-
readonly
|
|
784
|
-
|
|
785
|
-
readonly
|
|
786
|
-
|
|
701
|
+
/** 普通文本文件 */
|
|
702
|
+
readonly TEXT: "text/plain";
|
|
703
|
+
/** 超文本标记语言文档 */
|
|
704
|
+
readonly HTML: "text/html";
|
|
705
|
+
/** 层叠样式表文件 */
|
|
706
|
+
readonly CSS: "text/css";
|
|
707
|
+
/** 逗号分隔值文件(表格数据) */
|
|
708
|
+
readonly CSV: "text/csv";
|
|
709
|
+
/** 制表符分隔值文件 */
|
|
710
|
+
readonly TSV: "text/tab-separated-values";
|
|
711
|
+
/** XML 文档 */
|
|
712
|
+
readonly XML: "text/xml";
|
|
713
|
+
/** XHTML 文档(XML 严格格式的 HTML) */
|
|
714
|
+
readonly XHTML: "application/xhtml+xml";
|
|
715
|
+
/** JavaScript 文件 */
|
|
716
|
+
readonly JS: "text/javascript";
|
|
717
|
+
/** TypeScript 文件 */
|
|
718
|
+
readonly TS: "text/typescript";
|
|
719
|
+
/** Python 文件 */
|
|
720
|
+
readonly PY: "text/x-python";
|
|
721
|
+
/** Shell 脚本 (.sh) */
|
|
722
|
+
readonly SH: "text/x-sh";
|
|
723
|
+
/** C 语言源文件 */
|
|
724
|
+
readonly C: "text/x-c";
|
|
725
|
+
/** C++ 源文件 */
|
|
726
|
+
readonly CPP: "text/x-c++";
|
|
727
|
+
/** C# 源文件 */
|
|
728
|
+
readonly CSHARP: "text/x-csharp";
|
|
729
|
+
/** Java 源文件 */
|
|
730
|
+
readonly JAVA: "text/x-java";
|
|
731
|
+
/** Go 源文件 */
|
|
732
|
+
readonly GO: "text/x-go";
|
|
733
|
+
/** Rust 源文件 */
|
|
734
|
+
readonly RUST: "text/x-rust";
|
|
735
|
+
/** PHP 文件 */
|
|
736
|
+
readonly PHP: "text/x-php";
|
|
737
|
+
/** Ruby 文件 */
|
|
738
|
+
readonly RUBY: "text/x-ruby";
|
|
739
|
+
/** Swift 源文件 */
|
|
740
|
+
readonly SWIFT: "text/x-swift";
|
|
741
|
+
/** YAML 文档 */
|
|
742
|
+
readonly YAML: "text/vnd.yaml";
|
|
743
|
+
/** TOML 文档 */
|
|
744
|
+
readonly TOML: "text/x-toml";
|
|
745
|
+
/** SQL 脚本 */
|
|
746
|
+
readonly SQL: "text/x-sql";
|
|
747
|
+
/** Markdown 格式文档 */
|
|
748
|
+
readonly MARKDOWN: "text/markdown";
|
|
749
|
+
/** 富文本格式文档(.rtf) */
|
|
750
|
+
readonly RTF: "application/rtf";
|
|
751
|
+
/** iCalendar 日历格式(.ics) */
|
|
752
|
+
readonly CALENDAR: "text/calendar";
|
|
753
|
+
/** JPEG 图像(.jpg/.jpeg) */
|
|
754
|
+
readonly JPEG: "image/jpeg";
|
|
755
|
+
/** PNG 图像(无损压缩,支持透明) */
|
|
756
|
+
readonly PNG: "image/png";
|
|
757
|
+
/** GIF 图像(支持动画) */
|
|
758
|
+
readonly GIF: "image/gif";
|
|
759
|
+
/** Windows 位图(.bmp) */
|
|
760
|
+
readonly BMP: "image/bmp";
|
|
761
|
+
/** SVG 向量图形(.svg) */
|
|
762
|
+
readonly SVG: "image/svg+xml";
|
|
763
|
+
/** APNG 动态图像(.apng) */
|
|
764
|
+
readonly APNG: "image/apng";
|
|
765
|
+
/** AVIF 图像(高效压缩) */
|
|
766
|
+
readonly AVIF: "image/avif";
|
|
767
|
+
/** 图标文件格式(.ico) */
|
|
768
|
+
readonly ICO: "image/vnd.microsoft.icon";
|
|
769
|
+
/** WebP 图像(高效压缩) */
|
|
770
|
+
readonly WEBP: "image/webp";
|
|
771
|
+
/** TIFF 图像(.tif/.tiff) */
|
|
772
|
+
readonly TIFF: "image/tiff";
|
|
773
|
+
/** HEIC 图像(高效编码) */
|
|
774
|
+
readonly HEIC: "image/heic";
|
|
775
|
+
/** Adobe Photoshop 文件(.psd) */
|
|
776
|
+
readonly PSD: "image/vnd.adobe.photoshop";
|
|
777
|
+
/** MP3 音频(.mp3) */
|
|
778
|
+
readonly MP3: "audio/mpeg";
|
|
779
|
+
/** AAC 音频(.aac) */
|
|
780
|
+
readonly AAC: "audio/aac";
|
|
781
|
+
/** MIDI 音乐文件(.mid/.midi) */
|
|
782
|
+
readonly MIDI: "audio/midi";
|
|
783
|
+
/** OGG 音频(.oga) */
|
|
784
|
+
readonly OGG_AUDIO: "audio/ogg";
|
|
785
|
+
/** Opus 音频(.opus) */
|
|
786
|
+
readonly OPUS: "audio/opus";
|
|
787
|
+
/** WAV 音频(.wav) */
|
|
788
|
+
readonly WAV: "audio/wav";
|
|
789
|
+
/** RealAudio 音频(.ra/.ram) */
|
|
790
|
+
readonly REAL_AUDIO: "audio/x-pn-realaudio";
|
|
791
|
+
/** MP4 视频(.mp4) */
|
|
792
|
+
readonly MP4: "video/mp4";
|
|
793
|
+
/** MPEG 视频(.mpeg/.mpg) */
|
|
794
|
+
readonly MPEG: "video/mpeg";
|
|
795
|
+
/** OGG 视频(.ogv) */
|
|
796
|
+
readonly OGG_VIDEO: "video/ogg";
|
|
797
|
+
/** AVI 视频(.avi) */
|
|
798
|
+
readonly AVI: "video/x-msvideo";
|
|
799
|
+
/** 3GPP 视频(.3gp) */
|
|
800
|
+
readonly THREE_GPP: "video/3gpp";
|
|
801
|
+
/** 3GPP2 视频(.3g2) */
|
|
802
|
+
readonly THREE_GPP2: "video/3gpp2";
|
|
803
|
+
/** WebM 视频(.webm) */
|
|
804
|
+
readonly WEBM: "video/webm";
|
|
805
|
+
/** PDF 文档 */
|
|
806
|
+
readonly PDF: "application/pdf";
|
|
807
|
+
/** Word 97-2003 文档(.doc) */
|
|
808
|
+
readonly DOC: "application/msword";
|
|
809
|
+
/** Word 2007+ 文档(.docx) */
|
|
810
|
+
readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
811
|
+
/** Excel 2007+ 工作簿(.xlsx) */
|
|
812
|
+
readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
813
|
+
/** 启用宏的Excel工作簿(.xlsm) */
|
|
814
|
+
readonly XLSM: "application/vnd.ms-excel.sheet.macroEnabled.12";
|
|
815
|
+
/** Excel模板文件(.xltx) */
|
|
816
|
+
readonly XLTX: "application/vnd.openxmlformats-officedocument.spreadsheetml.template";
|
|
817
|
+
/** PowerPoint 2007+ 演示文稿(.pptx) */
|
|
818
|
+
readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
819
|
+
/** PowerPoint 97-2003 演示文稿(.ppt) */
|
|
820
|
+
readonly PPT: "application/vnd.ms-powerpoint";
|
|
821
|
+
/** OpenDocument 文本文档(.odt) */
|
|
822
|
+
readonly ODT: "application/vnd.oasis.opendocument.text";
|
|
823
|
+
/** OpenDocument 表格文档(.ods) */
|
|
824
|
+
readonly ODS: "application/vnd.oasis.opendocument.spreadsheet";
|
|
825
|
+
/** OpenDocument 演示文稿(.odp) */
|
|
826
|
+
readonly ODP: "application/vnd.oasis.opendocument.presentation";
|
|
827
|
+
/** EPUB 电子书(.epub) */
|
|
828
|
+
readonly EPUB: "application/epub+zip";
|
|
829
|
+
/** Kindle 电子书(.azw) */
|
|
830
|
+
readonly AZW: "application/vnd.amazon.ebook";
|
|
831
|
+
/** ZIP 压缩文件(.zip) */
|
|
832
|
+
readonly ZIP: "application/zip";
|
|
833
|
+
/** GZIP 压缩文件(.gz) */
|
|
834
|
+
readonly GZIP: "application/gzip";
|
|
835
|
+
/** GZIP 压缩文件(旧格式) */
|
|
836
|
+
readonly X_GZIP: "application/x-gzip";
|
|
837
|
+
/** TAR 归档文件(.tar) */
|
|
838
|
+
readonly TAR: "application/x-tar";
|
|
839
|
+
/** BZip 归档(.bz) */
|
|
840
|
+
readonly BZIP: "application/x-bzip";
|
|
841
|
+
/** BZip2 归档(.bz2) */
|
|
842
|
+
readonly BZIP2: "application/x-bzip2";
|
|
843
|
+
/** 7-Zip 压缩文件(.7z) */
|
|
844
|
+
readonly SEVEN_Z: "application/x-7z-compressed";
|
|
845
|
+
/** RAR 压缩文件(.rar) */
|
|
846
|
+
readonly RAR: "application/vnd.rar";
|
|
847
|
+
/** 通用二进制数据(默认类型) */
|
|
848
|
+
readonly OCTET_STREAM: "application/octet-stream";
|
|
849
|
+
/** JSON 数据格式(.json) */
|
|
850
|
+
readonly JSON: "application/json";
|
|
851
|
+
/** JSON-LD 格式(.jsonld) */
|
|
852
|
+
readonly LD_JSON: "application/ld+json";
|
|
853
|
+
/** Java 归档文件(.jar) */
|
|
854
|
+
readonly JAR: "application/java-archive";
|
|
855
|
+
/** WebAssembly 二进制指令格式(.wasm) */
|
|
856
|
+
readonly WASM: "application/wasm";
|
|
857
|
+
/** MS 嵌入式 OpenType 字体(.eot) */
|
|
858
|
+
readonly EOT: "application/vnd.ms-fontobject";
|
|
859
|
+
/** OpenType 字体(.otf) */
|
|
860
|
+
readonly OTF: "font/otf";
|
|
861
|
+
/** WOFF 字体(.woff) */
|
|
862
|
+
readonly WOFF: "font/woff";
|
|
863
|
+
/** WOFF2 字体(.woff2) */
|
|
864
|
+
readonly WOFF2: "font/woff2";
|
|
865
|
+
/** TrueType 字体(.ttf) */
|
|
866
|
+
readonly TTF: "font/ttf";
|
|
867
|
+
/** Excel 97-2003 工作簿(.xls) */
|
|
868
|
+
readonly XLS: "application/vnd.ms-excel";
|
|
869
|
+
/** Microsoft XPS 文档(.xps) */
|
|
870
|
+
readonly XPS: "application/vnd.ms-xpsdocument";
|
|
871
|
+
/** Word 启用宏文档(.docm) */
|
|
787
872
|
readonly DOCM: "application/vnd.ms-word.document.macroEnabled.12";
|
|
788
873
|
};
|
|
789
874
|
}
|
|
@@ -810,7 +895,7 @@ declare class NumberUtil {
|
|
|
810
895
|
static within(input: number, interval: [number, number], includeLeft?: boolean, includeRight?: boolean): boolean;
|
|
811
896
|
}
|
|
812
897
|
//#endregion
|
|
813
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
898
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/typed-array.d.ts
|
|
814
899
|
/**
|
|
815
900
|
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
|
816
901
|
|
|
@@ -818,7 +903,7 @@ Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScrip
|
|
|
818
903
|
*/
|
|
819
904
|
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
820
905
|
//#endregion
|
|
821
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
906
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/characters.d.ts
|
|
822
907
|
/**
|
|
823
908
|
Matches any digit as a string ('0'-'9').
|
|
824
909
|
|
|
@@ -835,7 +920,7 @@ const b: DigitCharacter = 0; // Invalid
|
|
|
835
920
|
*/
|
|
836
921
|
type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
837
922
|
//#endregion
|
|
838
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
923
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
839
924
|
/**
|
|
840
925
|
Convert a union type to an intersection type.
|
|
841
926
|
|
|
@@ -853,18 +938,23 @@ type Intersection = UnionToIntersection<Union>;
|
|
|
853
938
|
|
|
854
939
|
@category Type
|
|
855
940
|
*/
|
|
856
|
-
type UnionToIntersection<Union> = (
|
|
941
|
+
type UnionToIntersection<Union> = (
|
|
942
|
+
// `extends unknown` is always going to be the case and is used to convert the
|
|
857
943
|
// `Union` into a [distributive conditional
|
|
858
944
|
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
859
|
-
Union extends unknown
|
|
945
|
+
Union extends unknown ?
|
|
946
|
+
// The union type is used as the only argument to a function since the union
|
|
860
947
|
// of function arguments is an intersection.
|
|
861
|
-
|
|
862
|
-
|
|
948
|
+
(distributedUnion: Union) => void :
|
|
949
|
+
// This won't happen.
|
|
950
|
+
never
|
|
951
|
+
// Infer the `Intersection` type since TypeScript represents the positional
|
|
863
952
|
// arguments of unions of functions as an intersection of the union.
|
|
864
|
-
) extends ((mergedIntersection: infer Intersection) => void)
|
|
865
|
-
|
|
953
|
+
) extends ((mergedIntersection: infer Intersection) => void) ?
|
|
954
|
+
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
955
|
+
Intersection & Union : never;
|
|
866
956
|
//#endregion
|
|
867
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
957
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/keys-of-union.d.ts
|
|
868
958
|
/**
|
|
869
959
|
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
870
960
|
|
|
@@ -902,10 +992,11 @@ type AllKeys = KeysOfUnion<Union>;
|
|
|
902
992
|
|
|
903
993
|
@category Object
|
|
904
994
|
*/
|
|
905
|
-
type KeysOfUnion<ObjectType> =
|
|
995
|
+
type KeysOfUnion<ObjectType> =
|
|
996
|
+
// Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
|
|
906
997
|
keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
907
998
|
//#endregion
|
|
908
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
999
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-any.d.ts
|
|
909
1000
|
/**
|
|
910
1001
|
Returns a boolean for whether the given type is `any`.
|
|
911
1002
|
|
|
@@ -936,7 +1027,7 @@ const anyA = get(anyObject, 'a');
|
|
|
936
1027
|
*/
|
|
937
1028
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
938
1029
|
//#endregion
|
|
939
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1030
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
940
1031
|
/**
|
|
941
1032
|
Returns a boolean for whether the given key is an optional key of type.
|
|
942
1033
|
|
|
@@ -979,7 +1070,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
979
1070
|
*/
|
|
980
1071
|
type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
981
1072
|
//#endregion
|
|
982
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1073
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
983
1074
|
/**
|
|
984
1075
|
Extract all optional keys from the given type.
|
|
985
1076
|
|
|
@@ -1014,10 +1105,10 @@ const update2: UpdateOperation<User> = {
|
|
|
1014
1105
|
@category Utilities
|
|
1015
1106
|
*/
|
|
1016
1107
|
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
1017
|
-
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
1018
|
-
: never;
|
|
1108
|
+
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never; }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
1109
|
+
: never; // Should never happen
|
|
1019
1110
|
//#endregion
|
|
1020
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1111
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
1021
1112
|
/**
|
|
1022
1113
|
Extract all required keys from the given type.
|
|
1023
1114
|
|
|
@@ -1049,9 +1140,9 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
|
1049
1140
|
@category Utilities
|
|
1050
1141
|
*/
|
|
1051
1142
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
1052
|
-
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
1143
|
+
? Exclude<keyof Type, OptionalKeysOf<Type>> : never; // Should never happen
|
|
1053
1144
|
//#endregion
|
|
1054
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1145
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-never.d.ts
|
|
1055
1146
|
/**
|
|
1056
1147
|
Returns a boolean for whether the given type is `never`.
|
|
1057
1148
|
|
|
@@ -1107,7 +1198,7 @@ type B = IsTrueFixed<never>;
|
|
|
1107
1198
|
*/
|
|
1108
1199
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
1109
1200
|
//#endregion
|
|
1110
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1201
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/if.d.ts
|
|
1111
1202
|
/**
|
|
1112
1203
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
1113
1204
|
|
|
@@ -1202,7 +1293,7 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
1202
1293
|
*/
|
|
1203
1294
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
1204
1295
|
//#endregion
|
|
1205
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1296
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/unknown-array.d.ts
|
|
1206
1297
|
/**
|
|
1207
1298
|
Represents an array with `unknown` value.
|
|
1208
1299
|
|
|
@@ -1229,7 +1320,7 @@ type C = IsArray<string>;
|
|
|
1229
1320
|
*/
|
|
1230
1321
|
type UnknownArray = readonly unknown[];
|
|
1231
1322
|
//#endregion
|
|
1232
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1323
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/internal/type.d.ts
|
|
1233
1324
|
/**
|
|
1234
1325
|
Returns a boolean for whether A is false.
|
|
1235
1326
|
|
|
@@ -1248,16 +1339,16 @@ An if-else-like type that resolves depending on whether the given type is `any`
|
|
|
1248
1339
|
|
|
1249
1340
|
@example
|
|
1250
1341
|
```
|
|
1251
|
-
// When `T` is
|
|
1252
|
-
type A = IfNotAnyOrNever<string, 'VALID'
|
|
1342
|
+
// When `T` is neither `any` nor `never` (like `string`) => Returns `IfNot` branch
|
|
1343
|
+
type A = IfNotAnyOrNever<string, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
|
|
1253
1344
|
//=> 'VALID'
|
|
1254
1345
|
|
|
1255
1346
|
// When `T` is `any` => Returns `IfAny` branch
|
|
1256
|
-
type B = IfNotAnyOrNever<any, 'VALID'
|
|
1347
|
+
type B = IfNotAnyOrNever<any, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
|
|
1257
1348
|
//=> 'IS_ANY'
|
|
1258
1349
|
|
|
1259
1350
|
// When `T` is `never` => Returns `IfNever` branch
|
|
1260
|
-
type C = IfNotAnyOrNever<never, 'VALID'
|
|
1351
|
+
type C = IfNotAnyOrNever<never, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
|
|
1261
1352
|
//=> 'IS_NEVER'
|
|
1262
1353
|
```
|
|
1263
1354
|
|
|
@@ -1270,7 +1361,7 @@ import type {StringRepeat} from 'type-fest';
|
|
|
1270
1361
|
type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
|
|
1271
1362
|
|
|
1272
1363
|
// The following implementation is not tail recursive
|
|
1273
|
-
type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
|
|
1364
|
+
type TrimLeft<S extends string> = IfNotAnyOrNever<S, {ifNot: S extends ` ${infer R}` ? TrimLeft<R> : S}>;
|
|
1274
1365
|
|
|
1275
1366
|
// Hence, instantiations with long strings will fail
|
|
1276
1367
|
// @ts-expect-error
|
|
@@ -1279,7 +1370,7 @@ type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
|
|
|
1279
1370
|
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
1280
1371
|
|
|
1281
1372
|
// To fix this, move the recursion into a helper type
|
|
1282
|
-
type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S
|
|
1373
|
+
type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, {ifNot: _TrimLeftOptimised<S>}>;
|
|
1283
1374
|
|
|
1284
1375
|
type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
|
|
1285
1376
|
|
|
@@ -1287,13 +1378,17 @@ type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
|
|
|
1287
1378
|
//=> ''
|
|
1288
1379
|
```
|
|
1289
1380
|
*/
|
|
1290
|
-
type IfNotAnyOrNever<T,
|
|
1381
|
+
type IfNotAnyOrNever<T, Cases extends {
|
|
1382
|
+
ifNot: unknown;
|
|
1383
|
+
ifAny?: unknown;
|
|
1384
|
+
ifNever?: unknown;
|
|
1385
|
+
}> = IsAny<T> extends true ? 'ifAny' extends keyof Cases ? Cases['ifAny'] : any : IsNever<T> extends true ? 'ifNever' extends keyof Cases ? Cases['ifNever'] : never : Cases['ifNot'];
|
|
1291
1386
|
/**
|
|
1292
1387
|
Indicates the value of `exactOptionalPropertyTypes` compiler option.
|
|
1293
1388
|
*/
|
|
1294
1389
|
type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
|
|
1295
1390
|
//#endregion
|
|
1296
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1391
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/internal/array.d.ts
|
|
1297
1392
|
/**
|
|
1298
1393
|
Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
|
|
1299
1394
|
|
|
@@ -1325,31 +1420,23 @@ type B = CollapseRestElement<[string?, string?, ...number[]]>;
|
|
|
1325
1420
|
//=> [string | undefined, string | undefined, number]
|
|
1326
1421
|
```
|
|
1327
1422
|
*/
|
|
1328
|
-
type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray,
|
|
1423
|
+
type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, {
|
|
1424
|
+
ifNot: _CollapseRestElement<TArray>;
|
|
1425
|
+
}>;
|
|
1329
1426
|
type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
|
|
1330
|
-
? keyof TArray & `${number}` extends never
|
|
1427
|
+
? keyof TArray & `${number}` extends never ?
|
|
1428
|
+
// Enters this branch, if `TArray` is empty (e.g., []),
|
|
1331
1429
|
// or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
|
|
1332
|
-
|
|
1333
|
-
: TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
|
|
1334
|
-
: TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
|
|
1335
|
-
: First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
|
|
1336
|
-
: never; // Should never happen
|
|
1430
|
+
TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
|
|
1431
|
+
: TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
|
|
1432
|
+
: TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
|
|
1433
|
+
: First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
|
|
1434
|
+
: never; // Should never happen
|
|
1337
1435
|
//#endregion
|
|
1338
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1436
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/numeric.d.ts
|
|
1339
1437
|
type _Numeric = number | bigint;
|
|
1340
1438
|
type Zero = 0 | 0n;
|
|
1341
1439
|
/**
|
|
1342
|
-
Matches the hidden `Infinity` type.
|
|
1343
|
-
|
|
1344
|
-
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
|
|
1345
|
-
|
|
1346
|
-
@see {@link NegativeInfinity}
|
|
1347
|
-
|
|
1348
|
-
@category Numeric
|
|
1349
|
-
*/
|
|
1350
|
-
// See https://github.com/microsoft/TypeScript/issues/31752
|
|
1351
|
-
// eslint-disable-next-line no-loss-of-precision
|
|
1352
|
-
/**
|
|
1353
1440
|
A negative `number`/`bigint` (`-∞ < x < 0`)
|
|
1354
1441
|
|
|
1355
1442
|
Use-case: Validating and documenting parameters.
|
|
@@ -1380,12 +1467,12 @@ type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
|
|
|
1380
1467
|
//#region ../../node_modules/.pnpm/tagged-tag@1.0.0/node_modules/tagged-tag/index.d.ts
|
|
1381
1468
|
declare const tag: unique symbol;
|
|
1382
1469
|
//#endregion
|
|
1383
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1470
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/tagged.d.ts
|
|
1384
1471
|
// eslint-disable-next-line type-fest/require-exported-types
|
|
1385
1472
|
type TagContainer<Token> = {
|
|
1386
1473
|
readonly [tag]: Token;
|
|
1387
1474
|
};
|
|
1388
|
-
type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata }>;
|
|
1475
|
+
type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata; }>;
|
|
1389
1476
|
/**
|
|
1390
1477
|
Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) and [per-tag metadata](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf).
|
|
1391
1478
|
|
|
@@ -1476,83 +1563,9 @@ type WontWork = UnwrapTagged<string>;
|
|
|
1476
1563
|
@category Type
|
|
1477
1564
|
*/
|
|
1478
1565
|
type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = RemoveAllTags<TaggedType>;
|
|
1479
|
-
type RemoveAllTags<T> = T extends Tag<PropertyKey, any> ? { [ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]> ? RemoveAllTags<Type> : never }[keyof T[typeof tag]] : T;
|
|
1480
|
-
/**
|
|
1481
|
-
Note: The `Opaque` type is deprecated in favor of `Tagged`.
|
|
1482
|
-
|
|
1483
|
-
Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for runtime values that would otherwise have the same type. (See examples.)
|
|
1484
|
-
|
|
1485
|
-
The generic type parameters can be anything.
|
|
1486
|
-
|
|
1487
|
-
Note that `Opaque` is somewhat of a misnomer here, in that, unlike [some alternative implementations](https://github.com/microsoft/TypeScript/issues/4895#issuecomment-425132582), the original, untagged type is not actually hidden. (E.g., functions that accept the untagged type can still be called with the "opaque" version -- but not vice-versa.)
|
|
1488
|
-
|
|
1489
|
-
Also note that this implementation is limited to a single tag. If you want to allow multiple tags, use `Tagged` instead.
|
|
1490
|
-
|
|
1491
|
-
[Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
|
|
1492
|
-
|
|
1493
|
-
There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
|
|
1494
|
-
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
|
|
1495
|
-
- [Microsoft/TypeScript#15408](https://github.com/Microsoft/TypeScript/issues/15408)
|
|
1496
|
-
- [Microsoft/TypeScript#15807](https://github.com/Microsoft/TypeScript/issues/15807)
|
|
1497
|
-
|
|
1498
|
-
@example
|
|
1499
|
-
```
|
|
1500
|
-
import type {Opaque} from 'type-fest';
|
|
1501
|
-
|
|
1502
|
-
type AccountNumber = Opaque<number, 'AccountNumber'>;
|
|
1503
|
-
type AccountBalance = Opaque<number, 'AccountBalance'>;
|
|
1504
|
-
|
|
1505
|
-
// The `Token` parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
|
|
1506
|
-
type ThingOne = Opaque<string>;
|
|
1507
|
-
type ThingTwo = Opaque<string>;
|
|
1508
|
-
|
|
1509
|
-
// To the compiler, these types are allowed to be cast to each other as they have the same underlying type. They are both `string & { __opaque__: unknown }`.
|
|
1510
|
-
// To avoid this behaviour, you would instead pass the "Token" parameter, like so.
|
|
1511
|
-
type NewThingOne = Opaque<string, 'ThingOne'>;
|
|
1512
|
-
type NewThingTwo = Opaque<string, 'ThingTwo'>;
|
|
1513
|
-
|
|
1514
|
-
// Now they're completely separate types, so the following will fail to compile.
|
|
1515
|
-
function createNewThingOne(): NewThingOne {
|
|
1516
|
-
// As you can see, casting from a string is still allowed. However, you may not cast NewThingOne to NewThingTwo, and vice versa.
|
|
1517
|
-
return 'new thing one' as NewThingOne;
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
// This will fail to compile, as they are fundamentally different types.
|
|
1521
|
-
// @ts-expect-error
|
|
1522
|
-
const thingTwo = createNewThingOne() as NewThingTwo;
|
|
1523
|
-
|
|
1524
|
-
// Here's another example of opaque typing.
|
|
1525
|
-
function createAccountNumber(): AccountNumber {
|
|
1526
|
-
return 2 as AccountNumber;
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
|
|
1530
|
-
|
|
1531
|
-
// This will compile successfully.
|
|
1532
|
-
getMoneyForAccount(createAccountNumber());
|
|
1533
|
-
|
|
1534
|
-
// But this won't, because it has to be explicitly passed as an `AccountNumber` type.
|
|
1535
|
-
// @ts-expect-error
|
|
1536
|
-
getMoneyForAccount(2);
|
|
1537
|
-
|
|
1538
|
-
// You can use opaque values like they aren't opaque too.
|
|
1539
|
-
const accountNumber = createAccountNumber();
|
|
1540
|
-
|
|
1541
|
-
// This will compile successfully.
|
|
1542
|
-
const newAccountNumber = accountNumber + 2;
|
|
1543
|
-
|
|
1544
|
-
// As a side note, you can (and should) use recursive types for your opaque types to make them stronger and hopefully easier to type.
|
|
1545
|
-
type Person = {
|
|
1546
|
-
id: Opaque<number, Person>;
|
|
1547
|
-
name: string;
|
|
1548
|
-
};
|
|
1549
|
-
```
|
|
1550
|
-
|
|
1551
|
-
@category Type
|
|
1552
|
-
@deprecated Use {@link Tagged} instead
|
|
1553
|
-
*/
|
|
1566
|
+
type RemoveAllTags<T> = T extends Tag<PropertyKey, any> ? { [ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]> ? RemoveAllTags<Type> : never; }[keyof T[typeof tag]] : T;
|
|
1554
1567
|
//#endregion
|
|
1555
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1568
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-literal.d.ts
|
|
1556
1569
|
/**
|
|
1557
1570
|
Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
1558
1571
|
|
|
@@ -1609,12 +1622,17 @@ type L2 = Length<`${number}`>;
|
|
|
1609
1622
|
@category Type Guard
|
|
1610
1623
|
@category Utilities
|
|
1611
1624
|
*/
|
|
1612
|
-
type IsStringLiteral<S> = IfNotAnyOrNever<S,
|
|
1613
|
-
|
|
1625
|
+
type IsStringLiteral<S> = IfNotAnyOrNever<S, {
|
|
1626
|
+
ifNot: _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>;
|
|
1627
|
+
ifAny: false;
|
|
1628
|
+
ifNever: false;
|
|
1629
|
+
}>;
|
|
1630
|
+
type _IsStringLiteral<S> =
|
|
1631
|
+
// If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
|
|
1614
1632
|
// and since `{}` extends index signatures, the result becomes `false`.
|
|
1615
1633
|
S extends string ? {} extends Record<S, never> ? false : true : false;
|
|
1616
1634
|
//#endregion
|
|
1617
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1635
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/tuple-of.d.ts
|
|
1618
1636
|
/**
|
|
1619
1637
|
Create a tuple type of the specified length with elements of the specified type.
|
|
1620
1638
|
|
|
@@ -1689,13 +1707,17 @@ Note: If you need a readonly tuple, simply wrap this type with `Readonly`, for e
|
|
|
1689
1707
|
|
|
1690
1708
|
@category Array
|
|
1691
1709
|
*/
|
|
1692
|
-
type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length,
|
|
1710
|
+
type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, {
|
|
1711
|
+
ifNot: _TupleOf<If<IsNegative<Length>, 0, Length>, Fill>;
|
|
1712
|
+
ifAny: Fill[];
|
|
1713
|
+
ifNever: [];
|
|
1714
|
+
}>;
|
|
1693
1715
|
type _TupleOf<Length extends number, Fill> = number extends Length ? Fill[] : BuildTupleDigitByDigit<`${Length}`, Fill>;
|
|
1694
1716
|
type BuildTupleDigitByDigit<Length extends string, Fill, Accumulator extends UnknownArray = []> = Length extends `${infer First extends DigitCharacter}${infer Rest}` ? BuildTupleDigitByDigit<Rest, Fill, [...RepeatTupleTenTimes<Accumulator>, ...DigitTupleOf<First, Fill>]> : Accumulator;
|
|
1695
1717
|
type RepeatTupleTenTimes<Tuple extends UnknownArray> = [...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple];
|
|
1696
1718
|
type DigitTupleOf<Digit extends DigitCharacter, Fill> = [[], [Fill], [Fill, Fill], [Fill, Fill, Fill], [Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill]][Digit];
|
|
1697
1719
|
//#endregion
|
|
1698
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1720
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/simplify.d.ts
|
|
1699
1721
|
/**
|
|
1700
1722
|
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
1701
1723
|
|
|
@@ -1754,9 +1776,9 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
1754
1776
|
@see {@link SimplifyDeep}
|
|
1755
1777
|
@category Object
|
|
1756
1778
|
*/
|
|
1757
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
1779
|
+
type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
1758
1780
|
//#endregion
|
|
1759
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1781
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-equal.d.ts
|
|
1760
1782
|
/**
|
|
1761
1783
|
Returns a boolean for whether the two given types are equal.
|
|
1762
1784
|
|
|
@@ -1787,7 +1809,7 @@ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false
|
|
|
1787
1809
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
1788
1810
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
1789
1811
|
//#endregion
|
|
1790
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1812
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
1791
1813
|
/**
|
|
1792
1814
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
1793
1815
|
|
|
@@ -1879,9 +1901,9 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
1879
1901
|
@see {@link PickIndexSignature}
|
|
1880
1902
|
@category Object
|
|
1881
1903
|
*/
|
|
1882
|
-
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
1904
|
+
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType]; };
|
|
1883
1905
|
//#endregion
|
|
1884
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1906
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
1885
1907
|
/**
|
|
1886
1908
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
1887
1909
|
|
|
@@ -1927,11 +1949,11 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
1927
1949
|
@see {@link OmitIndexSignature}
|
|
1928
1950
|
@category Object
|
|
1929
1951
|
*/
|
|
1930
|
-
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
1952
|
+
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType]; };
|
|
1931
1953
|
//#endregion
|
|
1932
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1954
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/merge.d.ts
|
|
1933
1955
|
// Merges two objects without worrying about index signatures.
|
|
1934
|
-
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
|
|
1956
|
+
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>;
|
|
1935
1957
|
/**
|
|
1936
1958
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
1937
1959
|
|
|
@@ -1995,13 +2017,12 @@ Note: If you want a merge type that more accurately reflects the runtime behavio
|
|
|
1995
2017
|
@category Object
|
|
1996
2018
|
*/
|
|
1997
2019
|
type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
|
|
1998
|
-
? Source extends unknown // For distributing `Source`
|
|
1999
|
-
? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
|
|
2000
|
-
: never;
|
|
2001
|
-
// Should never happen
|
|
2020
|
+
? Source extends unknown // For distributing `Source`
|
|
2021
|
+
? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
|
|
2022
|
+
: never; // Should never happen
|
|
2002
2023
|
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
2003
2024
|
//#endregion
|
|
2004
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2025
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/internal/object.d.ts
|
|
2005
2026
|
/**
|
|
2006
2027
|
Works similar to the built-in `Pick` utility type, except for the following differences:
|
|
2007
2028
|
- Distributes over union types and allows picking keys from any member of the union type.
|
|
@@ -2039,7 +2060,7 @@ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
|
|
|
2039
2060
|
type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
|
|
2040
2061
|
//=> {}
|
|
2041
2062
|
*/
|
|
2042
|
-
type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
|
|
2063
|
+
type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P]; };
|
|
2043
2064
|
/**
|
|
2044
2065
|
Merges user specified options with default options.
|
|
2045
2066
|
|
|
@@ -2092,9 +2113,9 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
2092
2113
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
2093
2114
|
```
|
|
2094
2115
|
*/
|
|
2095
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
2096
|
-
? Result : never;
|
|
2097
|
-
type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key] }>>>;
|
|
2116
|
+
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends (infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
2117
|
+
) ? Result : never;
|
|
2118
|
+
type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key]; }>>>;
|
|
2098
2119
|
/**
|
|
2099
2120
|
Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
|
|
2100
2121
|
|
|
@@ -2122,35 +2143,44 @@ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined
|
|
|
2122
2143
|
//=> string | null | undefined
|
|
2123
2144
|
```
|
|
2124
2145
|
*/
|
|
2125
|
-
type CollapseLiterals<T> = {} extends T ? T : T extends infer U & {} ? U : T;
|
|
2146
|
+
type CollapseLiterals<T> = {} extends T ? T : T extends (infer U) & {} ? U : T;
|
|
2126
2147
|
//#endregion
|
|
2127
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2148
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/some-extend.d.ts
|
|
2128
2149
|
/**
|
|
2129
2150
|
@see {@link SomeExtend}
|
|
2130
2151
|
*/
|
|
2131
2152
|
type SomeExtendOptions = {
|
|
2132
2153
|
/**
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
+
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
2155
|
+
|
|
2156
|
+
- When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
|
|
2157
|
+
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
2158
|
+
|
|
2159
|
+
@default true
|
|
2160
|
+
|
|
2161
|
+
@example
|
|
2162
|
+
```
|
|
2163
|
+
import type {SomeExtend} from 'type-fest';
|
|
2164
|
+
|
|
2165
|
+
type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
|
|
2166
|
+
//=> false
|
|
2167
|
+
|
|
2168
|
+
type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
|
|
2169
|
+
//=> true
|
|
2170
|
+
|
|
2171
|
+
type C = SomeExtend<[1, never], never, {strictNever: true}>;
|
|
2172
|
+
//=> true
|
|
2173
|
+
|
|
2174
|
+
type D = SomeExtend<[1, never], never, {strictNever: false}>;
|
|
2175
|
+
//=> true
|
|
2176
|
+
|
|
2177
|
+
type E = SomeExtend<[never], any, {strictNever: true}>;
|
|
2178
|
+
//=> true
|
|
2179
|
+
|
|
2180
|
+
type F = SomeExtend<[never], any, {strictNever: false}>;
|
|
2181
|
+
//=> true
|
|
2182
|
+
```
|
|
2183
|
+
*/
|
|
2154
2184
|
strictNever?: boolean;
|
|
2155
2185
|
};
|
|
2156
2186
|
type DefaultSomeExtendOptions = {
|
|
@@ -2203,10 +2233,15 @@ type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
|
|
|
2203
2233
|
@category Array
|
|
2204
2234
|
*/
|
|
2205
2235
|
type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOptions = {}> = _SomeExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<SomeExtendOptions, DefaultSomeExtendOptions, Options>>;
|
|
2206
|
-
type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray,
|
|
2207
|
-
|
|
2236
|
+
type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, {
|
|
2237
|
+
ifNot: TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true ?
|
|
2238
|
+
// If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
|
|
2239
|
+
true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false;
|
|
2240
|
+
ifAny: false;
|
|
2241
|
+
ifNever: false;
|
|
2242
|
+
}>;
|
|
2208
2243
|
//#endregion
|
|
2209
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2244
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/or-all.d.ts
|
|
2210
2245
|
/**
|
|
2211
2246
|
Returns a boolean for whether any of the given elements is `true`.
|
|
2212
2247
|
|
|
@@ -2277,7 +2312,7 @@ Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in a
|
|
|
2277
2312
|
*/
|
|
2278
2313
|
type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
|
|
2279
2314
|
//#endregion
|
|
2280
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2315
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/or.d.ts
|
|
2281
2316
|
/**
|
|
2282
2317
|
Returns a boolean for whether either of two given types is `true`.
|
|
2283
2318
|
|
|
@@ -2357,37 +2392,48 @@ type G = Or<never, never>;
|
|
|
2357
2392
|
*/
|
|
2358
2393
|
type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
|
|
2359
2394
|
//#endregion
|
|
2360
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2395
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/all-extend.d.ts
|
|
2361
2396
|
/**
|
|
2362
2397
|
@see {@link AllExtend}
|
|
2363
2398
|
*/
|
|
2364
2399
|
type AllExtendOptions = {
|
|
2365
2400
|
/**
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2401
|
+
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
2402
|
+
|
|
2403
|
+
- When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
|
|
2404
|
+
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
2405
|
+
|
|
2406
|
+
@default true
|
|
2407
|
+
|
|
2408
|
+
@example
|
|
2409
|
+
```
|
|
2410
|
+
import type {AllExtend} from 'type-fest';
|
|
2411
|
+
|
|
2412
|
+
type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
|
|
2413
|
+
//=> false
|
|
2414
|
+
|
|
2415
|
+
type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
|
|
2416
|
+
//=> true
|
|
2417
|
+
|
|
2418
|
+
type C = AllExtend<[never, never], never, {strictNever: true}>;
|
|
2419
|
+
//=> true
|
|
2420
|
+
|
|
2421
|
+
type D = AllExtend<[never, never], never, {strictNever: false}>;
|
|
2422
|
+
//=> true
|
|
2423
|
+
|
|
2424
|
+
type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
|
|
2425
|
+
//=> true
|
|
2426
|
+
|
|
2427
|
+
type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
|
|
2428
|
+
//=> true
|
|
2429
|
+
|
|
2430
|
+
type G = AllExtend<[never, 1], never, {strictNever: true}>;
|
|
2431
|
+
//=> false
|
|
2432
|
+
|
|
2433
|
+
type H = AllExtend<[never, 1], never, {strictNever: false}>;
|
|
2434
|
+
//=> false
|
|
2435
|
+
```
|
|
2436
|
+
*/
|
|
2391
2437
|
strictNever?: boolean;
|
|
2392
2438
|
};
|
|
2393
2439
|
type DefaultAllExtendOptions = {
|
|
@@ -2440,10 +2486,15 @@ type B = AllExtend<[1?, 2?, 3?], number | undefined>;
|
|
|
2440
2486
|
@category Array
|
|
2441
2487
|
*/
|
|
2442
2488
|
type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
|
|
2443
|
-
type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray,
|
|
2444
|
-
|
|
2489
|
+
type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, {
|
|
2490
|
+
ifNot: TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true ?
|
|
2491
|
+
// If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
|
|
2492
|
+
_AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true;
|
|
2493
|
+
ifAny: false;
|
|
2494
|
+
ifNever: false;
|
|
2495
|
+
}>;
|
|
2445
2496
|
//#endregion
|
|
2446
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2497
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/and-all.d.ts
|
|
2447
2498
|
/**
|
|
2448
2499
|
Returns a boolean for whether all of the given elements are `true`.
|
|
2449
2500
|
|
|
@@ -2517,7 +2568,7 @@ Note: `AndAll<[]>` evaluates to `true` due to the concept of [vacuous truth](htt
|
|
|
2517
2568
|
*/
|
|
2518
2569
|
type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;
|
|
2519
2570
|
//#endregion
|
|
2520
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2571
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/and.d.ts
|
|
2521
2572
|
/**
|
|
2522
2573
|
Returns a boolean for whether two given types are both `true`.
|
|
2523
2574
|
|
|
@@ -2597,7 +2648,7 @@ type G = And<never, never>;
|
|
|
2597
2648
|
*/
|
|
2598
2649
|
type And<A extends boolean, B extends boolean> = AndAll<[A, B]>;
|
|
2599
2650
|
//#endregion
|
|
2600
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2651
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/except.d.ts
|
|
2601
2652
|
/**
|
|
2602
2653
|
Filter out keys from an object.
|
|
2603
2654
|
|
|
@@ -2628,10 +2679,12 @@ type Filtered = Filter<'bar', 'foo'>;
|
|
|
2628
2679
|
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
2629
2680
|
type ExceptOptions = {
|
|
2630
2681
|
/**
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2682
|
+
Disallow assigning non-specified properties.
|
|
2683
|
+
|
|
2684
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
2685
|
+
|
|
2686
|
+
@default false
|
|
2687
|
+
*/
|
|
2635
2688
|
requireExactProps?: boolean;
|
|
2636
2689
|
};
|
|
2637
2690
|
type DefaultExceptOptions = {
|
|
@@ -2693,9 +2746,9 @@ type PostPayloadFixed = Except<UserData, 'email'>;
|
|
|
2693
2746
|
@category Object
|
|
2694
2747
|
*/
|
|
2695
2748
|
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
2696
|
-
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
|
|
2749
|
+
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
|
|
2697
2750
|
//#endregion
|
|
2698
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2751
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/exclude-exactly.d.ts
|
|
2699
2752
|
/**
|
|
2700
2753
|
A stricter version of `Exclude<T, U>` that excludes types only when they are exactly identical.
|
|
2701
2754
|
|
|
@@ -2724,16 +2777,24 @@ type TestExcludeExactly3 = ExcludeExactly<{a: string} | {a: string; b: string},
|
|
|
2724
2777
|
|
|
2725
2778
|
@category Improved Built-in
|
|
2726
2779
|
*/
|
|
2727
|
-
type ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Union,
|
|
2728
|
-
|
|
2729
|
-
If
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
Union,
|
|
2780
|
+
type ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Union, {
|
|
2781
|
+
ifNot: _ExcludeExactly<Union, Delete>;
|
|
2782
|
+
// If `Union` is `any`, then if `Delete` is `any`, return `never`, else return `Union`.
|
|
2783
|
+
ifAny: If<IsAny<Delete>, never, Union>;
|
|
2784
|
+
// If `Union` is `never`, then if `Delete` is `never`, return `never`, else return `Union`.
|
|
2785
|
+
ifNever: If<IsNever<Delete>, never, Union>;
|
|
2786
|
+
}>;
|
|
2787
|
+
type _ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Delete, {
|
|
2788
|
+
ifNot: Union extends unknown // For distributing `Union`
|
|
2789
|
+
? [Delete extends unknown // For distributing `Delete`
|
|
2790
|
+
? If<IsEqual<Union, Delete>, true, never> : never] extends [never] ? Union : never : never;
|
|
2791
|
+
// If `Delete` is `any` or `never`, then return `Union`,
|
|
2792
|
+
// because `Union` cannot be `any` or `never` here.
|
|
2793
|
+
ifAny: Union;
|
|
2794
|
+
ifNever: Union;
|
|
2795
|
+
}>;
|
|
2735
2796
|
//#endregion
|
|
2736
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2797
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/union-member.d.ts
|
|
2737
2798
|
/**
|
|
2738
2799
|
Returns an arbitrary member of a union type.
|
|
2739
2800
|
|
|
@@ -2790,7 +2851,7 @@ type LastNever = UnionMember<never>;
|
|
|
2790
2851
|
*/
|
|
2791
2852
|
type UnionMember<T> = IsNever<T> extends true ? never : UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
|
|
2792
2853
|
//#endregion
|
|
2793
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2854
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
2794
2855
|
/**
|
|
2795
2856
|
Convert a union type into an unordered tuple type of its elements.
|
|
2796
2857
|
|
|
@@ -2826,11 +2887,10 @@ const petList = Object.keys(pets) as UnionToTuple<Pet>;
|
|
|
2826
2887
|
|
|
2827
2888
|
@category Array
|
|
2828
2889
|
*/
|
|
2829
|
-
type UnionToTuple<Union> = _UnionToTuple<Union> extends infer Result extends UnknownArray ? Result : never;
|
|
2830
|
-
// Nudges the compiler that `UnionToTuple` always yields an array.
|
|
2890
|
+
type UnionToTuple<Union> = _UnionToTuple<Union> extends (infer Result extends UnknownArray) ? Result : never; // Nudges the compiler that `UnionToTuple` always yields an array.
|
|
2831
2891
|
type _UnionToTuple<Union, Accumulator extends UnknownArray = [], Member = UnionMember<Union>> = IsNever<Union> extends true ? Accumulator : _UnionToTuple<ExcludeExactly<Union, Member>, [Member, ...Accumulator]>;
|
|
2832
2892
|
//#endregion
|
|
2833
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2893
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/set-optional.d.ts
|
|
2834
2894
|
/**
|
|
2835
2895
|
Create a type that makes the given keys optional, while keeping the remaining keys as is.
|
|
2836
2896
|
|
|
@@ -2854,11 +2914,13 @@ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
|
2854
2914
|
*/
|
|
2855
2915
|
type SetOptional<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetOptional<BaseType, Keys>;
|
|
2856
2916
|
type _SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends unknown // To distribute `BaseType` when it's a union type.
|
|
2857
|
-
? Simplify<
|
|
2858
|
-
|
|
2859
|
-
|
|
2917
|
+
? Simplify<
|
|
2918
|
+
// Pick just the keys that are readonly from the base type.
|
|
2919
|
+
Except<BaseType, Keys> &
|
|
2920
|
+
// Pick the keys that should be mutable from the base type and make them mutable.
|
|
2921
|
+
Partial<HomomorphicPick<BaseType, Keys>>> : never;
|
|
2860
2922
|
//#endregion
|
|
2861
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2923
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/value-of.d.ts
|
|
2862
2924
|
/**
|
|
2863
2925
|
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
|
2864
2926
|
|
|
@@ -2882,7 +2944,7 @@ type C = ValueOf<{id: number; name: string; active: boolean}, 'id' | 'name'>;
|
|
|
2882
2944
|
*/
|
|
2883
2945
|
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
2884
2946
|
//#endregion
|
|
2885
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2947
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/split.d.ts
|
|
2886
2948
|
/**
|
|
2887
2949
|
Split options.
|
|
2888
2950
|
|
|
@@ -2890,21 +2952,27 @@ Split options.
|
|
|
2890
2952
|
*/
|
|
2891
2953
|
type SplitOptions = {
|
|
2892
2954
|
/**
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2955
|
+
When enabled, instantiations with non-literal string types (e.g., `string`, `Uppercase<string>`, `on${string}`) simply return back `string[]` without performing any splitting, as the exact structure cannot be statically determined.
|
|
2956
|
+
|
|
2957
|
+
@default true
|
|
2958
|
+
|
|
2959
|
+
@example
|
|
2960
|
+
```ts
|
|
2961
|
+
import type {Split} from 'type-fest';
|
|
2962
|
+
|
|
2963
|
+
type Example1 = Split<`foo.${string}.bar`, '.', {strictLiteralChecks: false}>;
|
|
2964
|
+
//=> ['foo', string, 'bar']
|
|
2965
|
+
|
|
2966
|
+
type Example2 = Split<`foo.${string}`, '.', {strictLiteralChecks: true}>;
|
|
2967
|
+
//=> string[]
|
|
2968
|
+
|
|
2969
|
+
type Example3 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: false}>;
|
|
2970
|
+
//=> ['foo', 'r', 'z']
|
|
2971
|
+
|
|
2972
|
+
type Example4 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: true}>;
|
|
2973
|
+
//=> string[]
|
|
2974
|
+
```
|
|
2975
|
+
*/
|
|
2908
2976
|
strictLiteralChecks?: boolean;
|
|
2909
2977
|
};
|
|
2910
2978
|
type DefaultSplitOptions = {
|
|
@@ -2933,13 +3001,15 @@ const array: Item[] = split(items, ',');
|
|
|
2933
3001
|
*/
|
|
2934
3002
|
type Split<S extends string, Delimiter extends string, Options extends SplitOptions = {}> = SplitHelper<S, Delimiter, ApplyDefaultOptions<SplitOptions, DefaultSplitOptions, Options>>;
|
|
2935
3003
|
type SplitHelper<S extends string, Delimiter extends string, Options extends Required<SplitOptions>, Accumulator extends string[] = []> = S extends string // For distributing `S`
|
|
2936
|
-
? Delimiter extends string // For distributing `Delimiter`
|
|
3004
|
+
? Delimiter extends string // For distributing `Delimiter`
|
|
3005
|
+
?
|
|
2937
3006
|
// If `strictLiteralChecks` is `false` OR `S` and `Delimiter` both are string literals, then perform the split
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
: never
|
|
3007
|
+
Or<Not<Options['strictLiteralChecks']>, And<IsStringLiteral<S>, IsStringLiteral<Delimiter>>> extends true ? S extends `${infer Head}${Delimiter}${infer Tail}` ? SplitHelper<Tail, Delimiter, Options, [...Accumulator, Head]> : Delimiter extends '' ? S extends '' ? Accumulator : [...Accumulator, S] : [...Accumulator, S] :
|
|
3008
|
+
// Otherwise, return `string[]`
|
|
3009
|
+
string[] : never // Should never happen
|
|
3010
|
+
: never; // Should never happen
|
|
2941
3011
|
//#endregion
|
|
2942
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
3012
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/replace.d.ts
|
|
2943
3013
|
type ReplaceOptions = {
|
|
2944
3014
|
all?: boolean;
|
|
2945
3015
|
};
|
|
@@ -3001,8 +3071,8 @@ replaceAll('My Cool Title', ' ', '');
|
|
|
3001
3071
|
*/
|
|
3002
3072
|
type Replace<Input extends string, Search extends string, Replacement extends string, Options extends ReplaceOptions = {}> = _Replace<Input, Search, Replacement, ApplyDefaultOptions<ReplaceOptions, DefaultReplaceOptions, Options>>;
|
|
3003
3073
|
type _Replace<Input extends string, Search extends string, Replacement extends string, Options extends Required<ReplaceOptions>, Accumulator extends string = ''> = Search extends string // For distributing `Search`
|
|
3004
|
-
? Replacement extends string // For distributing `Replacement`
|
|
3005
|
-
? Input extends `${infer Head}${Search}${infer Tail}` ? Options['all'] extends true ? _Replace<Tail, Search, Replacement, Options, `${Accumulator}${Head}${Replacement}`> : `${Head}${Replacement}${Tail}` : `${Accumulator}${Input}` : never : never;
|
|
3074
|
+
? Replacement extends string // For distributing `Replacement`
|
|
3075
|
+
? Input extends `${infer Head}${Search}${infer Tail}` ? Options['all'] extends true ? _Replace<Tail, Search, Replacement, Options, `${Accumulator}${Head}${Replacement}`> : `${Head}${Replacement}${Tail}` : `${Accumulator}${Input}` : never : never;
|
|
3006
3076
|
//#endregion
|
|
3007
3077
|
//#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/List.d.ts
|
|
3008
3078
|
/**
|
|
@@ -3345,7 +3415,7 @@ declare type Tail$1<L extends List> = L extends readonly [] ? L : L extends read
|
|
|
3345
3415
|
* ```ts
|
|
3346
3416
|
* ```
|
|
3347
3417
|
*/
|
|
3348
|
-
declare type Overwrite<O extends object, O1 extends object> = { [K in keyof O]: K extends keyof O1 ? O1[K] : O[K] } & {};
|
|
3418
|
+
declare type Overwrite<O extends object, O1 extends object> = { [K in keyof O]: K extends keyof O1 ? O1[K] : O[K]; } & {};
|
|
3349
3419
|
//#endregion
|
|
3350
3420
|
//#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/_Internal.d.ts
|
|
3351
3421
|
/**
|
|
@@ -3414,7 +3484,7 @@ declare type __Drop<L extends List, N extends Iteration, way extends Way> = {
|
|
|
3414
3484
|
/**
|
|
3415
3485
|
* @hidden
|
|
3416
3486
|
*/
|
|
3417
|
-
declare type _Drop<L extends List, N extends number, way extends Way = '->'> = __Drop<Naked<L>, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
|
|
3487
|
+
declare type _Drop<L extends List, N extends number, way extends Way = '->'> = __Drop<Naked<L>, IterationOf<N>, way> extends (infer X) ? Cast<X, List> : never;
|
|
3418
3488
|
/**
|
|
3419
3489
|
* Remove `N` entries out of `L`
|
|
3420
3490
|
* @param L to remove from
|
|
@@ -3454,7 +3524,7 @@ declare type __Take<L extends List, N extends Iteration, way extends Way> = {
|
|
|
3454
3524
|
/**
|
|
3455
3525
|
* @hidden
|
|
3456
3526
|
*/
|
|
3457
|
-
declare type _Take<L extends List, N extends number, way extends Way = '->'> = __Take<L, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
|
|
3527
|
+
declare type _Take<L extends List, N extends number, way extends Way = '->'> = __Take<L, IterationOf<N>, way> extends (infer X) ? Cast<X, List> : never;
|
|
3458
3528
|
/**
|
|
3459
3529
|
* Extract `N` entries out of `L`
|
|
3460
3530
|
* @param L to extract from
|
|
@@ -3470,16 +3540,16 @@ declare type Take<L extends List, N extends number, way extends Way = '->'> = L
|
|
|
3470
3540
|
//#region src/object/index.type.d.ts
|
|
3471
3541
|
type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
|
|
3472
3542
|
type AnyArray<A = any> = readonly A[];
|
|
3473
|
-
type TupleToEntries<A extends readonly unknown[]> = If<IsAny<A>, unknown, { [Key in keyof A]: [Key, A[Key]] }>;
|
|
3543
|
+
type TupleToEntries<A extends readonly unknown[]> = If<IsAny<A>, unknown, { [Key in keyof A]: [Key, A[Key]]; }>;
|
|
3474
3544
|
type Groups<L extends AnyArray, LN extends AnyArray = [], D extends number[] = []> = D["length"] extends 40 ? LN : {
|
|
3475
3545
|
0: Groups<Drop<L, 1>, Append<LN, [`${LN["length"]}`, Take<L, 1>]>, [...D, 0]>;
|
|
3476
3546
|
1: LN;
|
|
3477
3547
|
}[Extends<L, AnyArray<never>>];
|
|
3478
|
-
type TupleToGroups<L extends AnyArray> = Groups<L> extends infer X ? Cast<X, AnyArray> : never;
|
|
3479
|
-
type Crush<T> = T extends readonly (infer U)[] ? Record<string, U extends object ? unknown : U> : Simplify<UnionToIntersection<keyof T extends infer Prop ? Prop extends keyof T ? T[Prop] extends infer Value ? ([Extract<Value, object>] extends [never] ? never : Record<string, unknown>) | ([Exclude<Value, object>] extends [never] ? never : [Extract<Value, object>] extends [never] ? { [P in Prop]: Value } : Record<string, unknown>) : never : never : never>>;
|
|
3548
|
+
type TupleToGroups<L extends AnyArray> = Groups<L> extends (infer X) ? Cast<X, AnyArray> : never;
|
|
3549
|
+
type Crush<T> = T extends readonly (infer U)[] ? Record<string, U extends object ? unknown : U> : Simplify<UnionToIntersection<keyof T extends (infer Prop) ? Prop extends keyof T ? T[Prop] extends (infer Value) ? ([Extract<Value, object>] extends [never] ? never : Record<string, unknown>) | ([Exclude<Value, object>] extends [never] ? never : [Extract<Value, object>] extends [never] ? { [P in Prop]: Value; } : Record<string, unknown>) : never : never : never>>;
|
|
3480
3550
|
type IntersectOf<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
3481
|
-
type ComputeRaw<A> = A extends AnyFunction ? A : { [K in keyof A]: A[K] } & unknown;
|
|
3482
|
-
type _Invert<O extends Record<PropertyKey, PropertyKey>> = ComputeRaw<IntersectOf<{ [K in keyof O]: Record<O[K], K
|
|
3551
|
+
type ComputeRaw<A> = A extends AnyFunction ? A : { [K in keyof A]: A[K]; } & unknown;
|
|
3552
|
+
type _Invert<O extends Record<PropertyKey, PropertyKey>> = ComputeRaw<IntersectOf<{ [K in keyof O]: Record<O[K], K>; }[keyof O]>>;
|
|
3483
3553
|
type Invert<O extends Record<keyof O, PropertyKey>> = O extends unknown ? _Invert<O> : never;
|
|
3484
3554
|
//#endregion
|
|
3485
3555
|
//#region src/object/objectUtil.d.ts
|
|
@@ -4371,6 +4441,21 @@ declare class TypeUtil {
|
|
|
4371
4441
|
* ```
|
|
4372
4442
|
*/
|
|
4373
4443
|
static isPlainObject(value: unknown, prototypeCheck?: boolean): value is Record<PropertyKey, unknown>;
|
|
4444
|
+
/**
|
|
4445
|
+
* 判断是否为广义对象类型
|
|
4446
|
+
*
|
|
4447
|
+
* @param value 待检查值
|
|
4448
|
+
* @returns 是否为对象
|
|
4449
|
+
* @example
|
|
4450
|
+
* ```ts
|
|
4451
|
+
* TypeUtil.isObject({}); // true
|
|
4452
|
+
* TypeUtil.isObject([]); // true
|
|
4453
|
+
* TypeUtil.isObject(new Date()); // true
|
|
4454
|
+
* TypeUtil.isObject(null); // false
|
|
4455
|
+
* TypeUtil.isObject("string"); // false
|
|
4456
|
+
* ```
|
|
4457
|
+
*/
|
|
4458
|
+
static isObject(value: unknown): value is object;
|
|
4374
4459
|
/**
|
|
4375
4460
|
* 判断一个对象是否为有效的枚举
|
|
4376
4461
|
* - 枚举成员不能为空
|