@pawover/kit 0.2.1 → 0.3.0
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 +14 -14
- package/packages/hooks/dist/alova.d.ts +7 -4
- package/packages/hooks/dist/alova.js +13 -27
- package/packages/hooks/dist/react.d.ts +1 -3
- package/packages/hooks/dist/react.js +34 -34
- package/packages/utils/dist/index.d.ts +463 -351
- package/packages/utils/dist/index.js +82 -40
- package/packages/utils/dist/math.d.ts +0 -1
- 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
|
/**
|
|
@@ -695,97 +694,225 @@ declare class FunctionUtil {
|
|
|
695
694
|
*/
|
|
696
695
|
declare class MimeUtil {
|
|
697
696
|
/**
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*/
|
|
701
|
-
static readonly
|
|
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
|
-
|
|
697
|
+
* 文件类型 MIME 常量
|
|
698
|
+
* - 每个类型对应具体的文件扩展名
|
|
699
|
+
*/
|
|
700
|
+
static readonly FILE_MIME: {
|
|
701
|
+
/** 普通文本文件(.txt) */
|
|
702
|
+
readonly TEXT: "text/plain";
|
|
703
|
+
/** 超文本标记语言文档(.html/.htm) */
|
|
704
|
+
readonly HTML: "text/html";
|
|
705
|
+
/** 层叠样式表文件(.css) */
|
|
706
|
+
readonly CSS: "text/css";
|
|
707
|
+
/** 逗号分隔值文件/表格数据(.csv) */
|
|
708
|
+
readonly CSV: "text/csv";
|
|
709
|
+
/** 制表符分隔值文件(.tsv) */
|
|
710
|
+
readonly TSV: "text/tab-separated-values";
|
|
711
|
+
/** XML 文档(.xml) */
|
|
712
|
+
readonly XML: "application/xml";
|
|
713
|
+
/** XML 文档/兼容值 */
|
|
714
|
+
readonly XML_TEXT: "text/xml";
|
|
715
|
+
/** XHTML 文档(.xhtml/.xht) */
|
|
716
|
+
readonly XHTML: "application/xhtml+xml";
|
|
717
|
+
/** JavaScript 文件(.js) */
|
|
718
|
+
readonly JS: "text/javascript";
|
|
719
|
+
/** TypeScript 文件(.ts) */
|
|
720
|
+
readonly TS: "text/typescript";
|
|
721
|
+
/** Python 文件(.py) */
|
|
722
|
+
readonly PY: "text/x-python";
|
|
723
|
+
/** Shell 脚本 (.sh) */
|
|
724
|
+
readonly SH: "text/x-sh";
|
|
725
|
+
/** C 语言源文件(.c) */
|
|
726
|
+
readonly C: "text/x-c";
|
|
727
|
+
/** C++ 源文件(.cpp/.cc/.cxx) */
|
|
728
|
+
readonly CPP: "text/x-c++";
|
|
729
|
+
/** C# 源文件(.cs) */
|
|
730
|
+
readonly CSHARP: "text/x-csharp";
|
|
731
|
+
/** Java 源文件(.java) */
|
|
732
|
+
readonly JAVA: "text/x-java";
|
|
733
|
+
/** Go 源文件(.go) */
|
|
734
|
+
readonly GO: "text/x-go";
|
|
735
|
+
/** Rust 源文件(.rs) */
|
|
736
|
+
readonly RUST: "text/x-rust";
|
|
737
|
+
/** PHP 文件(.php) */
|
|
738
|
+
readonly PHP: "text/x-php";
|
|
739
|
+
/** Ruby 文件(.rb) */
|
|
740
|
+
readonly RUBY: "text/x-ruby";
|
|
741
|
+
/** Swift 源文件(.swift) */
|
|
742
|
+
readonly SWIFT: "text/x-swift";
|
|
743
|
+
/** YAML 文档(.yaml/.yml) */
|
|
744
|
+
readonly YAML: "application/yaml";
|
|
745
|
+
/** YAML 文档/兼容值 */
|
|
746
|
+
readonly YAML_TEXT: "text/vnd.yaml";
|
|
747
|
+
/** TOML 文档(.toml) */
|
|
748
|
+
readonly TOML: "application/toml";
|
|
749
|
+
/** TOML 文档/兼容值 */
|
|
750
|
+
readonly TOML_TEXT: "text/x-toml";
|
|
751
|
+
/** SQL 脚本(.sql) */
|
|
752
|
+
readonly SQL: "application/sql";
|
|
753
|
+
/** SQL 脚本/兼容值 */
|
|
754
|
+
readonly SQL_TEXT: "text/x-sql";
|
|
755
|
+
/** Markdown 格式文档(.md/.markdown) */
|
|
756
|
+
readonly MARKDOWN: "text/markdown";
|
|
757
|
+
/** 富文本格式文档(.rtf) */
|
|
758
|
+
readonly RTF: "application/rtf";
|
|
759
|
+
/** iCalendar 日历格式(.ics) */
|
|
760
|
+
readonly CALENDAR: "text/calendar";
|
|
761
|
+
/** JPEG 图像(.jpg/.jpeg) */
|
|
762
|
+
readonly JPEG: "image/jpeg";
|
|
763
|
+
/** JPG 图像(JPEG 别名,.jpg) */
|
|
764
|
+
readonly JPG: "image/jpeg";
|
|
765
|
+
/** PNG 图像/无损压缩,支持透明(.png) */
|
|
766
|
+
readonly PNG: "image/png";
|
|
767
|
+
/** GIF 图像/支持动画(.gif) */
|
|
768
|
+
readonly GIF: "image/gif";
|
|
769
|
+
/** Windows 位图(.bmp) */
|
|
770
|
+
readonly BMP: "image/bmp";
|
|
771
|
+
/** SVG 向量图形(.svg) */
|
|
772
|
+
readonly SVG: "image/svg+xml";
|
|
773
|
+
/** APNG 动态图像(.apng) */
|
|
774
|
+
readonly APNG: "image/apng";
|
|
775
|
+
/** AVIF 图像/高效压缩(.avif) */
|
|
776
|
+
readonly AVIF: "image/avif";
|
|
777
|
+
/** 图标文件格式(.ico) */
|
|
778
|
+
readonly ICO: "image/vnd.microsoft.icon";
|
|
779
|
+
/** WebP 图像/高效压缩(.webp) */
|
|
780
|
+
readonly WEBP: "image/webp";
|
|
781
|
+
/** TIFF 图像(.tif/.tiff) */
|
|
782
|
+
readonly TIFF: "image/tiff";
|
|
783
|
+
/** HEIC 图像/高效编码(.heic) */
|
|
784
|
+
readonly HEIC: "image/heic";
|
|
785
|
+
/** HEIF 图像/高效编码(.heif) */
|
|
786
|
+
readonly HEIF: "image/heif";
|
|
787
|
+
/** Adobe Photoshop 文件(.psd) */
|
|
788
|
+
readonly PSD: "image/vnd.adobe.photoshop";
|
|
789
|
+
/** MP3 音频(.mp3) */
|
|
790
|
+
readonly MP3: "audio/mpeg";
|
|
791
|
+
/** AAC 音频(.aac) */
|
|
792
|
+
readonly AAC: "audio/aac";
|
|
793
|
+
/** MIDI 音乐文件(.mid/.midi) */
|
|
794
|
+
readonly MIDI: "audio/midi";
|
|
795
|
+
/** OGG 音频(.oga) */
|
|
796
|
+
readonly OGG_AUDIO: "audio/ogg";
|
|
797
|
+
/** Opus 音频(.opus) */
|
|
798
|
+
readonly OPUS: "audio/opus";
|
|
799
|
+
/** FLAC 无损音频(.flac) */
|
|
800
|
+
readonly FLAC: "audio/flac";
|
|
801
|
+
/** WAV 音频(.wav) */
|
|
802
|
+
readonly WAV: "audio/wav";
|
|
803
|
+
/** WebM 音频(.weba) */
|
|
804
|
+
readonly WEBM_AUDIO: "audio/webm";
|
|
805
|
+
/** RealAudio 音频(.ra/.ram) */
|
|
806
|
+
readonly REAL_AUDIO: "audio/x-pn-realaudio";
|
|
807
|
+
/** MP4 视频(.mp4) */
|
|
808
|
+
readonly MP4: "video/mp4";
|
|
809
|
+
/** MPEG 视频(.mpeg/.mpg) */
|
|
810
|
+
readonly MPEG: "video/mpeg";
|
|
811
|
+
/** OGG 视频(.ogv) */
|
|
812
|
+
readonly OGG_VIDEO: "video/ogg";
|
|
813
|
+
/** AVI 视频(.avi) */
|
|
814
|
+
readonly AVI: "video/x-msvideo";
|
|
815
|
+
/** 3GPP 视频(.3gp) */
|
|
816
|
+
readonly THREE_GPP: "video/3gpp";
|
|
817
|
+
/** 3GPP2 视频(.3g2) */
|
|
818
|
+
readonly THREE_GPP2: "video/3gpp2";
|
|
819
|
+
/** WebM 视频(.webm) */
|
|
820
|
+
readonly WEBM: "video/webm";
|
|
821
|
+
/** QuickTime 视频(.mov) */
|
|
822
|
+
readonly QUICKTIME: "video/quicktime";
|
|
823
|
+
/** PDF 文档(.pdf) */
|
|
824
|
+
readonly PDF: "application/pdf";
|
|
825
|
+
/** Word 97-2003 文档(.doc) */
|
|
826
|
+
readonly DOC: "application/msword";
|
|
827
|
+
/** Word 2007+ 文档(.docx) */
|
|
828
|
+
readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
829
|
+
/** Excel 2007+ 工作簿(.xlsx) */
|
|
830
|
+
readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
831
|
+
/** 启用宏的Excel工作簿(.xlsm) */
|
|
832
|
+
readonly XLSM: "application/vnd.ms-excel.sheet.macroEnabled.12";
|
|
833
|
+
/** Excel模板文件(.xltx) */
|
|
834
|
+
readonly XLTX: "application/vnd.openxmlformats-officedocument.spreadsheetml.template";
|
|
835
|
+
/** PowerPoint 2007+ 演示文稿(.pptx) */
|
|
836
|
+
readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
837
|
+
/** PowerPoint 97-2003 演示文稿(.ppt) */
|
|
838
|
+
readonly PPT: "application/vnd.ms-powerpoint";
|
|
839
|
+
/** OpenDocument 文本文档(.odt) */
|
|
840
|
+
readonly ODT: "application/vnd.oasis.opendocument.text";
|
|
841
|
+
/** OpenDocument 表格文档(.ods) */
|
|
842
|
+
readonly ODS: "application/vnd.oasis.opendocument.spreadsheet";
|
|
843
|
+
/** OpenDocument 演示文稿(.odp) */
|
|
844
|
+
readonly ODP: "application/vnd.oasis.opendocument.presentation";
|
|
845
|
+
/** EPUB 电子书(.epub) */
|
|
846
|
+
readonly EPUB: "application/epub+zip";
|
|
847
|
+
/** Kindle 电子书(.azw) */
|
|
848
|
+
readonly AZW: "application/vnd.amazon.ebook";
|
|
849
|
+
/** ZIP 压缩文件(.zip) */
|
|
850
|
+
readonly ZIP: "application/zip";
|
|
851
|
+
/** GZIP 压缩文件(.gz) */
|
|
852
|
+
readonly GZIP: "application/gzip";
|
|
853
|
+
/** TAR 归档文件(.tar) */
|
|
854
|
+
readonly TAR: "application/x-tar";
|
|
855
|
+
/** BZip 归档(.bz) */
|
|
856
|
+
readonly BZIP: "application/x-bzip";
|
|
857
|
+
/** BZip2 归档(.bz2) */
|
|
858
|
+
readonly BZIP2: "application/x-bzip2";
|
|
859
|
+
/** 7-Zip 压缩文件(.7z) */
|
|
860
|
+
readonly SEVEN_Z: "application/x-7z-compressed";
|
|
861
|
+
/** RAR 压缩文件(.rar) */
|
|
862
|
+
readonly RAR: "application/vnd.rar";
|
|
863
|
+
/** XZ 压缩文件(.xz) */
|
|
864
|
+
readonly XZ: "application/x-xz";
|
|
865
|
+
/** Zstandard 压缩文件(.zst) */
|
|
866
|
+
readonly ZSTD: "application/zstd";
|
|
867
|
+
/** ISO 光盘镜像(.iso) */
|
|
868
|
+
readonly ISO9660_IMAGE: "application/x-iso9660-image";
|
|
869
|
+
/** JSON 数据格式(.json) */
|
|
870
|
+
readonly JSON: "application/json";
|
|
871
|
+
/** JSON-LD 格式(.jsonld) */
|
|
872
|
+
readonly LD_JSON: "application/ld+json";
|
|
873
|
+
/** Web App Manifest(.webmanifest) */
|
|
874
|
+
readonly MANIFEST: "application/manifest+json";
|
|
875
|
+
/** Java 归档文件(.jar) */
|
|
876
|
+
readonly JAR: "application/java-archive";
|
|
877
|
+
/** WebAssembly 二进制指令格式(.wasm) */
|
|
878
|
+
readonly WASM: "application/wasm";
|
|
879
|
+
/** MS 嵌入式 OpenType 字体(.eot) */
|
|
880
|
+
readonly EOT: "application/vnd.ms-fontobject";
|
|
881
|
+
/** OpenType 字体(.otf) */
|
|
882
|
+
readonly OTF: "font/otf";
|
|
883
|
+
/** WOFF 字体(.woff) */
|
|
884
|
+
readonly WOFF: "font/woff";
|
|
885
|
+
/** WOFF2 字体(.woff2) */
|
|
886
|
+
readonly WOFF2: "font/woff2";
|
|
887
|
+
/** TrueType 字体(.ttf) */
|
|
888
|
+
readonly TTF: "font/ttf";
|
|
889
|
+
/** Excel 97-2003 工作簿(.xls) */
|
|
890
|
+
readonly XLS: "application/vnd.ms-excel";
|
|
891
|
+
/** Microsoft XPS 文档(.xps) */
|
|
892
|
+
readonly XPS: "application/vnd.ms-xpsdocument";
|
|
893
|
+
/** Word 启用宏文档(.docm) */
|
|
787
894
|
readonly DOCM: "application/vnd.ms-word.document.macroEnabled.12";
|
|
788
895
|
};
|
|
896
|
+
/**
|
|
897
|
+
* 协议/内容类型 MIME 常量
|
|
898
|
+
* - 用于 HTTP 请求/响应内容协商,无对应文件扩展名
|
|
899
|
+
*/
|
|
900
|
+
static readonly PROTOCOL_MIME: {
|
|
901
|
+
/** 通用二进制数据流 */
|
|
902
|
+
readonly OCTET_STREAM: "application/octet-stream";
|
|
903
|
+
/** URL 编码表单 */
|
|
904
|
+
readonly FORM_URLENCODED: "application/x-www-form-urlencoded";
|
|
905
|
+
/** multipart 表单 */
|
|
906
|
+
readonly FORM_DATA: "multipart/form-data";
|
|
907
|
+
/** Server-Sent Events 数据流 */
|
|
908
|
+
readonly EVENT_STREAM: "text/event-stream";
|
|
909
|
+
/** 问题详情 JSON(RFC 9457) */
|
|
910
|
+
readonly PROBLEM_JSON: "application/problem+json";
|
|
911
|
+
/** JSON Patch(RFC 6902) */
|
|
912
|
+
readonly JSON_PATCH: "application/json-patch+json";
|
|
913
|
+
/** JSON Merge Patch(RFC 7386) */
|
|
914
|
+
readonly MERGE_PATCH_JSON: "application/merge-patch+json";
|
|
915
|
+
};
|
|
789
916
|
}
|
|
790
917
|
//#endregion
|
|
791
918
|
//#region src/number/numberUtil.d.ts
|
|
@@ -810,7 +937,7 @@ declare class NumberUtil {
|
|
|
810
937
|
static within(input: number, interval: [number, number], includeLeft?: boolean, includeRight?: boolean): boolean;
|
|
811
938
|
}
|
|
812
939
|
//#endregion
|
|
813
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
940
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/typed-array.d.ts
|
|
814
941
|
/**
|
|
815
942
|
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
|
816
943
|
|
|
@@ -818,7 +945,7 @@ Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScrip
|
|
|
818
945
|
*/
|
|
819
946
|
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
820
947
|
//#endregion
|
|
821
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
948
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/characters.d.ts
|
|
822
949
|
/**
|
|
823
950
|
Matches any digit as a string ('0'-'9').
|
|
824
951
|
|
|
@@ -835,7 +962,7 @@ const b: DigitCharacter = 0; // Invalid
|
|
|
835
962
|
*/
|
|
836
963
|
type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
837
964
|
//#endregion
|
|
838
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
965
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
839
966
|
/**
|
|
840
967
|
Convert a union type to an intersection type.
|
|
841
968
|
|
|
@@ -853,18 +980,23 @@ type Intersection = UnionToIntersection<Union>;
|
|
|
853
980
|
|
|
854
981
|
@category Type
|
|
855
982
|
*/
|
|
856
|
-
type UnionToIntersection<Union> = (
|
|
983
|
+
type UnionToIntersection<Union> = (
|
|
984
|
+
// `extends unknown` is always going to be the case and is used to convert the
|
|
857
985
|
// `Union` into a [distributive conditional
|
|
858
986
|
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
859
|
-
Union extends unknown
|
|
987
|
+
Union extends unknown ?
|
|
988
|
+
// The union type is used as the only argument to a function since the union
|
|
860
989
|
// of function arguments is an intersection.
|
|
861
|
-
|
|
862
|
-
|
|
990
|
+
(distributedUnion: Union) => void :
|
|
991
|
+
// This won't happen.
|
|
992
|
+
never
|
|
993
|
+
// Infer the `Intersection` type since TypeScript represents the positional
|
|
863
994
|
// arguments of unions of functions as an intersection of the union.
|
|
864
|
-
) extends ((mergedIntersection: infer Intersection) => void)
|
|
865
|
-
|
|
995
|
+
) extends ((mergedIntersection: infer Intersection) => void) ?
|
|
996
|
+
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
997
|
+
Intersection & Union : never;
|
|
866
998
|
//#endregion
|
|
867
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
999
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/keys-of-union.d.ts
|
|
868
1000
|
/**
|
|
869
1001
|
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
870
1002
|
|
|
@@ -902,10 +1034,11 @@ type AllKeys = KeysOfUnion<Union>;
|
|
|
902
1034
|
|
|
903
1035
|
@category Object
|
|
904
1036
|
*/
|
|
905
|
-
type KeysOfUnion<ObjectType> =
|
|
1037
|
+
type KeysOfUnion<ObjectType> =
|
|
1038
|
+
// Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
|
|
906
1039
|
keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
907
1040
|
//#endregion
|
|
908
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1041
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-any.d.ts
|
|
909
1042
|
/**
|
|
910
1043
|
Returns a boolean for whether the given type is `any`.
|
|
911
1044
|
|
|
@@ -936,7 +1069,7 @@ const anyA = get(anyObject, 'a');
|
|
|
936
1069
|
*/
|
|
937
1070
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
938
1071
|
//#endregion
|
|
939
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1072
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
940
1073
|
/**
|
|
941
1074
|
Returns a boolean for whether the given key is an optional key of type.
|
|
942
1075
|
|
|
@@ -979,7 +1112,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
979
1112
|
*/
|
|
980
1113
|
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
1114
|
//#endregion
|
|
982
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1115
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
983
1116
|
/**
|
|
984
1117
|
Extract all optional keys from the given type.
|
|
985
1118
|
|
|
@@ -1014,10 +1147,10 @@ const update2: UpdateOperation<User> = {
|
|
|
1014
1147
|
@category Utilities
|
|
1015
1148
|
*/
|
|
1016
1149
|
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;
|
|
1150
|
+
? (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`
|
|
1151
|
+
: never; // Should never happen
|
|
1019
1152
|
//#endregion
|
|
1020
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1153
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
1021
1154
|
/**
|
|
1022
1155
|
Extract all required keys from the given type.
|
|
1023
1156
|
|
|
@@ -1049,9 +1182,9 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
|
1049
1182
|
@category Utilities
|
|
1050
1183
|
*/
|
|
1051
1184
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
1052
|
-
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
1185
|
+
? Exclude<keyof Type, OptionalKeysOf<Type>> : never; // Should never happen
|
|
1053
1186
|
//#endregion
|
|
1054
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1187
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-never.d.ts
|
|
1055
1188
|
/**
|
|
1056
1189
|
Returns a boolean for whether the given type is `never`.
|
|
1057
1190
|
|
|
@@ -1107,7 +1240,7 @@ type B = IsTrueFixed<never>;
|
|
|
1107
1240
|
*/
|
|
1108
1241
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
1109
1242
|
//#endregion
|
|
1110
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1243
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/if.d.ts
|
|
1111
1244
|
/**
|
|
1112
1245
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
1113
1246
|
|
|
@@ -1202,7 +1335,7 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
1202
1335
|
*/
|
|
1203
1336
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
1204
1337
|
//#endregion
|
|
1205
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1338
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/unknown-array.d.ts
|
|
1206
1339
|
/**
|
|
1207
1340
|
Represents an array with `unknown` value.
|
|
1208
1341
|
|
|
@@ -1229,7 +1362,7 @@ type C = IsArray<string>;
|
|
|
1229
1362
|
*/
|
|
1230
1363
|
type UnknownArray = readonly unknown[];
|
|
1231
1364
|
//#endregion
|
|
1232
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1365
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/internal/type.d.ts
|
|
1233
1366
|
/**
|
|
1234
1367
|
Returns a boolean for whether A is false.
|
|
1235
1368
|
|
|
@@ -1248,16 +1381,16 @@ An if-else-like type that resolves depending on whether the given type is `any`
|
|
|
1248
1381
|
|
|
1249
1382
|
@example
|
|
1250
1383
|
```
|
|
1251
|
-
// When `T` is
|
|
1252
|
-
type A = IfNotAnyOrNever<string, 'VALID'
|
|
1384
|
+
// When `T` is neither `any` nor `never` (like `string`) => Returns `IfNot` branch
|
|
1385
|
+
type A = IfNotAnyOrNever<string, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
|
|
1253
1386
|
//=> 'VALID'
|
|
1254
1387
|
|
|
1255
1388
|
// When `T` is `any` => Returns `IfAny` branch
|
|
1256
|
-
type B = IfNotAnyOrNever<any, 'VALID'
|
|
1389
|
+
type B = IfNotAnyOrNever<any, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
|
|
1257
1390
|
//=> 'IS_ANY'
|
|
1258
1391
|
|
|
1259
1392
|
// When `T` is `never` => Returns `IfNever` branch
|
|
1260
|
-
type C = IfNotAnyOrNever<never, 'VALID'
|
|
1393
|
+
type C = IfNotAnyOrNever<never, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
|
|
1261
1394
|
//=> 'IS_NEVER'
|
|
1262
1395
|
```
|
|
1263
1396
|
|
|
@@ -1270,7 +1403,7 @@ import type {StringRepeat} from 'type-fest';
|
|
|
1270
1403
|
type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
|
|
1271
1404
|
|
|
1272
1405
|
// The following implementation is not tail recursive
|
|
1273
|
-
type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
|
|
1406
|
+
type TrimLeft<S extends string> = IfNotAnyOrNever<S, {ifNot: S extends ` ${infer R}` ? TrimLeft<R> : S}>;
|
|
1274
1407
|
|
|
1275
1408
|
// Hence, instantiations with long strings will fail
|
|
1276
1409
|
// @ts-expect-error
|
|
@@ -1279,7 +1412,7 @@ type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
|
|
|
1279
1412
|
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
1280
1413
|
|
|
1281
1414
|
// To fix this, move the recursion into a helper type
|
|
1282
|
-
type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S
|
|
1415
|
+
type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, {ifNot: _TrimLeftOptimised<S>}>;
|
|
1283
1416
|
|
|
1284
1417
|
type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
|
|
1285
1418
|
|
|
@@ -1287,13 +1420,17 @@ type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
|
|
|
1287
1420
|
//=> ''
|
|
1288
1421
|
```
|
|
1289
1422
|
*/
|
|
1290
|
-
type IfNotAnyOrNever<T,
|
|
1423
|
+
type IfNotAnyOrNever<T, Cases extends {
|
|
1424
|
+
ifNot: unknown;
|
|
1425
|
+
ifAny?: unknown;
|
|
1426
|
+
ifNever?: unknown;
|
|
1427
|
+
}> = 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
1428
|
/**
|
|
1292
1429
|
Indicates the value of `exactOptionalPropertyTypes` compiler option.
|
|
1293
1430
|
*/
|
|
1294
1431
|
type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
|
|
1295
1432
|
//#endregion
|
|
1296
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1433
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/internal/array.d.ts
|
|
1297
1434
|
/**
|
|
1298
1435
|
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
1436
|
|
|
@@ -1325,31 +1462,23 @@ type B = CollapseRestElement<[string?, string?, ...number[]]>;
|
|
|
1325
1462
|
//=> [string | undefined, string | undefined, number]
|
|
1326
1463
|
```
|
|
1327
1464
|
*/
|
|
1328
|
-
type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray,
|
|
1465
|
+
type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, {
|
|
1466
|
+
ifNot: _CollapseRestElement<TArray>;
|
|
1467
|
+
}>;
|
|
1329
1468
|
type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
|
|
1330
|
-
? keyof TArray & `${number}` extends never
|
|
1469
|
+
? keyof TArray & `${number}` extends never ?
|
|
1470
|
+
// Enters this branch, if `TArray` is empty (e.g., []),
|
|
1331
1471
|
// 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
|
|
1472
|
+
TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
|
|
1473
|
+
: TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
|
|
1474
|
+
: 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.
|
|
1475
|
+
: First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
|
|
1476
|
+
: never; // Should never happen
|
|
1337
1477
|
//#endregion
|
|
1338
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1478
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/numeric.d.ts
|
|
1339
1479
|
type _Numeric = number | bigint;
|
|
1340
1480
|
type Zero = 0 | 0n;
|
|
1341
1481
|
/**
|
|
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
1482
|
A negative `number`/`bigint` (`-∞ < x < 0`)
|
|
1354
1483
|
|
|
1355
1484
|
Use-case: Validating and documenting parameters.
|
|
@@ -1380,12 +1509,12 @@ type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
|
|
|
1380
1509
|
//#region ../../node_modules/.pnpm/tagged-tag@1.0.0/node_modules/tagged-tag/index.d.ts
|
|
1381
1510
|
declare const tag: unique symbol;
|
|
1382
1511
|
//#endregion
|
|
1383
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1512
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/tagged.d.ts
|
|
1384
1513
|
// eslint-disable-next-line type-fest/require-exported-types
|
|
1385
1514
|
type TagContainer<Token> = {
|
|
1386
1515
|
readonly [tag]: Token;
|
|
1387
1516
|
};
|
|
1388
|
-
type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata }>;
|
|
1517
|
+
type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata; }>;
|
|
1389
1518
|
/**
|
|
1390
1519
|
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
1520
|
|
|
@@ -1476,83 +1605,9 @@ type WontWork = UnwrapTagged<string>;
|
|
|
1476
1605
|
@category Type
|
|
1477
1606
|
*/
|
|
1478
1607
|
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
|
-
*/
|
|
1608
|
+
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
1609
|
//#endregion
|
|
1555
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1610
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-literal.d.ts
|
|
1556
1611
|
/**
|
|
1557
1612
|
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
1613
|
|
|
@@ -1609,12 +1664,17 @@ type L2 = Length<`${number}`>;
|
|
|
1609
1664
|
@category Type Guard
|
|
1610
1665
|
@category Utilities
|
|
1611
1666
|
*/
|
|
1612
|
-
type IsStringLiteral<S> = IfNotAnyOrNever<S,
|
|
1613
|
-
|
|
1667
|
+
type IsStringLiteral<S> = IfNotAnyOrNever<S, {
|
|
1668
|
+
ifNot: _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>;
|
|
1669
|
+
ifAny: false;
|
|
1670
|
+
ifNever: false;
|
|
1671
|
+
}>;
|
|
1672
|
+
type _IsStringLiteral<S> =
|
|
1673
|
+
// If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
|
|
1614
1674
|
// and since `{}` extends index signatures, the result becomes `false`.
|
|
1615
1675
|
S extends string ? {} extends Record<S, never> ? false : true : false;
|
|
1616
1676
|
//#endregion
|
|
1617
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1677
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/tuple-of.d.ts
|
|
1618
1678
|
/**
|
|
1619
1679
|
Create a tuple type of the specified length with elements of the specified type.
|
|
1620
1680
|
|
|
@@ -1689,13 +1749,17 @@ Note: If you need a readonly tuple, simply wrap this type with `Readonly`, for e
|
|
|
1689
1749
|
|
|
1690
1750
|
@category Array
|
|
1691
1751
|
*/
|
|
1692
|
-
type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length,
|
|
1752
|
+
type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, {
|
|
1753
|
+
ifNot: _TupleOf<If<IsNegative<Length>, 0, Length>, Fill>;
|
|
1754
|
+
ifAny: Fill[];
|
|
1755
|
+
ifNever: [];
|
|
1756
|
+
}>;
|
|
1693
1757
|
type _TupleOf<Length extends number, Fill> = number extends Length ? Fill[] : BuildTupleDigitByDigit<`${Length}`, Fill>;
|
|
1694
1758
|
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
1759
|
type RepeatTupleTenTimes<Tuple extends UnknownArray> = [...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple];
|
|
1696
1760
|
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
1761
|
//#endregion
|
|
1698
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1762
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/simplify.d.ts
|
|
1699
1763
|
/**
|
|
1700
1764
|
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
1765
|
|
|
@@ -1754,9 +1818,9 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
1754
1818
|
@see {@link SimplifyDeep}
|
|
1755
1819
|
@category Object
|
|
1756
1820
|
*/
|
|
1757
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
1821
|
+
type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
1758
1822
|
//#endregion
|
|
1759
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1823
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/is-equal.d.ts
|
|
1760
1824
|
/**
|
|
1761
1825
|
Returns a boolean for whether the two given types are equal.
|
|
1762
1826
|
|
|
@@ -1787,7 +1851,7 @@ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false
|
|
|
1787
1851
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
1788
1852
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
1789
1853
|
//#endregion
|
|
1790
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1854
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
1791
1855
|
/**
|
|
1792
1856
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
1793
1857
|
|
|
@@ -1879,9 +1943,9 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
1879
1943
|
@see {@link PickIndexSignature}
|
|
1880
1944
|
@category Object
|
|
1881
1945
|
*/
|
|
1882
|
-
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
1946
|
+
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType]; };
|
|
1883
1947
|
//#endregion
|
|
1884
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1948
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
1885
1949
|
/**
|
|
1886
1950
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
1887
1951
|
|
|
@@ -1927,11 +1991,11 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
1927
1991
|
@see {@link OmitIndexSignature}
|
|
1928
1992
|
@category Object
|
|
1929
1993
|
*/
|
|
1930
|
-
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
1994
|
+
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType]; };
|
|
1931
1995
|
//#endregion
|
|
1932
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1996
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/merge.d.ts
|
|
1933
1997
|
// 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>;
|
|
1998
|
+
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>;
|
|
1935
1999
|
/**
|
|
1936
2000
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
1937
2001
|
|
|
@@ -1995,13 +2059,12 @@ Note: If you want a merge type that more accurately reflects the runtime behavio
|
|
|
1995
2059
|
@category Object
|
|
1996
2060
|
*/
|
|
1997
2061
|
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
|
|
2062
|
+
? Source extends unknown // For distributing `Source`
|
|
2063
|
+
? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
|
|
2064
|
+
: never; // Should never happen
|
|
2002
2065
|
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
2003
2066
|
//#endregion
|
|
2004
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2067
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/internal/object.d.ts
|
|
2005
2068
|
/**
|
|
2006
2069
|
Works similar to the built-in `Pick` utility type, except for the following differences:
|
|
2007
2070
|
- Distributes over union types and allows picking keys from any member of the union type.
|
|
@@ -2039,7 +2102,7 @@ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
|
|
|
2039
2102
|
type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
|
|
2040
2103
|
//=> {}
|
|
2041
2104
|
*/
|
|
2042
|
-
type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
|
|
2105
|
+
type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P]; };
|
|
2043
2106
|
/**
|
|
2044
2107
|
Merges user specified options with default options.
|
|
2045
2108
|
|
|
@@ -2092,9 +2155,9 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
2092
2155
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
2093
2156
|
```
|
|
2094
2157
|
*/
|
|
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] }>>>;
|
|
2158
|
+
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>`
|
|
2159
|
+
) ? Result : never;
|
|
2160
|
+
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
2161
|
/**
|
|
2099
2162
|
Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
|
|
2100
2163
|
|
|
@@ -2122,35 +2185,44 @@ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined
|
|
|
2122
2185
|
//=> string | null | undefined
|
|
2123
2186
|
```
|
|
2124
2187
|
*/
|
|
2125
|
-
type CollapseLiterals<T> = {} extends T ? T : T extends infer U & {} ? U : T;
|
|
2188
|
+
type CollapseLiterals<T> = {} extends T ? T : T extends (infer U) & {} ? U : T;
|
|
2126
2189
|
//#endregion
|
|
2127
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2190
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/some-extend.d.ts
|
|
2128
2191
|
/**
|
|
2129
2192
|
@see {@link SomeExtend}
|
|
2130
2193
|
*/
|
|
2131
2194
|
type SomeExtendOptions = {
|
|
2132
2195
|
/**
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2196
|
+
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
2197
|
+
|
|
2198
|
+
- 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`).
|
|
2199
|
+
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
2200
|
+
|
|
2201
|
+
@default true
|
|
2202
|
+
|
|
2203
|
+
@example
|
|
2204
|
+
```
|
|
2205
|
+
import type {SomeExtend} from 'type-fest';
|
|
2206
|
+
|
|
2207
|
+
type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
|
|
2208
|
+
//=> false
|
|
2209
|
+
|
|
2210
|
+
type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
|
|
2211
|
+
//=> true
|
|
2212
|
+
|
|
2213
|
+
type C = SomeExtend<[1, never], never, {strictNever: true}>;
|
|
2214
|
+
//=> true
|
|
2215
|
+
|
|
2216
|
+
type D = SomeExtend<[1, never], never, {strictNever: false}>;
|
|
2217
|
+
//=> true
|
|
2218
|
+
|
|
2219
|
+
type E = SomeExtend<[never], any, {strictNever: true}>;
|
|
2220
|
+
//=> true
|
|
2221
|
+
|
|
2222
|
+
type F = SomeExtend<[never], any, {strictNever: false}>;
|
|
2223
|
+
//=> true
|
|
2224
|
+
```
|
|
2225
|
+
*/
|
|
2154
2226
|
strictNever?: boolean;
|
|
2155
2227
|
};
|
|
2156
2228
|
type DefaultSomeExtendOptions = {
|
|
@@ -2203,10 +2275,15 @@ type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
|
|
|
2203
2275
|
@category Array
|
|
2204
2276
|
*/
|
|
2205
2277
|
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
|
-
|
|
2278
|
+
type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, {
|
|
2279
|
+
ifNot: TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true ?
|
|
2280
|
+
// If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
|
|
2281
|
+
true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false;
|
|
2282
|
+
ifAny: false;
|
|
2283
|
+
ifNever: false;
|
|
2284
|
+
}>;
|
|
2208
2285
|
//#endregion
|
|
2209
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2286
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/or-all.d.ts
|
|
2210
2287
|
/**
|
|
2211
2288
|
Returns a boolean for whether any of the given elements is `true`.
|
|
2212
2289
|
|
|
@@ -2277,7 +2354,7 @@ Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in a
|
|
|
2277
2354
|
*/
|
|
2278
2355
|
type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
|
|
2279
2356
|
//#endregion
|
|
2280
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2357
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/or.d.ts
|
|
2281
2358
|
/**
|
|
2282
2359
|
Returns a boolean for whether either of two given types is `true`.
|
|
2283
2360
|
|
|
@@ -2357,37 +2434,48 @@ type G = Or<never, never>;
|
|
|
2357
2434
|
*/
|
|
2358
2435
|
type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
|
|
2359
2436
|
//#endregion
|
|
2360
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2437
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/all-extend.d.ts
|
|
2361
2438
|
/**
|
|
2362
2439
|
@see {@link AllExtend}
|
|
2363
2440
|
*/
|
|
2364
2441
|
type AllExtendOptions = {
|
|
2365
2442
|
/**
|
|
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
|
-
|
|
2443
|
+
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
2444
|
+
|
|
2445
|
+
- 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`).
|
|
2446
|
+
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
2447
|
+
|
|
2448
|
+
@default true
|
|
2449
|
+
|
|
2450
|
+
@example
|
|
2451
|
+
```
|
|
2452
|
+
import type {AllExtend} from 'type-fest';
|
|
2453
|
+
|
|
2454
|
+
type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
|
|
2455
|
+
//=> false
|
|
2456
|
+
|
|
2457
|
+
type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
|
|
2458
|
+
//=> true
|
|
2459
|
+
|
|
2460
|
+
type C = AllExtend<[never, never], never, {strictNever: true}>;
|
|
2461
|
+
//=> true
|
|
2462
|
+
|
|
2463
|
+
type D = AllExtend<[never, never], never, {strictNever: false}>;
|
|
2464
|
+
//=> true
|
|
2465
|
+
|
|
2466
|
+
type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
|
|
2467
|
+
//=> true
|
|
2468
|
+
|
|
2469
|
+
type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
|
|
2470
|
+
//=> true
|
|
2471
|
+
|
|
2472
|
+
type G = AllExtend<[never, 1], never, {strictNever: true}>;
|
|
2473
|
+
//=> false
|
|
2474
|
+
|
|
2475
|
+
type H = AllExtend<[never, 1], never, {strictNever: false}>;
|
|
2476
|
+
//=> false
|
|
2477
|
+
```
|
|
2478
|
+
*/
|
|
2391
2479
|
strictNever?: boolean;
|
|
2392
2480
|
};
|
|
2393
2481
|
type DefaultAllExtendOptions = {
|
|
@@ -2440,10 +2528,15 @@ type B = AllExtend<[1?, 2?, 3?], number | undefined>;
|
|
|
2440
2528
|
@category Array
|
|
2441
2529
|
*/
|
|
2442
2530
|
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
|
-
|
|
2531
|
+
type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, {
|
|
2532
|
+
ifNot: TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true ?
|
|
2533
|
+
// If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
|
|
2534
|
+
_AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true;
|
|
2535
|
+
ifAny: false;
|
|
2536
|
+
ifNever: false;
|
|
2537
|
+
}>;
|
|
2445
2538
|
//#endregion
|
|
2446
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2539
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/and-all.d.ts
|
|
2447
2540
|
/**
|
|
2448
2541
|
Returns a boolean for whether all of the given elements are `true`.
|
|
2449
2542
|
|
|
@@ -2517,7 +2610,7 @@ Note: `AndAll<[]>` evaluates to `true` due to the concept of [vacuous truth](htt
|
|
|
2517
2610
|
*/
|
|
2518
2611
|
type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;
|
|
2519
2612
|
//#endregion
|
|
2520
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2613
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/and.d.ts
|
|
2521
2614
|
/**
|
|
2522
2615
|
Returns a boolean for whether two given types are both `true`.
|
|
2523
2616
|
|
|
@@ -2597,7 +2690,7 @@ type G = And<never, never>;
|
|
|
2597
2690
|
*/
|
|
2598
2691
|
type And<A extends boolean, B extends boolean> = AndAll<[A, B]>;
|
|
2599
2692
|
//#endregion
|
|
2600
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2693
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/except.d.ts
|
|
2601
2694
|
/**
|
|
2602
2695
|
Filter out keys from an object.
|
|
2603
2696
|
|
|
@@ -2628,10 +2721,12 @@ type Filtered = Filter<'bar', 'foo'>;
|
|
|
2628
2721
|
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
2629
2722
|
type ExceptOptions = {
|
|
2630
2723
|
/**
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2724
|
+
Disallow assigning non-specified properties.
|
|
2725
|
+
|
|
2726
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
2727
|
+
|
|
2728
|
+
@default false
|
|
2729
|
+
*/
|
|
2635
2730
|
requireExactProps?: boolean;
|
|
2636
2731
|
};
|
|
2637
2732
|
type DefaultExceptOptions = {
|
|
@@ -2693,9 +2788,9 @@ type PostPayloadFixed = Except<UserData, 'email'>;
|
|
|
2693
2788
|
@category Object
|
|
2694
2789
|
*/
|
|
2695
2790
|
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>> : {});
|
|
2791
|
+
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
2792
|
//#endregion
|
|
2698
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2793
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/exclude-exactly.d.ts
|
|
2699
2794
|
/**
|
|
2700
2795
|
A stricter version of `Exclude<T, U>` that excludes types only when they are exactly identical.
|
|
2701
2796
|
|
|
@@ -2724,16 +2819,24 @@ type TestExcludeExactly3 = ExcludeExactly<{a: string} | {a: string; b: string},
|
|
|
2724
2819
|
|
|
2725
2820
|
@category Improved Built-in
|
|
2726
2821
|
*/
|
|
2727
|
-
type ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Union,
|
|
2728
|
-
|
|
2729
|
-
If
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
Union,
|
|
2822
|
+
type ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Union, {
|
|
2823
|
+
ifNot: _ExcludeExactly<Union, Delete>;
|
|
2824
|
+
// If `Union` is `any`, then if `Delete` is `any`, return `never`, else return `Union`.
|
|
2825
|
+
ifAny: If<IsAny<Delete>, never, Union>;
|
|
2826
|
+
// If `Union` is `never`, then if `Delete` is `never`, return `never`, else return `Union`.
|
|
2827
|
+
ifNever: If<IsNever<Delete>, never, Union>;
|
|
2828
|
+
}>;
|
|
2829
|
+
type _ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Delete, {
|
|
2830
|
+
ifNot: Union extends unknown // For distributing `Union`
|
|
2831
|
+
? [Delete extends unknown // For distributing `Delete`
|
|
2832
|
+
? If<IsEqual<Union, Delete>, true, never> : never] extends [never] ? Union : never : never;
|
|
2833
|
+
// If `Delete` is `any` or `never`, then return `Union`,
|
|
2834
|
+
// because `Union` cannot be `any` or `never` here.
|
|
2835
|
+
ifAny: Union;
|
|
2836
|
+
ifNever: Union;
|
|
2837
|
+
}>;
|
|
2735
2838
|
//#endregion
|
|
2736
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2839
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/union-member.d.ts
|
|
2737
2840
|
/**
|
|
2738
2841
|
Returns an arbitrary member of a union type.
|
|
2739
2842
|
|
|
@@ -2790,7 +2893,7 @@ type LastNever = UnionMember<never>;
|
|
|
2790
2893
|
*/
|
|
2791
2894
|
type UnionMember<T> = IsNever<T> extends true ? never : UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
|
|
2792
2895
|
//#endregion
|
|
2793
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2896
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
2794
2897
|
/**
|
|
2795
2898
|
Convert a union type into an unordered tuple type of its elements.
|
|
2796
2899
|
|
|
@@ -2826,11 +2929,10 @@ const petList = Object.keys(pets) as UnionToTuple<Pet>;
|
|
|
2826
2929
|
|
|
2827
2930
|
@category Array
|
|
2828
2931
|
*/
|
|
2829
|
-
type UnionToTuple<Union> = _UnionToTuple<Union> extends infer Result extends UnknownArray ? Result : never;
|
|
2830
|
-
// Nudges the compiler that `UnionToTuple` always yields an array.
|
|
2932
|
+
type UnionToTuple<Union> = _UnionToTuple<Union> extends (infer Result extends UnknownArray) ? Result : never; // Nudges the compiler that `UnionToTuple` always yields an array.
|
|
2831
2933
|
type _UnionToTuple<Union, Accumulator extends UnknownArray = [], Member = UnionMember<Union>> = IsNever<Union> extends true ? Accumulator : _UnionToTuple<ExcludeExactly<Union, Member>, [Member, ...Accumulator]>;
|
|
2832
2934
|
//#endregion
|
|
2833
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2935
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/set-optional.d.ts
|
|
2834
2936
|
/**
|
|
2835
2937
|
Create a type that makes the given keys optional, while keeping the remaining keys as is.
|
|
2836
2938
|
|
|
@@ -2854,11 +2956,13 @@ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
|
2854
2956
|
*/
|
|
2855
2957
|
type SetOptional<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetOptional<BaseType, Keys>;
|
|
2856
2958
|
type _SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends unknown // To distribute `BaseType` when it's a union type.
|
|
2857
|
-
? Simplify<
|
|
2858
|
-
|
|
2859
|
-
|
|
2959
|
+
? Simplify<
|
|
2960
|
+
// Pick just the keys that are readonly from the base type.
|
|
2961
|
+
Except<BaseType, Keys> &
|
|
2962
|
+
// Pick the keys that should be mutable from the base type and make them mutable.
|
|
2963
|
+
Partial<HomomorphicPick<BaseType, Keys>>> : never;
|
|
2860
2964
|
//#endregion
|
|
2861
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2965
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/value-of.d.ts
|
|
2862
2966
|
/**
|
|
2863
2967
|
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
|
2864
2968
|
|
|
@@ -2882,7 +2986,7 @@ type C = ValueOf<{id: number; name: string; active: boolean}, 'id' | 'name'>;
|
|
|
2882
2986
|
*/
|
|
2883
2987
|
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
2884
2988
|
//#endregion
|
|
2885
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2989
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/split.d.ts
|
|
2886
2990
|
/**
|
|
2887
2991
|
Split options.
|
|
2888
2992
|
|
|
@@ -2890,21 +2994,27 @@ Split options.
|
|
|
2890
2994
|
*/
|
|
2891
2995
|
type SplitOptions = {
|
|
2892
2996
|
/**
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2997
|
+
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.
|
|
2998
|
+
|
|
2999
|
+
@default true
|
|
3000
|
+
|
|
3001
|
+
@example
|
|
3002
|
+
```ts
|
|
3003
|
+
import type {Split} from 'type-fest';
|
|
3004
|
+
|
|
3005
|
+
type Example1 = Split<`foo.${string}.bar`, '.', {strictLiteralChecks: false}>;
|
|
3006
|
+
//=> ['foo', string, 'bar']
|
|
3007
|
+
|
|
3008
|
+
type Example2 = Split<`foo.${string}`, '.', {strictLiteralChecks: true}>;
|
|
3009
|
+
//=> string[]
|
|
3010
|
+
|
|
3011
|
+
type Example3 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: false}>;
|
|
3012
|
+
//=> ['foo', 'r', 'z']
|
|
3013
|
+
|
|
3014
|
+
type Example4 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: true}>;
|
|
3015
|
+
//=> string[]
|
|
3016
|
+
```
|
|
3017
|
+
*/
|
|
2908
3018
|
strictLiteralChecks?: boolean;
|
|
2909
3019
|
};
|
|
2910
3020
|
type DefaultSplitOptions = {
|
|
@@ -2933,13 +3043,15 @@ const array: Item[] = split(items, ',');
|
|
|
2933
3043
|
*/
|
|
2934
3044
|
type Split<S extends string, Delimiter extends string, Options extends SplitOptions = {}> = SplitHelper<S, Delimiter, ApplyDefaultOptions<SplitOptions, DefaultSplitOptions, Options>>;
|
|
2935
3045
|
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`
|
|
3046
|
+
? Delimiter extends string // For distributing `Delimiter`
|
|
3047
|
+
?
|
|
2937
3048
|
// If `strictLiteralChecks` is `false` OR `S` and `Delimiter` both are string literals, then perform the split
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
: never
|
|
3049
|
+
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] :
|
|
3050
|
+
// Otherwise, return `string[]`
|
|
3051
|
+
string[] : never // Should never happen
|
|
3052
|
+
: never; // Should never happen
|
|
2941
3053
|
//#endregion
|
|
2942
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
3054
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/replace.d.ts
|
|
2943
3055
|
type ReplaceOptions = {
|
|
2944
3056
|
all?: boolean;
|
|
2945
3057
|
};
|
|
@@ -3001,8 +3113,8 @@ replaceAll('My Cool Title', ' ', '');
|
|
|
3001
3113
|
*/
|
|
3002
3114
|
type Replace<Input extends string, Search extends string, Replacement extends string, Options extends ReplaceOptions = {}> = _Replace<Input, Search, Replacement, ApplyDefaultOptions<ReplaceOptions, DefaultReplaceOptions, Options>>;
|
|
3003
3115
|
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;
|
|
3116
|
+
? Replacement extends string // For distributing `Replacement`
|
|
3117
|
+
? 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
3118
|
//#endregion
|
|
3007
3119
|
//#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/List.d.ts
|
|
3008
3120
|
/**
|
|
@@ -3345,7 +3457,7 @@ declare type Tail$1<L extends List> = L extends readonly [] ? L : L extends read
|
|
|
3345
3457
|
* ```ts
|
|
3346
3458
|
* ```
|
|
3347
3459
|
*/
|
|
3348
|
-
declare type Overwrite<O extends object, O1 extends object> = { [K in keyof O]: K extends keyof O1 ? O1[K] : O[K] } & {};
|
|
3460
|
+
declare type Overwrite<O extends object, O1 extends object> = { [K in keyof O]: K extends keyof O1 ? O1[K] : O[K]; } & {};
|
|
3349
3461
|
//#endregion
|
|
3350
3462
|
//#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/_Internal.d.ts
|
|
3351
3463
|
/**
|
|
@@ -3414,7 +3526,7 @@ declare type __Drop<L extends List, N extends Iteration, way extends Way> = {
|
|
|
3414
3526
|
/**
|
|
3415
3527
|
* @hidden
|
|
3416
3528
|
*/
|
|
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;
|
|
3529
|
+
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
3530
|
/**
|
|
3419
3531
|
* Remove `N` entries out of `L`
|
|
3420
3532
|
* @param L to remove from
|
|
@@ -3454,7 +3566,7 @@ declare type __Take<L extends List, N extends Iteration, way extends Way> = {
|
|
|
3454
3566
|
/**
|
|
3455
3567
|
* @hidden
|
|
3456
3568
|
*/
|
|
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;
|
|
3569
|
+
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
3570
|
/**
|
|
3459
3571
|
* Extract `N` entries out of `L`
|
|
3460
3572
|
* @param L to extract from
|
|
@@ -3470,16 +3582,16 @@ declare type Take<L extends List, N extends number, way extends Way = '->'> = L
|
|
|
3470
3582
|
//#region src/object/index.type.d.ts
|
|
3471
3583
|
type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
|
|
3472
3584
|
type AnyArray<A = any> = readonly A[];
|
|
3473
|
-
type TupleToEntries<A extends readonly unknown[]> = If<IsAny<A>, unknown, { [Key in keyof A]: [Key, A[Key]] }>;
|
|
3585
|
+
type TupleToEntries<A extends readonly unknown[]> = If<IsAny<A>, unknown, { [Key in keyof A]: [Key, A[Key]]; }>;
|
|
3474
3586
|
type Groups<L extends AnyArray, LN extends AnyArray = [], D extends number[] = []> = D["length"] extends 40 ? LN : {
|
|
3475
3587
|
0: Groups<Drop<L, 1>, Append<LN, [`${LN["length"]}`, Take<L, 1>]>, [...D, 0]>;
|
|
3476
3588
|
1: LN;
|
|
3477
3589
|
}[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>>;
|
|
3590
|
+
type TupleToGroups<L extends AnyArray> = Groups<L> extends (infer X) ? Cast<X, AnyArray> : never;
|
|
3591
|
+
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
3592
|
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
|
|
3593
|
+
type ComputeRaw<A> = A extends AnyFunction ? A : { [K in keyof A]: A[K]; } & unknown;
|
|
3594
|
+
type _Invert<O extends Record<PropertyKey, PropertyKey>> = ComputeRaw<IntersectOf<{ [K in keyof O]: Record<O[K], K>; }[keyof O]>>;
|
|
3483
3595
|
type Invert<O extends Record<keyof O, PropertyKey>> = O extends unknown ? _Invert<O> : never;
|
|
3484
3596
|
//#endregion
|
|
3485
3597
|
//#region src/object/objectUtil.d.ts
|