@liip/liipgpt 3.0.3 → 3.0.4
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/config/index.d.ts +1066 -1044
- package/configurator/_app/env.js +1 -1
- package/configurator/_app/immutable/chunks/{BPAvyvOk.js → BwCrMbEO.js} +1 -1
- package/configurator/_app/immutable/chunks/{DKk7yX4l.js → CPucR0Pn.js} +1 -1
- package/configurator/_app/immutable/chunks/{DwRK1ewj.js → D6Gh3zUA.js} +1 -1
- package/configurator/_app/immutable/chunks/{H-rwhsMq.js → DRFIdVmg.js} +1 -1
- package/configurator/_app/immutable/chunks/{DfdIiSI2.js → DoLgg1iA.js} +1 -1
- package/configurator/_app/immutable/chunks/{D13GOT_N.js → DseA0obG.js} +1 -1
- package/configurator/_app/immutable/chunks/{0ArP2NFS.js → JG6qqUCN.js} +1 -1
- package/configurator/_app/immutable/chunks/{BXugfhfL.js → Pz_sB2fA.js} +1 -1
- package/configurator/_app/immutable/chunks/{nv-NqnzC.js → zfExwgk0.js} +1 -1
- package/configurator/_app/immutable/entry/{app.CNNioGHt.js → app.B8LH58UX.js} +2 -2
- package/configurator/_app/immutable/entry/start.Dz_0Ojpm.js +1 -0
- package/configurator/_app/immutable/nodes/{0.B4OJir9d.js → 0.C8Fd-EWk.js} +1 -1
- package/configurator/_app/immutable/nodes/{1.BgTcSBhy.js → 1.DRa5uu5C.js} +1 -1
- package/configurator/_app/immutable/nodes/{2.CbvBUvRq.js → 2.DRkrRD_l.js} +3 -3
- package/configurator/_app/immutable/nodes/{3.BYQGNA4J.js → 3.DHZtb_nO.js} +1 -1
- package/configurator/_app/version.json +1 -1
- package/configurator/index.html +6 -6
- package/configurator/sidebar.html +6 -6
- package/package.json +1 -1
- package/configurator/_app/immutable/entry/start.mToUs99P.js +0 -1
package/config/index.d.ts
CHANGED
|
@@ -1607,1056 +1607,353 @@ export type Route = {
|
|
|
1607
1607
|
query: string;
|
|
1608
1608
|
};
|
|
1609
1609
|
export type ConversationState = "idle" | "searching" | "answering";
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1610
|
+
declare const errorTranslationSchema: z.ZodObject<{
|
|
1611
|
+
blocked: z.ZodString;
|
|
1612
|
+
maintenance: z.ZodString;
|
|
1613
|
+
"rate-limit": z.ZodString;
|
|
1614
|
+
"server-error": z.ZodString;
|
|
1615
|
+
"too-short": z.ZodString;
|
|
1616
|
+
"too-long": z.ZodString;
|
|
1617
|
+
"quota-reached": z.ZodString;
|
|
1618
|
+
aborted: z.ZodString;
|
|
1619
|
+
"sse-error": z.ZodString;
|
|
1620
|
+
"client-error": z.ZodString;
|
|
1621
|
+
"unexpected-call": z.ZodString;
|
|
1622
|
+
"incomplete-error": z.ZodString;
|
|
1623
|
+
"feedback-failed": z.ZodString;
|
|
1624
|
+
"speech-not-supported": z.ZodString;
|
|
1625
|
+
"speech-transcription-failed": z.ZodString;
|
|
1626
|
+
"speech-no-text-detected": z.ZodString;
|
|
1627
|
+
"speech-microphone-access-denied": z.ZodString;
|
|
1628
|
+
"pii-detected": z.ZodString;
|
|
1629
|
+
}, "strip", z.ZodTypeAny, {
|
|
1630
|
+
"pii-detected": string;
|
|
1631
|
+
blocked: string;
|
|
1632
|
+
maintenance: string;
|
|
1633
|
+
"rate-limit": string;
|
|
1634
|
+
"server-error": string;
|
|
1635
|
+
"too-short": string;
|
|
1636
|
+
"too-long": string;
|
|
1637
|
+
"quota-reached": string;
|
|
1638
|
+
aborted: string;
|
|
1639
|
+
"unexpected-call": string;
|
|
1640
|
+
"sse-error": string;
|
|
1641
|
+
"client-error": string;
|
|
1642
|
+
"incomplete-error": string;
|
|
1643
|
+
"feedback-failed": string;
|
|
1644
|
+
"speech-not-supported": string;
|
|
1645
|
+
"speech-transcription-failed": string;
|
|
1646
|
+
"speech-no-text-detected": string;
|
|
1647
|
+
"speech-microphone-access-denied": string;
|
|
1648
|
+
}, {
|
|
1649
|
+
"pii-detected": string;
|
|
1650
|
+
blocked: string;
|
|
1651
|
+
maintenance: string;
|
|
1652
|
+
"rate-limit": string;
|
|
1653
|
+
"server-error": string;
|
|
1654
|
+
"too-short": string;
|
|
1655
|
+
"too-long": string;
|
|
1656
|
+
"quota-reached": string;
|
|
1657
|
+
aborted: string;
|
|
1658
|
+
"unexpected-call": string;
|
|
1659
|
+
"sse-error": string;
|
|
1660
|
+
"client-error": string;
|
|
1661
|
+
"incomplete-error": string;
|
|
1662
|
+
"feedback-failed": string;
|
|
1663
|
+
"speech-not-supported": string;
|
|
1664
|
+
"speech-transcription-failed": string;
|
|
1665
|
+
"speech-no-text-detected": string;
|
|
1666
|
+
"speech-microphone-access-denied": string;
|
|
1667
|
+
}>;
|
|
1668
|
+
declare const chatSelectorTranslationSchema: z.ZodObject<{
|
|
1669
|
+
name: z.ZodString;
|
|
1670
|
+
namePlural: z.ZodOptional<z.ZodString>;
|
|
1671
|
+
intro: z.ZodOptional<z.ZodString>;
|
|
1672
|
+
placeholder: z.ZodString;
|
|
1673
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
1674
|
+
}, "strip", z.ZodTypeAny, {
|
|
1675
|
+
values: Record<string, string>;
|
|
1621
1676
|
name: string;
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
1628
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
1629
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
1630
|
-
};
|
|
1631
|
-
|
|
1632
|
-
const update1: UpdateOperation<User> = {
|
|
1633
|
-
name: 'Alice'
|
|
1634
|
-
};
|
|
1635
|
-
|
|
1636
|
-
const update2: UpdateOperation<User> = {
|
|
1637
|
-
name: 'Bob',
|
|
1638
|
-
luckyNumber: REMOVE_FIELD
|
|
1639
|
-
};
|
|
1640
|
-
```
|
|
1641
|
-
|
|
1642
|
-
@category Utilities
|
|
1643
|
-
*/
|
|
1644
|
-
export type OptionalKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
|
|
1645
|
-
? (keyof {
|
|
1646
|
-
[Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never;
|
|
1647
|
-
}) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
|
|
1648
|
-
: never; // Should never happen
|
|
1649
|
-
/**
|
|
1650
|
-
Extract all required keys from the given type.
|
|
1651
|
-
|
|
1652
|
-
This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
|
1653
|
-
|
|
1654
|
-
@example
|
|
1655
|
-
```
|
|
1656
|
-
import type {RequiredKeysOf} from 'type-fest';
|
|
1657
|
-
|
|
1658
|
-
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
1659
|
-
|
|
1660
|
-
interface User {
|
|
1677
|
+
placeholder: string;
|
|
1678
|
+
namePlural?: string | undefined;
|
|
1679
|
+
intro?: string | undefined;
|
|
1680
|
+
}, {
|
|
1681
|
+
values: Record<string, string>;
|
|
1661
1682
|
name: string;
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1683
|
+
placeholder: string;
|
|
1684
|
+
namePlural?: string | undefined;
|
|
1685
|
+
intro?: string | undefined;
|
|
1686
|
+
}>;
|
|
1687
|
+
declare const translationSchema: z.ZodObject<{
|
|
1688
|
+
predefinedQuestions: z.ZodString;
|
|
1689
|
+
introductionTitle: z.ZodString;
|
|
1690
|
+
introductionDisclaimer: z.ZodOptional<z.ZodString>;
|
|
1691
|
+
chatInputPlaceholder: z.ZodString;
|
|
1692
|
+
chatInputPlaceholderListening: z.ZodOptional<z.ZodString>;
|
|
1693
|
+
chatInputSubmit: z.ZodString;
|
|
1694
|
+
chatInputStartListening: z.ZodString;
|
|
1695
|
+
chatInputStopListening: z.ZodString;
|
|
1696
|
+
referenceLink: z.ZodString;
|
|
1697
|
+
referencesDisplay: z.ZodString;
|
|
1698
|
+
referencesHide: z.ZodString;
|
|
1699
|
+
referencesTitle: z.ZodString;
|
|
1700
|
+
referencesFurtherTitle: z.ZodString;
|
|
1701
|
+
newChat: z.ZodString;
|
|
1702
|
+
maintenanceModeError: z.ZodString;
|
|
1703
|
+
messageBotLoading: z.ZodString;
|
|
1704
|
+
messageBotError: z.ZodString;
|
|
1705
|
+
messageBotDefaultError: z.ZodString;
|
|
1706
|
+
noResultsFound: z.ZodString;
|
|
1707
|
+
chatFooterText: z.ZodOptional<z.ZodString>;
|
|
1708
|
+
scrollToBottom: z.ZodString;
|
|
1709
|
+
openButtonTitle: z.ZodOptional<z.ZodString>;
|
|
1710
|
+
openButtonDescription: z.ZodOptional<z.ZodString>;
|
|
1711
|
+
openMenu: z.ZodString;
|
|
1712
|
+
openInfo: z.ZodString;
|
|
1713
|
+
aboutThisChat: z.ZodOptional<z.ZodString>;
|
|
1714
|
+
closeMenu: z.ZodString;
|
|
1715
|
+
closeChat: z.ZodString;
|
|
1716
|
+
close: z.ZodString;
|
|
1717
|
+
send: z.ZodString;
|
|
1718
|
+
thankYouForFeedback: z.ZodString;
|
|
1719
|
+
giveFeedback: z.ZodString;
|
|
1720
|
+
sendFeedback: z.ZodString;
|
|
1721
|
+
feedbackFormTitle: z.ZodString;
|
|
1722
|
+
feedbackFormMessage: z.ZodString;
|
|
1723
|
+
feedbackFormMessagePlaceholder: z.ZodString;
|
|
1724
|
+
feedbackFormEmail: z.ZodString;
|
|
1725
|
+
feedbackFormEmailPlaceholder: z.ZodString;
|
|
1726
|
+
answerGood: z.ZodString;
|
|
1727
|
+
answerBad: z.ZodString;
|
|
1728
|
+
classificationSubmit: z.ZodString;
|
|
1729
|
+
classificationThankYou: z.ZodString;
|
|
1730
|
+
classificationTitle: z.ZodString;
|
|
1731
|
+
selectLanguage: z.ZodString;
|
|
1732
|
+
lightMode: z.ZodString;
|
|
1733
|
+
darkMode: z.ZodString;
|
|
1734
|
+
termsTitle: z.ZodOptional<z.ZodString>;
|
|
1735
|
+
termsContent: z.ZodOptional<z.ZodString>;
|
|
1736
|
+
selectors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1737
|
+
name: z.ZodString;
|
|
1738
|
+
namePlural: z.ZodOptional<z.ZodString>;
|
|
1739
|
+
intro: z.ZodOptional<z.ZodString>;
|
|
1740
|
+
placeholder: z.ZodString;
|
|
1741
|
+
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
1742
|
+
}, "strip", z.ZodTypeAny, {
|
|
1743
|
+
values: Record<string, string>;
|
|
1744
|
+
name: string;
|
|
1745
|
+
placeholder: string;
|
|
1746
|
+
namePlural?: string | undefined;
|
|
1747
|
+
intro?: string | undefined;
|
|
1748
|
+
}, {
|
|
1749
|
+
values: Record<string, string>;
|
|
1750
|
+
name: string;
|
|
1751
|
+
placeholder: string;
|
|
1752
|
+
namePlural?: string | undefined;
|
|
1753
|
+
intro?: string | undefined;
|
|
1754
|
+
}>>>;
|
|
1755
|
+
hideSettings: z.ZodString;
|
|
1756
|
+
showSettings: z.ZodString;
|
|
1757
|
+
chooseAtLeastOneOption: z.ZodString;
|
|
1758
|
+
selectAll: z.ZodString;
|
|
1759
|
+
selectNone: z.ZodString;
|
|
1760
|
+
}, "strip", z.ZodTypeAny, {
|
|
1761
|
+
predefinedQuestions: string;
|
|
1762
|
+
introductionTitle: string;
|
|
1763
|
+
chatInputPlaceholder: string;
|
|
1764
|
+
chatInputSubmit: string;
|
|
1765
|
+
chatInputStartListening: string;
|
|
1766
|
+
chatInputStopListening: string;
|
|
1767
|
+
referenceLink: string;
|
|
1768
|
+
referencesDisplay: string;
|
|
1769
|
+
referencesHide: string;
|
|
1770
|
+
referencesTitle: string;
|
|
1771
|
+
referencesFurtherTitle: string;
|
|
1772
|
+
newChat: string;
|
|
1773
|
+
maintenanceModeError: string;
|
|
1774
|
+
messageBotLoading: string;
|
|
1775
|
+
messageBotError: string;
|
|
1776
|
+
messageBotDefaultError: string;
|
|
1777
|
+
noResultsFound: string;
|
|
1778
|
+
scrollToBottom: string;
|
|
1779
|
+
openMenu: string;
|
|
1780
|
+
openInfo: string;
|
|
1781
|
+
closeMenu: string;
|
|
1782
|
+
closeChat: string;
|
|
1783
|
+
close: string;
|
|
1784
|
+
send: string;
|
|
1785
|
+
thankYouForFeedback: string;
|
|
1786
|
+
giveFeedback: string;
|
|
1787
|
+
sendFeedback: string;
|
|
1788
|
+
feedbackFormTitle: string;
|
|
1789
|
+
feedbackFormMessage: string;
|
|
1790
|
+
feedbackFormMessagePlaceholder: string;
|
|
1791
|
+
feedbackFormEmail: string;
|
|
1792
|
+
feedbackFormEmailPlaceholder: string;
|
|
1793
|
+
answerGood: string;
|
|
1794
|
+
answerBad: string;
|
|
1795
|
+
classificationSubmit: string;
|
|
1796
|
+
classificationThankYou: string;
|
|
1797
|
+
classificationTitle: string;
|
|
1798
|
+
selectLanguage: string;
|
|
1799
|
+
lightMode: string;
|
|
1800
|
+
darkMode: string;
|
|
1801
|
+
hideSettings: string;
|
|
1802
|
+
showSettings: string;
|
|
1803
|
+
chooseAtLeastOneOption: string;
|
|
1804
|
+
selectAll: string;
|
|
1805
|
+
selectNone: string;
|
|
1806
|
+
introductionDisclaimer?: string | undefined;
|
|
1807
|
+
chatInputPlaceholderListening?: string | undefined;
|
|
1808
|
+
chatFooterText?: string | undefined;
|
|
1809
|
+
openButtonTitle?: string | undefined;
|
|
1810
|
+
openButtonDescription?: string | undefined;
|
|
1811
|
+
aboutThisChat?: string | undefined;
|
|
1812
|
+
termsTitle?: string | undefined;
|
|
1813
|
+
termsContent?: string | undefined;
|
|
1814
|
+
selectors?: Record<string, {
|
|
1815
|
+
values: Record<string, string>;
|
|
1816
|
+
name: string;
|
|
1817
|
+
placeholder: string;
|
|
1818
|
+
namePlural?: string | undefined;
|
|
1819
|
+
intro?: string | undefined;
|
|
1820
|
+
}> | undefined;
|
|
1821
|
+
}, {
|
|
1822
|
+
predefinedQuestions: string;
|
|
1823
|
+
introductionTitle: string;
|
|
1824
|
+
chatInputPlaceholder: string;
|
|
1825
|
+
chatInputSubmit: string;
|
|
1826
|
+
chatInputStartListening: string;
|
|
1827
|
+
chatInputStopListening: string;
|
|
1828
|
+
referenceLink: string;
|
|
1829
|
+
referencesDisplay: string;
|
|
1830
|
+
referencesHide: string;
|
|
1831
|
+
referencesTitle: string;
|
|
1832
|
+
referencesFurtherTitle: string;
|
|
1833
|
+
newChat: string;
|
|
1834
|
+
maintenanceModeError: string;
|
|
1835
|
+
messageBotLoading: string;
|
|
1836
|
+
messageBotError: string;
|
|
1837
|
+
messageBotDefaultError: string;
|
|
1838
|
+
noResultsFound: string;
|
|
1839
|
+
scrollToBottom: string;
|
|
1840
|
+
openMenu: string;
|
|
1841
|
+
openInfo: string;
|
|
1842
|
+
closeMenu: string;
|
|
1843
|
+
closeChat: string;
|
|
1844
|
+
close: string;
|
|
1845
|
+
send: string;
|
|
1846
|
+
thankYouForFeedback: string;
|
|
1847
|
+
giveFeedback: string;
|
|
1848
|
+
sendFeedback: string;
|
|
1849
|
+
feedbackFormTitle: string;
|
|
1850
|
+
feedbackFormMessage: string;
|
|
1851
|
+
feedbackFormMessagePlaceholder: string;
|
|
1852
|
+
feedbackFormEmail: string;
|
|
1853
|
+
feedbackFormEmailPlaceholder: string;
|
|
1854
|
+
answerGood: string;
|
|
1855
|
+
answerBad: string;
|
|
1856
|
+
classificationSubmit: string;
|
|
1857
|
+
classificationThankYou: string;
|
|
1858
|
+
classificationTitle: string;
|
|
1859
|
+
selectLanguage: string;
|
|
1860
|
+
lightMode: string;
|
|
1861
|
+
darkMode: string;
|
|
1862
|
+
hideSettings: string;
|
|
1863
|
+
showSettings: string;
|
|
1864
|
+
chooseAtLeastOneOption: string;
|
|
1865
|
+
selectAll: string;
|
|
1866
|
+
selectNone: string;
|
|
1867
|
+
introductionDisclaimer?: string | undefined;
|
|
1868
|
+
chatInputPlaceholderListening?: string | undefined;
|
|
1869
|
+
chatFooterText?: string | undefined;
|
|
1870
|
+
openButtonTitle?: string | undefined;
|
|
1871
|
+
openButtonDescription?: string | undefined;
|
|
1872
|
+
aboutThisChat?: string | undefined;
|
|
1873
|
+
termsTitle?: string | undefined;
|
|
1874
|
+
termsContent?: string | undefined;
|
|
1875
|
+
selectors?: Record<string, {
|
|
1876
|
+
values: Record<string, string>;
|
|
1877
|
+
name: string;
|
|
1878
|
+
placeholder: string;
|
|
1879
|
+
namePlural?: string | undefined;
|
|
1880
|
+
intro?: string | undefined;
|
|
1881
|
+
}> | undefined;
|
|
1882
|
+
}>;
|
|
1883
|
+
declare const languagesSchema: z.ZodEnum<[
|
|
1884
|
+
"en",
|
|
1885
|
+
"de",
|
|
1886
|
+
"fr",
|
|
1887
|
+
"it"
|
|
1888
|
+
]>;
|
|
1889
|
+
export type Language = z.infer<typeof languagesSchema>;
|
|
1890
|
+
export type Translation = z.infer<typeof translationSchema>;
|
|
1891
|
+
export type ErrorTranslation = z.infer<typeof errorTranslationSchema>;
|
|
1892
|
+
export type Translations = Record<Language, Translation>;
|
|
1893
|
+
export type SelectorTranslation = z.infer<typeof chatSelectorTranslationSchema>;
|
|
1894
|
+
export type TranslationsPartial = Partial<Record<Language, Omit<Partial<Translation>, "selectors"> & {
|
|
1895
|
+
selectors?: Record<string, SelectorTranslation>;
|
|
1896
|
+
}>>;
|
|
1897
|
+
declare const SnippetReturn: unique symbol;
|
|
1898
|
+
// Use an interface instead of a type, makes for better intellisense info because the type is named in more situations.
|
|
1831
1899
|
/**
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
1853
|
-
|
|
1854
|
-
```
|
|
1855
|
-
type Indexed = {} extends Record<string, unknown>
|
|
1856
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
1857
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
1858
|
-
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
1859
|
-
|
|
1860
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
1861
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
1862
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
1863
|
-
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
1864
|
-
```
|
|
1865
|
-
|
|
1866
|
-
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
1867
|
-
|
|
1868
|
-
```
|
|
1869
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
1870
|
-
|
|
1871
|
-
type OmitIndexSignature<ObjectType> = {
|
|
1872
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
1873
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
1874
|
-
};
|
|
1875
|
-
```
|
|
1876
|
-
|
|
1877
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
1878
|
-
|
|
1879
|
-
```
|
|
1880
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
1881
|
-
|
|
1882
|
-
type OmitIndexSignature<ObjectType> = {
|
|
1883
|
-
[KeyType in keyof ObjectType
|
|
1884
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
1885
|
-
as {} extends Record<KeyType, unknown>
|
|
1886
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
1887
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
1888
|
-
]: ObjectType[KeyType];
|
|
1889
|
-
};
|
|
1890
|
-
```
|
|
1891
|
-
|
|
1892
|
-
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
1893
|
-
|
|
1894
|
-
@example
|
|
1895
|
-
```
|
|
1896
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
1897
|
-
|
|
1898
|
-
interface Example {
|
|
1899
|
-
// These index signatures will be removed.
|
|
1900
|
-
[x: string]: any
|
|
1901
|
-
[x: number]: any
|
|
1902
|
-
[x: symbol]: any
|
|
1903
|
-
[x: `head-${string}`]: string
|
|
1904
|
-
[x: `${string}-tail`]: string
|
|
1905
|
-
[x: `head-${string}-tail`]: string
|
|
1906
|
-
[x: `${bigint}`]: string
|
|
1907
|
-
[x: `embedded-${number}`]: string
|
|
1908
|
-
|
|
1909
|
-
// These explicitly defined keys will remain.
|
|
1910
|
-
foo: 'bar';
|
|
1911
|
-
qux?: 'baz';
|
|
1900
|
+
* The type of a `#snippet` block. You can use it to (for example) express that your component expects a snippet of a certain type:
|
|
1901
|
+
* ```ts
|
|
1902
|
+
* let { banner }: { banner: Snippet<[{ text: string }]> } = $props();
|
|
1903
|
+
* ```
|
|
1904
|
+
* You can only call a snippet through the `{@render ...}` tag.
|
|
1905
|
+
*
|
|
1906
|
+
* See the [snippet documentation](https://svelte.dev/docs/svelte/snippet) for more info.
|
|
1907
|
+
*
|
|
1908
|
+
* @template Parameters the parameters that the snippet expects (if any) as a tuple.
|
|
1909
|
+
*/
|
|
1910
|
+
export interface Snippet<Parameters extends unknown[] = [
|
|
1911
|
+
]> {
|
|
1912
|
+
(this: void,
|
|
1913
|
+
// this conditional allows tuples but not arrays. Arrays would indicate a
|
|
1914
|
+
// rest parameter type, which is not supported. If rest parameters are added
|
|
1915
|
+
// in the future, the condition can be removed.
|
|
1916
|
+
...args: number extends Parameters["length"] ? never : Parameters): {
|
|
1917
|
+
"{@render ...} must be called with a Snippet": "import type { Snippet } from 'svelte'";
|
|
1918
|
+
} & typeof SnippetReturn;
|
|
1912
1919
|
}
|
|
1913
|
-
|
|
1914
|
-
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
1915
|
-
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
1916
|
-
```
|
|
1917
|
-
|
|
1918
|
-
@see PickIndexSignature
|
|
1919
|
-
@category Object
|
|
1920
|
-
*/
|
|
1921
|
-
export type OmitIndexSignature<ObjectType> = {
|
|
1922
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
|
|
1923
|
-
};
|
|
1924
|
-
/**
|
|
1925
|
-
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
1926
|
-
|
|
1927
|
-
This is the counterpart of `OmitIndexSignature`.
|
|
1928
|
-
|
|
1929
|
-
@example
|
|
1930
|
-
```
|
|
1931
|
-
import type {PickIndexSignature} from 'type-fest';
|
|
1932
|
-
|
|
1933
|
-
declare const symbolKey: unique symbol;
|
|
1934
|
-
|
|
1935
|
-
type Example = {
|
|
1936
|
-
// These index signatures will remain.
|
|
1937
|
-
[x: string]: unknown;
|
|
1938
|
-
[x: number]: unknown;
|
|
1939
|
-
[x: symbol]: unknown;
|
|
1940
|
-
[x: `head-${string}`]: string;
|
|
1941
|
-
[x: `${string}-tail`]: string;
|
|
1942
|
-
[x: `head-${string}-tail`]: string;
|
|
1943
|
-
[x: `${bigint}`]: string;
|
|
1944
|
-
[x: `embedded-${number}`]: string;
|
|
1945
|
-
|
|
1946
|
-
// These explicitly defined keys will be removed.
|
|
1947
|
-
['kebab-case-key']: string;
|
|
1948
|
-
[symbolKey]: string;
|
|
1949
|
-
foo: 'bar';
|
|
1950
|
-
qux?: 'baz';
|
|
1951
|
-
};
|
|
1952
|
-
|
|
1953
|
-
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
1954
|
-
// {
|
|
1955
|
-
// [x: string]: unknown;
|
|
1956
|
-
// [x: number]: unknown;
|
|
1957
|
-
// [x: symbol]: unknown;
|
|
1958
|
-
// [x: `head-${string}`]: string;
|
|
1959
|
-
// [x: `${string}-tail`]: string;
|
|
1960
|
-
// [x: `head-${string}-tail`]: string;
|
|
1961
|
-
// [x: `${bigint}`]: string;
|
|
1962
|
-
// [x: `embedded-${number}`]: string;
|
|
1963
|
-
// }
|
|
1964
|
-
```
|
|
1965
|
-
|
|
1966
|
-
@see OmitIndexSignature
|
|
1967
|
-
@category Object
|
|
1968
|
-
*/
|
|
1969
|
-
export type PickIndexSignature<ObjectType> = {
|
|
1970
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType];
|
|
1971
|
-
};
|
|
1972
|
-
// Merges two objects without worrying about index signatures.
|
|
1973
|
-
export type SimpleMerge<Destination, Source> = {
|
|
1974
|
-
[Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
|
|
1975
|
-
} & Source;
|
|
1976
1920
|
/**
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
interface
|
|
1984
|
-
|
|
1985
|
-
[x: number]: unknown;
|
|
1986
|
-
foo: string;
|
|
1987
|
-
bar: symbol;
|
|
1921
|
+
* An [attachment](https://svelte.dev/docs/svelte/@attach) is a function that runs when an element is mounted
|
|
1922
|
+
* to the DOM, and optionally returns a function that is called when the element is later removed.
|
|
1923
|
+
*
|
|
1924
|
+
* It can be attached to an element with an `{@attach ...}` tag, or by spreading an object containing
|
|
1925
|
+
* a property created with [`createAttachmentKey`](https://svelte.dev/docs/svelte/svelte-attachments#createAttachmentKey).
|
|
1926
|
+
*/
|
|
1927
|
+
export interface Attachment<T extends EventTarget = Element> {
|
|
1928
|
+
(element: T): void | (() => void);
|
|
1988
1929
|
}
|
|
1989
|
-
|
|
1990
|
-
type
|
|
1991
|
-
[x: number]: number;
|
|
1992
|
-
[x: symbol]: unknown;
|
|
1993
|
-
bar: Date;
|
|
1994
|
-
baz: boolean;
|
|
1995
|
-
};
|
|
1996
|
-
|
|
1997
|
-
export type FooBar = Merge<Foo, Bar>;
|
|
1998
|
-
// => {
|
|
1999
|
-
// [x: string]: unknown;
|
|
2000
|
-
// [x: number]: number;
|
|
2001
|
-
// [x: symbol]: unknown;
|
|
2002
|
-
// foo: string;
|
|
2003
|
-
// bar: Date;
|
|
2004
|
-
// baz: boolean;
|
|
2005
|
-
// }
|
|
2006
|
-
```
|
|
2007
|
-
|
|
2008
|
-
@category Object
|
|
2009
|
-
*/
|
|
2010
|
-
export type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
2011
|
-
/**
|
|
2012
|
-
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
2013
|
-
|
|
2014
|
-
@see {@link IsAny}
|
|
2015
|
-
|
|
2016
|
-
@example
|
|
2017
|
-
```
|
|
2018
|
-
import type {IfAny} from 'type-fest';
|
|
2019
|
-
|
|
2020
|
-
type ShouldBeTrue = IfAny<any>;
|
|
2021
|
-
//=> true
|
|
2022
|
-
|
|
2023
|
-
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
2024
|
-
//=> 'bar'
|
|
2025
|
-
```
|
|
2026
|
-
|
|
2027
|
-
@category Type Guard
|
|
2028
|
-
@category Utilities
|
|
2029
|
-
*/
|
|
2030
|
-
export type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
2031
|
-
/**
|
|
2032
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
2033
|
-
*/
|
|
2034
|
-
export type BuiltIns = Primitive$1 | void | Date | RegExp;
|
|
2035
|
-
/**
|
|
2036
|
-
Matches non-recursive types.
|
|
2037
|
-
*/
|
|
2038
|
-
export type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown);
|
|
2039
|
-
/**
|
|
2040
|
-
Merges user specified options with default options.
|
|
2041
|
-
|
|
2042
|
-
@example
|
|
2043
|
-
```
|
|
2044
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
2045
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
2046
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
2047
|
-
|
|
2048
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
2049
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
2050
|
-
```
|
|
2051
|
-
|
|
2052
|
-
@example
|
|
2053
|
-
```
|
|
2054
|
-
// Complains if default values are not provided for optional options
|
|
2055
|
-
|
|
2056
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
2057
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
2058
|
-
type SpecifiedOptions = {};
|
|
2059
|
-
|
|
2060
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
2061
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
2062
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
2063
|
-
```
|
|
2064
|
-
|
|
2065
|
-
@example
|
|
2066
|
-
```
|
|
2067
|
-
// Complains if an option's default type does not conform to the expected type
|
|
2068
|
-
|
|
2069
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
2070
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
2071
|
-
type SpecifiedOptions = {};
|
|
2072
|
-
|
|
2073
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
2074
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
2075
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
2076
|
-
```
|
|
2077
|
-
|
|
2078
|
-
@example
|
|
2079
|
-
```
|
|
2080
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
2081
|
-
|
|
2082
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
2083
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
2084
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
2085
|
-
|
|
2086
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
2087
|
-
// ~~~~~~~~~~~~~~~~
|
|
2088
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
2089
|
-
```
|
|
2090
|
-
*/
|
|
2091
|
-
export type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny<SpecifiedOptions, Defaults, IfNever<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, {
|
|
2092
|
-
[Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key];
|
|
2093
|
-
}> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
2094
|
-
>>;
|
|
2095
|
-
/**
|
|
2096
|
-
Recursively simplifies a type while including and/or excluding certain types from being simplified.
|
|
2097
|
-
|
|
2098
|
-
This type is **experimental** and was introduced as a result of this {@link https://github.com/sindresorhus/type-fest/issues/436 issue}. It should be used with caution.
|
|
2099
|
-
|
|
2100
|
-
See {@link ConditionalSimplify} for usages and examples.
|
|
2101
|
-
|
|
2102
|
-
@internal
|
|
2103
|
-
@experimental
|
|
2104
|
-
@category Object
|
|
2105
|
-
*/
|
|
2106
|
-
export type ConditionalSimplifyDeep<Type, ExcludeType = never, IncludeType = unknown> = Type extends ExcludeType ? Type : Type extends IncludeType ? {
|
|
2107
|
-
[TypeKey in keyof Type]: ConditionalSimplifyDeep<Type[TypeKey], ExcludeType, IncludeType>;
|
|
2108
|
-
} : Type;
|
|
2109
|
-
/**
|
|
2110
|
-
Deeply simplifies an object type.
|
|
2111
|
-
|
|
2112
|
-
You can exclude certain types from being simplified by providing them in the second generic `ExcludeType`.
|
|
2113
|
-
|
|
2114
|
-
Useful to flatten the type output to improve type hints shown in editors.
|
|
2115
|
-
|
|
2116
|
-
@example
|
|
2117
|
-
```
|
|
2118
|
-
import type {SimplifyDeep} from 'type-fest';
|
|
2119
|
-
|
|
2120
|
-
type PositionX = {
|
|
2121
|
-
left: number;
|
|
2122
|
-
right: number;
|
|
2123
|
-
};
|
|
2124
|
-
|
|
2125
|
-
type PositionY = {
|
|
2126
|
-
top: number;
|
|
2127
|
-
bottom: number;
|
|
2128
|
-
};
|
|
2129
|
-
|
|
2130
|
-
type Properties1 = {
|
|
2131
|
-
height: number;
|
|
2132
|
-
position: PositionY;
|
|
2133
|
-
};
|
|
2134
|
-
|
|
2135
|
-
type Properties2 = {
|
|
2136
|
-
width: number;
|
|
2137
|
-
position: PositionX;
|
|
2138
|
-
};
|
|
2139
|
-
|
|
2140
|
-
type Properties = Properties1 & Properties2;
|
|
2141
|
-
// In your editor, hovering over `Props` will show the following:
|
|
2142
|
-
//
|
|
2143
|
-
// type Properties = Properties1 & Properties2;
|
|
2144
|
-
|
|
2145
|
-
type SimplifyDeepProperties = SimplifyDeep<Properties1 & Properties2>;
|
|
2146
|
-
// But if wrapped in SimplifyDeep, hovering over `SimplifyDeepProperties` will show a flattened object with all the properties:
|
|
1930
|
+
// Note: We also allow `null` as a valid value because Svelte treats this the same as `undefined`
|
|
1931
|
+
export type Booleanish = boolean | "true" | "false";
|
|
2147
1932
|
//
|
|
2148
|
-
//
|
|
2149
|
-
//
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
type
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
type PositionX = {
|
|
2173
|
-
left: number;
|
|
2174
|
-
right: number;
|
|
2175
|
-
};
|
|
2176
|
-
|
|
2177
|
-
type PositionY = {
|
|
2178
|
-
top: number;
|
|
2179
|
-
bottom: number;
|
|
2180
|
-
};
|
|
2181
|
-
|
|
2182
|
-
// You want to simplify all other types
|
|
2183
|
-
type Properties1 = {
|
|
2184
|
-
height: number;
|
|
2185
|
-
position: PositionY;
|
|
2186
|
-
foo: ComplexType;
|
|
2187
|
-
};
|
|
2188
|
-
|
|
2189
|
-
type Properties2 = {
|
|
2190
|
-
width: number;
|
|
2191
|
-
position: PositionX;
|
|
2192
|
-
foo: ComplexType;
|
|
2193
|
-
};
|
|
2194
|
-
|
|
2195
|
-
type SimplifyDeepProperties = SimplifyDeep<Properties1 & Properties2, ComplexType>;
|
|
2196
|
-
// If wrapped in `SimplifyDeep` and set `ComplexType` to exclude, hovering over `SimplifyDeepProperties` will
|
|
2197
|
-
// show a flattened object with all the properties except `ComplexType`:
|
|
2198
|
-
//
|
|
2199
|
-
// SimplifyDeepProperties = {
|
|
2200
|
-
// height: number;
|
|
2201
|
-
// width: number;
|
|
2202
|
-
// position: {
|
|
2203
|
-
// top: number;
|
|
2204
|
-
// bottom: number;
|
|
2205
|
-
// left: number;
|
|
2206
|
-
// right: number;
|
|
2207
|
-
// };
|
|
2208
|
-
// foo: ComplexType;
|
|
2209
|
-
// };
|
|
2210
|
-
```
|
|
2211
|
-
|
|
2212
|
-
@see Simplify
|
|
2213
|
-
@category Object
|
|
2214
|
-
*/
|
|
2215
|
-
export type SimplifyDeep<Type, ExcludeType = never> = ConditionalSimplifyDeep<Type, ExcludeType | NonRecursiveType | Set<unknown> | Map<unknown, unknown>, object>;
|
|
2216
|
-
/**
|
|
2217
|
-
@see {@link PartialDeep}
|
|
2218
|
-
*/
|
|
2219
|
-
export type PartialDeepOptions = {
|
|
2220
|
-
/**
|
|
2221
|
-
Whether to affect the individual elements of arrays and tuples.
|
|
2222
|
-
|
|
2223
|
-
@default false
|
|
2224
|
-
*/
|
|
2225
|
-
readonly recurseIntoArrays?: boolean;
|
|
2226
|
-
/**
|
|
2227
|
-
Allows `undefined` values in non-tuple arrays.
|
|
2228
|
-
|
|
2229
|
-
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
2230
|
-
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
2231
|
-
|
|
2232
|
-
@default true
|
|
2233
|
-
|
|
2234
|
-
@example
|
|
2235
|
-
You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
|
|
2236
|
-
|
|
2237
|
-
```
|
|
2238
|
-
import type {PartialDeep} from 'type-fest';
|
|
2239
|
-
|
|
2240
|
-
type Settings = {
|
|
2241
|
-
languages: string[];
|
|
2242
|
-
};
|
|
2243
|
-
|
|
2244
|
-
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}>;
|
|
2245
|
-
|
|
2246
|
-
partialSettings.languages = [undefined]; // Error
|
|
2247
|
-
partialSettings.languages = []; // Ok
|
|
2248
|
-
```
|
|
2249
|
-
*/
|
|
2250
|
-
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
2251
|
-
};
|
|
2252
|
-
export type DefaultPartialDeepOptions = {
|
|
2253
|
-
recurseIntoArrays: false;
|
|
2254
|
-
allowUndefinedInNonTupleArrays: true;
|
|
2255
|
-
};
|
|
2256
|
-
/**
|
|
2257
|
-
Create a type from another type with all keys and nested keys set to optional.
|
|
2258
|
-
|
|
2259
|
-
Use-cases:
|
|
2260
|
-
- Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
|
|
2261
|
-
- Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
|
|
2262
|
-
|
|
2263
|
-
@example
|
|
2264
|
-
```
|
|
2265
|
-
import type {PartialDeep} from 'type-fest';
|
|
2266
|
-
|
|
2267
|
-
const settings: Settings = {
|
|
2268
|
-
textEditor: {
|
|
2269
|
-
fontSize: 14,
|
|
2270
|
-
fontColor: '#000000',
|
|
2271
|
-
fontWeight: 400
|
|
2272
|
-
},
|
|
2273
|
-
autocomplete: false,
|
|
2274
|
-
autosave: true
|
|
2275
|
-
};
|
|
2276
|
-
|
|
2277
|
-
const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
|
|
2278
|
-
return {...settings, ...savedSettings};
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
2282
|
-
```
|
|
2283
|
-
|
|
2284
|
-
By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
|
|
2285
|
-
|
|
2286
|
-
```
|
|
2287
|
-
import type {PartialDeep} from 'type-fest';
|
|
2288
|
-
|
|
2289
|
-
type Settings = {
|
|
2290
|
-
languages: string[];
|
|
2291
|
-
}
|
|
2292
|
-
|
|
2293
|
-
const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
|
|
2294
|
-
languages: [undefined]
|
|
2295
|
-
};
|
|
2296
|
-
```
|
|
2297
|
-
|
|
2298
|
-
@see {@link PartialDeepOptions}
|
|
2299
|
-
|
|
2300
|
-
@category Object
|
|
2301
|
-
@category Array
|
|
2302
|
-
@category Set
|
|
2303
|
-
@category Map
|
|
2304
|
-
*/
|
|
2305
|
-
export type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
|
|
2306
|
-
export type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : IsNever<keyof T> extends true // For functions with no properties
|
|
2307
|
-
? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep<ItemType, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
2308
|
-
? Options["recurseIntoArrays"] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
2309
|
-
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
2310
|
-
? ReadonlyArray<_PartialDeep<Options["allowUndefinedInNonTupleArrays"] extends false ? ItemType : ItemType | undefined, Options>> : Array<_PartialDeep<Options["allowUndefinedInNonTupleArrays"] extends false ? ItemType : ItemType | undefined, Options>> : PartialObjectDeep<T, Options> // Tuples behave properly
|
|
2311
|
-
: T // If they don't opt into array testing, just use the original type
|
|
2312
|
-
: PartialObjectDeep<T, Options> : unknown;
|
|
2313
|
-
/**
|
|
2314
|
-
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
2315
|
-
*/
|
|
2316
|
-
export type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
2317
|
-
/**
|
|
2318
|
-
Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
|
|
2319
|
-
*/
|
|
2320
|
-
export type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
|
|
2321
|
-
/**
|
|
2322
|
-
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
2323
|
-
*/
|
|
2324
|
-
export type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
2325
|
-
/**
|
|
2326
|
-
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
2327
|
-
*/
|
|
2328
|
-
export type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
|
|
2329
|
-
/**
|
|
2330
|
-
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
2331
|
-
*/
|
|
2332
|
-
export type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = (ObjectType extends (...arguments_: any) => unknown ? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType> : {}) & ({
|
|
2333
|
-
[KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>;
|
|
2334
|
-
});
|
|
2335
|
-
declare const errorTranslationSchema: z.ZodObject<{
|
|
2336
|
-
blocked: z.ZodString;
|
|
2337
|
-
maintenance: z.ZodString;
|
|
2338
|
-
"rate-limit": z.ZodString;
|
|
2339
|
-
"server-error": z.ZodString;
|
|
2340
|
-
"too-short": z.ZodString;
|
|
2341
|
-
"too-long": z.ZodString;
|
|
2342
|
-
"quota-reached": z.ZodString;
|
|
2343
|
-
aborted: z.ZodString;
|
|
2344
|
-
"sse-error": z.ZodString;
|
|
2345
|
-
"client-error": z.ZodString;
|
|
2346
|
-
"unexpected-call": z.ZodString;
|
|
2347
|
-
"incomplete-error": z.ZodString;
|
|
2348
|
-
"feedback-failed": z.ZodString;
|
|
2349
|
-
"speech-not-supported": z.ZodString;
|
|
2350
|
-
"speech-transcription-failed": z.ZodString;
|
|
2351
|
-
"speech-no-text-detected": z.ZodString;
|
|
2352
|
-
"speech-microphone-access-denied": z.ZodString;
|
|
2353
|
-
"pii-detected": z.ZodString;
|
|
2354
|
-
}, "strip", z.ZodTypeAny, {
|
|
2355
|
-
"pii-detected": string;
|
|
2356
|
-
blocked: string;
|
|
2357
|
-
maintenance: string;
|
|
2358
|
-
"rate-limit": string;
|
|
2359
|
-
"server-error": string;
|
|
2360
|
-
"too-short": string;
|
|
2361
|
-
"too-long": string;
|
|
2362
|
-
"quota-reached": string;
|
|
2363
|
-
aborted: string;
|
|
2364
|
-
"unexpected-call": string;
|
|
2365
|
-
"sse-error": string;
|
|
2366
|
-
"client-error": string;
|
|
2367
|
-
"incomplete-error": string;
|
|
2368
|
-
"feedback-failed": string;
|
|
2369
|
-
"speech-not-supported": string;
|
|
2370
|
-
"speech-transcription-failed": string;
|
|
2371
|
-
"speech-no-text-detected": string;
|
|
2372
|
-
"speech-microphone-access-denied": string;
|
|
2373
|
-
}, {
|
|
2374
|
-
"pii-detected": string;
|
|
2375
|
-
blocked: string;
|
|
2376
|
-
maintenance: string;
|
|
2377
|
-
"rate-limit": string;
|
|
2378
|
-
"server-error": string;
|
|
2379
|
-
"too-short": string;
|
|
2380
|
-
"too-long": string;
|
|
2381
|
-
"quota-reached": string;
|
|
2382
|
-
aborted: string;
|
|
2383
|
-
"unexpected-call": string;
|
|
2384
|
-
"sse-error": string;
|
|
2385
|
-
"client-error": string;
|
|
2386
|
-
"incomplete-error": string;
|
|
2387
|
-
"feedback-failed": string;
|
|
2388
|
-
"speech-not-supported": string;
|
|
2389
|
-
"speech-transcription-failed": string;
|
|
2390
|
-
"speech-no-text-detected": string;
|
|
2391
|
-
"speech-microphone-access-denied": string;
|
|
2392
|
-
}>;
|
|
2393
|
-
declare const translationSchema: z.ZodObject<{
|
|
2394
|
-
predefinedQuestions: z.ZodString;
|
|
2395
|
-
introductionTitle: z.ZodString;
|
|
2396
|
-
introductionDisclaimer: z.ZodOptional<z.ZodString>;
|
|
2397
|
-
chatInputPlaceholder: z.ZodString;
|
|
2398
|
-
chatInputPlaceholderListening: z.ZodOptional<z.ZodString>;
|
|
2399
|
-
chatInputSubmit: z.ZodString;
|
|
2400
|
-
chatInputStartListening: z.ZodString;
|
|
2401
|
-
chatInputStopListening: z.ZodString;
|
|
2402
|
-
referenceLink: z.ZodString;
|
|
2403
|
-
referencesDisplay: z.ZodString;
|
|
2404
|
-
referencesHide: z.ZodString;
|
|
2405
|
-
referencesTitle: z.ZodString;
|
|
2406
|
-
referencesFurtherTitle: z.ZodString;
|
|
2407
|
-
newChat: z.ZodString;
|
|
2408
|
-
maintenanceModeError: z.ZodString;
|
|
2409
|
-
messageBotLoading: z.ZodString;
|
|
2410
|
-
messageBotError: z.ZodString;
|
|
2411
|
-
messageBotDefaultError: z.ZodString;
|
|
2412
|
-
noResultsFound: z.ZodString;
|
|
2413
|
-
chatFooterText: z.ZodOptional<z.ZodString>;
|
|
2414
|
-
scrollToBottom: z.ZodString;
|
|
2415
|
-
openButtonTitle: z.ZodOptional<z.ZodString>;
|
|
2416
|
-
openButtonDescription: z.ZodOptional<z.ZodString>;
|
|
2417
|
-
openMenu: z.ZodString;
|
|
2418
|
-
openInfo: z.ZodString;
|
|
2419
|
-
aboutThisChat: z.ZodOptional<z.ZodString>;
|
|
2420
|
-
closeMenu: z.ZodString;
|
|
2421
|
-
closeChat: z.ZodString;
|
|
2422
|
-
close: z.ZodString;
|
|
2423
|
-
send: z.ZodString;
|
|
2424
|
-
thankYouForFeedback: z.ZodString;
|
|
2425
|
-
giveFeedback: z.ZodString;
|
|
2426
|
-
sendFeedback: z.ZodString;
|
|
2427
|
-
feedbackFormTitle: z.ZodString;
|
|
2428
|
-
feedbackFormMessage: z.ZodString;
|
|
2429
|
-
feedbackFormMessagePlaceholder: z.ZodString;
|
|
2430
|
-
feedbackFormEmail: z.ZodString;
|
|
2431
|
-
feedbackFormEmailPlaceholder: z.ZodString;
|
|
2432
|
-
answerGood: z.ZodString;
|
|
2433
|
-
answerBad: z.ZodString;
|
|
2434
|
-
classificationSubmit: z.ZodString;
|
|
2435
|
-
classificationThankYou: z.ZodString;
|
|
2436
|
-
classificationTitle: z.ZodString;
|
|
2437
|
-
selectLanguage: z.ZodString;
|
|
2438
|
-
lightMode: z.ZodString;
|
|
2439
|
-
darkMode: z.ZodString;
|
|
2440
|
-
termsTitle: z.ZodOptional<z.ZodString>;
|
|
2441
|
-
termsContent: z.ZodOptional<z.ZodString>;
|
|
2442
|
-
selectors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
2443
|
-
name: z.ZodString;
|
|
2444
|
-
namePlural: z.ZodOptional<z.ZodString>;
|
|
2445
|
-
intro: z.ZodOptional<z.ZodString>;
|
|
2446
|
-
placeholder: z.ZodString;
|
|
2447
|
-
values: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
2448
|
-
}, "strip", z.ZodTypeAny, {
|
|
2449
|
-
values: Record<string, string>;
|
|
2450
|
-
name: string;
|
|
2451
|
-
placeholder: string;
|
|
2452
|
-
namePlural?: string | undefined;
|
|
2453
|
-
intro?: string | undefined;
|
|
2454
|
-
}, {
|
|
2455
|
-
values: Record<string, string>;
|
|
2456
|
-
name: string;
|
|
2457
|
-
placeholder: string;
|
|
2458
|
-
namePlural?: string | undefined;
|
|
2459
|
-
intro?: string | undefined;
|
|
2460
|
-
}>>>;
|
|
2461
|
-
hideSettings: z.ZodString;
|
|
2462
|
-
showSettings: z.ZodString;
|
|
2463
|
-
chooseAtLeastOneOption: z.ZodString;
|
|
2464
|
-
selectAll: z.ZodString;
|
|
2465
|
-
selectNone: z.ZodString;
|
|
2466
|
-
}, "strip", z.ZodTypeAny, {
|
|
2467
|
-
predefinedQuestions: string;
|
|
2468
|
-
introductionTitle: string;
|
|
2469
|
-
chatInputPlaceholder: string;
|
|
2470
|
-
chatInputSubmit: string;
|
|
2471
|
-
chatInputStartListening: string;
|
|
2472
|
-
chatInputStopListening: string;
|
|
2473
|
-
referenceLink: string;
|
|
2474
|
-
referencesDisplay: string;
|
|
2475
|
-
referencesHide: string;
|
|
2476
|
-
referencesTitle: string;
|
|
2477
|
-
referencesFurtherTitle: string;
|
|
2478
|
-
newChat: string;
|
|
2479
|
-
maintenanceModeError: string;
|
|
2480
|
-
messageBotLoading: string;
|
|
2481
|
-
messageBotError: string;
|
|
2482
|
-
messageBotDefaultError: string;
|
|
2483
|
-
noResultsFound: string;
|
|
2484
|
-
scrollToBottom: string;
|
|
2485
|
-
openMenu: string;
|
|
2486
|
-
openInfo: string;
|
|
2487
|
-
closeMenu: string;
|
|
2488
|
-
closeChat: string;
|
|
2489
|
-
close: string;
|
|
2490
|
-
send: string;
|
|
2491
|
-
thankYouForFeedback: string;
|
|
2492
|
-
giveFeedback: string;
|
|
2493
|
-
sendFeedback: string;
|
|
2494
|
-
feedbackFormTitle: string;
|
|
2495
|
-
feedbackFormMessage: string;
|
|
2496
|
-
feedbackFormMessagePlaceholder: string;
|
|
2497
|
-
feedbackFormEmail: string;
|
|
2498
|
-
feedbackFormEmailPlaceholder: string;
|
|
2499
|
-
answerGood: string;
|
|
2500
|
-
answerBad: string;
|
|
2501
|
-
classificationSubmit: string;
|
|
2502
|
-
classificationThankYou: string;
|
|
2503
|
-
classificationTitle: string;
|
|
2504
|
-
selectLanguage: string;
|
|
2505
|
-
lightMode: string;
|
|
2506
|
-
darkMode: string;
|
|
2507
|
-
hideSettings: string;
|
|
2508
|
-
showSettings: string;
|
|
2509
|
-
chooseAtLeastOneOption: string;
|
|
2510
|
-
selectAll: string;
|
|
2511
|
-
selectNone: string;
|
|
2512
|
-
introductionDisclaimer?: string | undefined;
|
|
2513
|
-
chatInputPlaceholderListening?: string | undefined;
|
|
2514
|
-
chatFooterText?: string | undefined;
|
|
2515
|
-
openButtonTitle?: string | undefined;
|
|
2516
|
-
openButtonDescription?: string | undefined;
|
|
2517
|
-
aboutThisChat?: string | undefined;
|
|
2518
|
-
termsTitle?: string | undefined;
|
|
2519
|
-
termsContent?: string | undefined;
|
|
2520
|
-
selectors?: Record<string, {
|
|
2521
|
-
values: Record<string, string>;
|
|
2522
|
-
name: string;
|
|
2523
|
-
placeholder: string;
|
|
2524
|
-
namePlural?: string | undefined;
|
|
2525
|
-
intro?: string | undefined;
|
|
2526
|
-
}> | undefined;
|
|
2527
|
-
}, {
|
|
2528
|
-
predefinedQuestions: string;
|
|
2529
|
-
introductionTitle: string;
|
|
2530
|
-
chatInputPlaceholder: string;
|
|
2531
|
-
chatInputSubmit: string;
|
|
2532
|
-
chatInputStartListening: string;
|
|
2533
|
-
chatInputStopListening: string;
|
|
2534
|
-
referenceLink: string;
|
|
2535
|
-
referencesDisplay: string;
|
|
2536
|
-
referencesHide: string;
|
|
2537
|
-
referencesTitle: string;
|
|
2538
|
-
referencesFurtherTitle: string;
|
|
2539
|
-
newChat: string;
|
|
2540
|
-
maintenanceModeError: string;
|
|
2541
|
-
messageBotLoading: string;
|
|
2542
|
-
messageBotError: string;
|
|
2543
|
-
messageBotDefaultError: string;
|
|
2544
|
-
noResultsFound: string;
|
|
2545
|
-
scrollToBottom: string;
|
|
2546
|
-
openMenu: string;
|
|
2547
|
-
openInfo: string;
|
|
2548
|
-
closeMenu: string;
|
|
2549
|
-
closeChat: string;
|
|
2550
|
-
close: string;
|
|
2551
|
-
send: string;
|
|
2552
|
-
thankYouForFeedback: string;
|
|
2553
|
-
giveFeedback: string;
|
|
2554
|
-
sendFeedback: string;
|
|
2555
|
-
feedbackFormTitle: string;
|
|
2556
|
-
feedbackFormMessage: string;
|
|
2557
|
-
feedbackFormMessagePlaceholder: string;
|
|
2558
|
-
feedbackFormEmail: string;
|
|
2559
|
-
feedbackFormEmailPlaceholder: string;
|
|
2560
|
-
answerGood: string;
|
|
2561
|
-
answerBad: string;
|
|
2562
|
-
classificationSubmit: string;
|
|
2563
|
-
classificationThankYou: string;
|
|
2564
|
-
classificationTitle: string;
|
|
2565
|
-
selectLanguage: string;
|
|
2566
|
-
lightMode: string;
|
|
2567
|
-
darkMode: string;
|
|
2568
|
-
hideSettings: string;
|
|
2569
|
-
showSettings: string;
|
|
2570
|
-
chooseAtLeastOneOption: string;
|
|
2571
|
-
selectAll: string;
|
|
2572
|
-
selectNone: string;
|
|
2573
|
-
introductionDisclaimer?: string | undefined;
|
|
2574
|
-
chatInputPlaceholderListening?: string | undefined;
|
|
2575
|
-
chatFooterText?: string | undefined;
|
|
2576
|
-
openButtonTitle?: string | undefined;
|
|
2577
|
-
openButtonDescription?: string | undefined;
|
|
2578
|
-
aboutThisChat?: string | undefined;
|
|
2579
|
-
termsTitle?: string | undefined;
|
|
2580
|
-
termsContent?: string | undefined;
|
|
2581
|
-
selectors?: Record<string, {
|
|
2582
|
-
values: Record<string, string>;
|
|
2583
|
-
name: string;
|
|
2584
|
-
placeholder: string;
|
|
2585
|
-
namePlural?: string | undefined;
|
|
2586
|
-
intro?: string | undefined;
|
|
2587
|
-
}> | undefined;
|
|
2588
|
-
}>;
|
|
2589
|
-
declare const languagesSchema: z.ZodEnum<[
|
|
2590
|
-
"en",
|
|
2591
|
-
"de",
|
|
2592
|
-
"fr",
|
|
2593
|
-
"it"
|
|
2594
|
-
]>;
|
|
2595
|
-
export type Language = z.infer<typeof languagesSchema>;
|
|
2596
|
-
export type Translation = z.infer<typeof translationSchema>;
|
|
2597
|
-
export type ErrorTranslation = z.infer<typeof errorTranslationSchema>;
|
|
2598
|
-
export type Translations = Record<Language, Translation>;
|
|
2599
|
-
export type TranslationsPartial = PartialDeep<Translations>;
|
|
2600
|
-
declare const SnippetReturn: unique symbol;
|
|
2601
|
-
// Use an interface instead of a type, makes for better intellisense info because the type is named in more situations.
|
|
2602
|
-
/**
|
|
2603
|
-
* The type of a `#snippet` block. You can use it to (for example) express that your component expects a snippet of a certain type:
|
|
2604
|
-
* ```ts
|
|
2605
|
-
* let { banner }: { banner: Snippet<[{ text: string }]> } = $props();
|
|
2606
|
-
* ```
|
|
2607
|
-
* You can only call a snippet through the `{@render ...}` tag.
|
|
2608
|
-
*
|
|
2609
|
-
* See the [snippet documentation](https://svelte.dev/docs/svelte/snippet) for more info.
|
|
2610
|
-
*
|
|
2611
|
-
* @template Parameters the parameters that the snippet expects (if any) as a tuple.
|
|
2612
|
-
*/
|
|
2613
|
-
export interface Snippet<Parameters extends unknown[] = [
|
|
2614
|
-
]> {
|
|
2615
|
-
(this: void,
|
|
2616
|
-
// this conditional allows tuples but not arrays. Arrays would indicate a
|
|
2617
|
-
// rest parameter type, which is not supported. If rest parameters are added
|
|
2618
|
-
// in the future, the condition can be removed.
|
|
2619
|
-
...args: number extends Parameters["length"] ? never : Parameters): {
|
|
2620
|
-
"{@render ...} must be called with a Snippet": "import type { Snippet } from 'svelte'";
|
|
2621
|
-
} & typeof SnippetReturn;
|
|
2622
|
-
}
|
|
2623
|
-
/**
|
|
2624
|
-
* An [attachment](https://svelte.dev/docs/svelte/@attach) is a function that runs when an element is mounted
|
|
2625
|
-
* to the DOM, and optionally returns a function that is called when the element is later removed.
|
|
2626
|
-
*
|
|
2627
|
-
* It can be attached to an element with an `{@attach ...}` tag, or by spreading an object containing
|
|
2628
|
-
* a property created with [`createAttachmentKey`](https://svelte.dev/docs/svelte/svelte-attachments#createAttachmentKey).
|
|
2629
|
-
*/
|
|
2630
|
-
export interface Attachment<T extends EventTarget = Element> {
|
|
2631
|
-
(element: T): void | (() => void);
|
|
2632
|
-
}
|
|
2633
|
-
// Note: We also allow `null` as a valid value because Svelte treats this the same as `undefined`
|
|
2634
|
-
export type Booleanish = boolean | "true" | "false";
|
|
2635
|
-
//
|
|
2636
|
-
// Event Handler Types
|
|
2637
|
-
// ----------------------------------------------------------------------
|
|
2638
|
-
export type EventHandler<E extends Event = Event, T extends EventTarget = Element> = (event: E & {
|
|
2639
|
-
currentTarget: EventTarget & T;
|
|
2640
|
-
}) => any;
|
|
2641
|
-
export type ClipboardEventHandler<T extends EventTarget> = EventHandler<ClipboardEvent, T>;
|
|
2642
|
-
export type CompositionEventHandler<T extends EventTarget> = EventHandler<CompositionEvent, T>;
|
|
2643
|
-
export type DragEventHandler<T extends EventTarget> = EventHandler<DragEvent, T>;
|
|
2644
|
-
export type FocusEventHandler<T extends EventTarget> = EventHandler<FocusEvent, T>;
|
|
2645
|
-
export type FormEventHandler<T extends EventTarget> = EventHandler<Event, T>;
|
|
2646
|
-
export type ChangeEventHandler<T extends EventTarget> = EventHandler<Event, T>;
|
|
2647
|
-
export type KeyboardEventHandler<T extends EventTarget> = EventHandler<KeyboardEvent, T>;
|
|
2648
|
-
export type MouseEventHandler<T extends EventTarget> = EventHandler<MouseEvent, T>;
|
|
2649
|
-
export type TouchEventHandler<T extends EventTarget> = EventHandler<TouchEvent, T>;
|
|
2650
|
-
export type PointerEventHandler<T extends EventTarget> = EventHandler<PointerEvent, T>;
|
|
2651
|
-
export type GamepadEventHandler<T extends EventTarget> = EventHandler<GamepadEvent, T>;
|
|
2652
|
-
export type UIEventHandler<T extends EventTarget> = EventHandler<UIEvent, T>;
|
|
2653
|
-
export type WheelEventHandler<T extends EventTarget> = EventHandler<WheelEvent, T>;
|
|
2654
|
-
export type AnimationEventHandler<T extends EventTarget> = EventHandler<AnimationEvent, T>;
|
|
2655
|
-
export type TransitionEventHandler<T extends EventTarget> = EventHandler<TransitionEvent, T>;
|
|
2656
|
-
export type MessageEventHandler<T extends EventTarget> = EventHandler<MessageEvent, T>;
|
|
2657
|
-
export type ToggleEventHandler<T extends EventTarget> = EventHandler<ToggleEvent, T>;
|
|
2658
|
-
export type ContentVisibilityAutoStateChangeEventHandler<T extends EventTarget> = EventHandler<ContentVisibilityAutoStateChangeEvent, T>;
|
|
2659
|
-
export type FullAutoFill = AutoFill | "bday" | `${OptionalPrefixToken<AutoFillAddressKind>}${"cc-additional-name"}` | "nickname" | "language" | "organization-title" | "photo" | "sex" | "url";
|
|
1933
|
+
// Event Handler Types
|
|
1934
|
+
// ----------------------------------------------------------------------
|
|
1935
|
+
export type EventHandler<E extends Event = Event, T extends EventTarget = Element> = (event: E & {
|
|
1936
|
+
currentTarget: EventTarget & T;
|
|
1937
|
+
}) => any;
|
|
1938
|
+
export type ClipboardEventHandler<T extends EventTarget> = EventHandler<ClipboardEvent, T>;
|
|
1939
|
+
export type CompositionEventHandler<T extends EventTarget> = EventHandler<CompositionEvent, T>;
|
|
1940
|
+
export type DragEventHandler<T extends EventTarget> = EventHandler<DragEvent, T>;
|
|
1941
|
+
export type FocusEventHandler<T extends EventTarget> = EventHandler<FocusEvent, T>;
|
|
1942
|
+
export type FormEventHandler<T extends EventTarget> = EventHandler<Event, T>;
|
|
1943
|
+
export type ChangeEventHandler<T extends EventTarget> = EventHandler<Event, T>;
|
|
1944
|
+
export type KeyboardEventHandler<T extends EventTarget> = EventHandler<KeyboardEvent, T>;
|
|
1945
|
+
export type MouseEventHandler<T extends EventTarget> = EventHandler<MouseEvent, T>;
|
|
1946
|
+
export type TouchEventHandler<T extends EventTarget> = EventHandler<TouchEvent, T>;
|
|
1947
|
+
export type PointerEventHandler<T extends EventTarget> = EventHandler<PointerEvent, T>;
|
|
1948
|
+
export type GamepadEventHandler<T extends EventTarget> = EventHandler<GamepadEvent, T>;
|
|
1949
|
+
export type UIEventHandler<T extends EventTarget> = EventHandler<UIEvent, T>;
|
|
1950
|
+
export type WheelEventHandler<T extends EventTarget> = EventHandler<WheelEvent, T>;
|
|
1951
|
+
export type AnimationEventHandler<T extends EventTarget> = EventHandler<AnimationEvent, T>;
|
|
1952
|
+
export type TransitionEventHandler<T extends EventTarget> = EventHandler<TransitionEvent, T>;
|
|
1953
|
+
export type MessageEventHandler<T extends EventTarget> = EventHandler<MessageEvent, T>;
|
|
1954
|
+
export type ToggleEventHandler<T extends EventTarget> = EventHandler<ToggleEvent, T>;
|
|
1955
|
+
export type ContentVisibilityAutoStateChangeEventHandler<T extends EventTarget> = EventHandler<ContentVisibilityAutoStateChangeEvent, T>;
|
|
1956
|
+
export type FullAutoFill = AutoFill | "bday" | `${OptionalPrefixToken<AutoFillAddressKind>}${"cc-additional-name"}` | "nickname" | "language" | "organization-title" | "photo" | "sex" | "url";
|
|
2660
1957
|
//
|
|
2661
1958
|
// DOM Attributes
|
|
2662
1959
|
// ----------------------------------------------------------------------
|
|
@@ -4320,7 +3617,732 @@ export interface SvelteHTMLElements {
|
|
|
4320
3617
|
[name: string]: any;
|
|
4321
3618
|
};
|
|
4322
3619
|
}
|
|
4323
|
-
export type ClassValue = string | import("clsx").ClassArray | import("clsx").ClassDictionary;
|
|
3620
|
+
export type ClassValue = string | import("clsx").ClassArray | import("clsx").ClassDictionary;
|
|
3621
|
+
type Primitive$1 = null | undefined | string | number | boolean | symbol | bigint;
|
|
3622
|
+
/**
|
|
3623
|
+
Extract all optional keys from the given type.
|
|
3624
|
+
|
|
3625
|
+
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
3626
|
+
|
|
3627
|
+
@example
|
|
3628
|
+
```
|
|
3629
|
+
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
3630
|
+
|
|
3631
|
+
interface User {
|
|
3632
|
+
name: string;
|
|
3633
|
+
surname: string;
|
|
3634
|
+
|
|
3635
|
+
luckyNumber?: number;
|
|
3636
|
+
}
|
|
3637
|
+
|
|
3638
|
+
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
3639
|
+
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
3640
|
+
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
3641
|
+
};
|
|
3642
|
+
|
|
3643
|
+
const update1: UpdateOperation<User> = {
|
|
3644
|
+
name: 'Alice'
|
|
3645
|
+
};
|
|
3646
|
+
|
|
3647
|
+
const update2: UpdateOperation<User> = {
|
|
3648
|
+
name: 'Bob',
|
|
3649
|
+
luckyNumber: REMOVE_FIELD
|
|
3650
|
+
};
|
|
3651
|
+
```
|
|
3652
|
+
|
|
3653
|
+
@category Utilities
|
|
3654
|
+
*/
|
|
3655
|
+
export type OptionalKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
|
|
3656
|
+
? (keyof {
|
|
3657
|
+
[Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never;
|
|
3658
|
+
}) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
|
|
3659
|
+
: never; // Should never happen
|
|
3660
|
+
/**
|
|
3661
|
+
Extract all required keys from the given type.
|
|
3662
|
+
|
|
3663
|
+
This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
|
3664
|
+
|
|
3665
|
+
@example
|
|
3666
|
+
```
|
|
3667
|
+
import type {RequiredKeysOf} from 'type-fest';
|
|
3668
|
+
|
|
3669
|
+
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
3670
|
+
|
|
3671
|
+
interface User {
|
|
3672
|
+
name: string;
|
|
3673
|
+
surname: string;
|
|
3674
|
+
|
|
3675
|
+
luckyNumber?: number;
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3678
|
+
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
3679
|
+
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
3680
|
+
```
|
|
3681
|
+
|
|
3682
|
+
@category Utilities
|
|
3683
|
+
*/
|
|
3684
|
+
export type RequiredKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
|
|
3685
|
+
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never; // Should never happen
|
|
3686
|
+
/**
|
|
3687
|
+
Returns a boolean for whether the given type is `never`.
|
|
3688
|
+
|
|
3689
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
3690
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
3691
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
3692
|
+
|
|
3693
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
3694
|
+
|
|
3695
|
+
@example
|
|
3696
|
+
```
|
|
3697
|
+
import type {IsNever, And} from 'type-fest';
|
|
3698
|
+
|
|
3699
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
3700
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
3701
|
+
And<
|
|
3702
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
3703
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
3704
|
+
>;
|
|
3705
|
+
|
|
3706
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
3707
|
+
AreStringsEqual<I, O> extends true
|
|
3708
|
+
? never
|
|
3709
|
+
: void;
|
|
3710
|
+
|
|
3711
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
3712
|
+
if (input === output) {
|
|
3713
|
+
process.exit(0);
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3717
|
+
endIfEqual('abc', 'abc');
|
|
3718
|
+
//=> never
|
|
3719
|
+
|
|
3720
|
+
endIfEqual('abc', '123');
|
|
3721
|
+
//=> void
|
|
3722
|
+
```
|
|
3723
|
+
|
|
3724
|
+
@category Type Guard
|
|
3725
|
+
@category Utilities
|
|
3726
|
+
*/
|
|
3727
|
+
export type IsNever<T> = [
|
|
3728
|
+
T
|
|
3729
|
+
] extends [
|
|
3730
|
+
never
|
|
3731
|
+
] ? true : false;
|
|
3732
|
+
/**
|
|
3733
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
3734
|
+
|
|
3735
|
+
@see {@link IsNever}
|
|
3736
|
+
|
|
3737
|
+
@example
|
|
3738
|
+
```
|
|
3739
|
+
import type {IfNever} from 'type-fest';
|
|
3740
|
+
|
|
3741
|
+
type ShouldBeTrue = IfNever<never>;
|
|
3742
|
+
//=> true
|
|
3743
|
+
|
|
3744
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
3745
|
+
//=> 'bar'
|
|
3746
|
+
```
|
|
3747
|
+
|
|
3748
|
+
@category Type Guard
|
|
3749
|
+
@category Utilities
|
|
3750
|
+
*/
|
|
3751
|
+
export type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
3752
|
+
type NoInfer$1<T> = T extends infer U ? U : never;
|
|
3753
|
+
/**
|
|
3754
|
+
Returns a boolean for whether the given type is `any`.
|
|
3755
|
+
|
|
3756
|
+
@link https://stackoverflow.com/a/49928360/1490091
|
|
3757
|
+
|
|
3758
|
+
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
3759
|
+
|
|
3760
|
+
@example
|
|
3761
|
+
```
|
|
3762
|
+
import type {IsAny} from 'type-fest';
|
|
3763
|
+
|
|
3764
|
+
const typedObject = {a: 1, b: 2} as const;
|
|
3765
|
+
const anyObject: any = {a: 1, b: 2};
|
|
3766
|
+
|
|
3767
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
3768
|
+
return obj[key];
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
const typedA = get(typedObject, 'a');
|
|
3772
|
+
//=> 1
|
|
3773
|
+
|
|
3774
|
+
const anyA = get(anyObject, 'a');
|
|
3775
|
+
//=> any
|
|
3776
|
+
```
|
|
3777
|
+
|
|
3778
|
+
@category Type Guard
|
|
3779
|
+
@category Utilities
|
|
3780
|
+
*/
|
|
3781
|
+
export type IsAny<T> = 0 extends 1 & NoInfer$1<T> ? true : false;
|
|
3782
|
+
/**
|
|
3783
|
+
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.
|
|
3784
|
+
|
|
3785
|
+
@example
|
|
3786
|
+
```
|
|
3787
|
+
import type {Simplify} from 'type-fest';
|
|
3788
|
+
|
|
3789
|
+
type PositionProps = {
|
|
3790
|
+
top: number;
|
|
3791
|
+
left: number;
|
|
3792
|
+
};
|
|
3793
|
+
|
|
3794
|
+
type SizeProps = {
|
|
3795
|
+
width: number;
|
|
3796
|
+
height: number;
|
|
3797
|
+
};
|
|
3798
|
+
|
|
3799
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
3800
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
|
3801
|
+
```
|
|
3802
|
+
|
|
3803
|
+
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
3804
|
+
|
|
3805
|
+
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
3806
|
+
|
|
3807
|
+
@example
|
|
3808
|
+
```
|
|
3809
|
+
import type {Simplify} from 'type-fest';
|
|
3810
|
+
|
|
3811
|
+
interface SomeInterface {
|
|
3812
|
+
foo: number;
|
|
3813
|
+
bar?: string;
|
|
3814
|
+
baz: number | undefined;
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3817
|
+
type SomeType = {
|
|
3818
|
+
foo: number;
|
|
3819
|
+
bar?: string;
|
|
3820
|
+
baz: number | undefined;
|
|
3821
|
+
};
|
|
3822
|
+
|
|
3823
|
+
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
3824
|
+
const someType: SomeType = literal;
|
|
3825
|
+
const someInterface: SomeInterface = literal;
|
|
3826
|
+
|
|
3827
|
+
function fn(object: Record<string, unknown>): void {}
|
|
3828
|
+
|
|
3829
|
+
fn(literal); // Good: literal object type is sealed
|
|
3830
|
+
fn(someType); // Good: type is sealed
|
|
3831
|
+
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
3832
|
+
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
3833
|
+
```
|
|
3834
|
+
|
|
3835
|
+
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
3836
|
+
@see SimplifyDeep
|
|
3837
|
+
@category Object
|
|
3838
|
+
*/
|
|
3839
|
+
export type Simplify<T> = {
|
|
3840
|
+
[KeyType in keyof T]: T[KeyType];
|
|
3841
|
+
} & {};
|
|
3842
|
+
/**
|
|
3843
|
+
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
3844
|
+
|
|
3845
|
+
This is the counterpart of `PickIndexSignature`.
|
|
3846
|
+
|
|
3847
|
+
Use-cases:
|
|
3848
|
+
- Remove overly permissive signatures from third-party types.
|
|
3849
|
+
|
|
3850
|
+
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
3851
|
+
|
|
3852
|
+
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
3853
|
+
|
|
3854
|
+
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
3855
|
+
|
|
3856
|
+
```
|
|
3857
|
+
const indexed: Record<string, unknown> = {}; // Allowed
|
|
3858
|
+
|
|
3859
|
+
const keyed: Record<'foo', unknown> = {}; // Error
|
|
3860
|
+
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
3861
|
+
```
|
|
3862
|
+
|
|
3863
|
+
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
3864
|
+
|
|
3865
|
+
```
|
|
3866
|
+
type Indexed = {} extends Record<string, unknown>
|
|
3867
|
+
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
3868
|
+
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
3869
|
+
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
3870
|
+
|
|
3871
|
+
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
3872
|
+
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
3873
|
+
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
3874
|
+
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
3875
|
+
```
|
|
3876
|
+
|
|
3877
|
+
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
3878
|
+
|
|
3879
|
+
```
|
|
3880
|
+
import type {OmitIndexSignature} from 'type-fest';
|
|
3881
|
+
|
|
3882
|
+
type OmitIndexSignature<ObjectType> = {
|
|
3883
|
+
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
3884
|
+
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
3885
|
+
};
|
|
3886
|
+
```
|
|
3887
|
+
|
|
3888
|
+
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
3889
|
+
|
|
3890
|
+
```
|
|
3891
|
+
import type {OmitIndexSignature} from 'type-fest';
|
|
3892
|
+
|
|
3893
|
+
type OmitIndexSignature<ObjectType> = {
|
|
3894
|
+
[KeyType in keyof ObjectType
|
|
3895
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
3896
|
+
as {} extends Record<KeyType, unknown>
|
|
3897
|
+
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
3898
|
+
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
3899
|
+
]: ObjectType[KeyType];
|
|
3900
|
+
};
|
|
3901
|
+
```
|
|
3902
|
+
|
|
3903
|
+
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
3904
|
+
|
|
3905
|
+
@example
|
|
3906
|
+
```
|
|
3907
|
+
import type {OmitIndexSignature} from 'type-fest';
|
|
3908
|
+
|
|
3909
|
+
interface Example {
|
|
3910
|
+
// These index signatures will be removed.
|
|
3911
|
+
[x: string]: any
|
|
3912
|
+
[x: number]: any
|
|
3913
|
+
[x: symbol]: any
|
|
3914
|
+
[x: `head-${string}`]: string
|
|
3915
|
+
[x: `${string}-tail`]: string
|
|
3916
|
+
[x: `head-${string}-tail`]: string
|
|
3917
|
+
[x: `${bigint}`]: string
|
|
3918
|
+
[x: `embedded-${number}`]: string
|
|
3919
|
+
|
|
3920
|
+
// These explicitly defined keys will remain.
|
|
3921
|
+
foo: 'bar';
|
|
3922
|
+
qux?: 'baz';
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
3926
|
+
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
3927
|
+
```
|
|
3928
|
+
|
|
3929
|
+
@see PickIndexSignature
|
|
3930
|
+
@category Object
|
|
3931
|
+
*/
|
|
3932
|
+
export type OmitIndexSignature<ObjectType> = {
|
|
3933
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
|
|
3934
|
+
};
|
|
3935
|
+
/**
|
|
3936
|
+
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
3937
|
+
|
|
3938
|
+
This is the counterpart of `OmitIndexSignature`.
|
|
3939
|
+
|
|
3940
|
+
@example
|
|
3941
|
+
```
|
|
3942
|
+
import type {PickIndexSignature} from 'type-fest';
|
|
3943
|
+
|
|
3944
|
+
declare const symbolKey: unique symbol;
|
|
3945
|
+
|
|
3946
|
+
type Example = {
|
|
3947
|
+
// These index signatures will remain.
|
|
3948
|
+
[x: string]: unknown;
|
|
3949
|
+
[x: number]: unknown;
|
|
3950
|
+
[x: symbol]: unknown;
|
|
3951
|
+
[x: `head-${string}`]: string;
|
|
3952
|
+
[x: `${string}-tail`]: string;
|
|
3953
|
+
[x: `head-${string}-tail`]: string;
|
|
3954
|
+
[x: `${bigint}`]: string;
|
|
3955
|
+
[x: `embedded-${number}`]: string;
|
|
3956
|
+
|
|
3957
|
+
// These explicitly defined keys will be removed.
|
|
3958
|
+
['kebab-case-key']: string;
|
|
3959
|
+
[symbolKey]: string;
|
|
3960
|
+
foo: 'bar';
|
|
3961
|
+
qux?: 'baz';
|
|
3962
|
+
};
|
|
3963
|
+
|
|
3964
|
+
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
3965
|
+
// {
|
|
3966
|
+
// [x: string]: unknown;
|
|
3967
|
+
// [x: number]: unknown;
|
|
3968
|
+
// [x: symbol]: unknown;
|
|
3969
|
+
// [x: `head-${string}`]: string;
|
|
3970
|
+
// [x: `${string}-tail`]: string;
|
|
3971
|
+
// [x: `head-${string}-tail`]: string;
|
|
3972
|
+
// [x: `${bigint}`]: string;
|
|
3973
|
+
// [x: `embedded-${number}`]: string;
|
|
3974
|
+
// }
|
|
3975
|
+
```
|
|
3976
|
+
|
|
3977
|
+
@see OmitIndexSignature
|
|
3978
|
+
@category Object
|
|
3979
|
+
*/
|
|
3980
|
+
export type PickIndexSignature<ObjectType> = {
|
|
3981
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType];
|
|
3982
|
+
};
|
|
3983
|
+
// Merges two objects without worrying about index signatures.
|
|
3984
|
+
export type SimpleMerge<Destination, Source> = {
|
|
3985
|
+
[Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
|
|
3986
|
+
} & Source;
|
|
3987
|
+
/**
|
|
3988
|
+
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
3989
|
+
|
|
3990
|
+
@example
|
|
3991
|
+
```
|
|
3992
|
+
import type {Merge} from 'type-fest';
|
|
3993
|
+
|
|
3994
|
+
interface Foo {
|
|
3995
|
+
[x: string]: unknown;
|
|
3996
|
+
[x: number]: unknown;
|
|
3997
|
+
foo: string;
|
|
3998
|
+
bar: symbol;
|
|
3999
|
+
}
|
|
4000
|
+
|
|
4001
|
+
type Bar = {
|
|
4002
|
+
[x: number]: number;
|
|
4003
|
+
[x: symbol]: unknown;
|
|
4004
|
+
bar: Date;
|
|
4005
|
+
baz: boolean;
|
|
4006
|
+
};
|
|
4007
|
+
|
|
4008
|
+
export type FooBar = Merge<Foo, Bar>;
|
|
4009
|
+
// => {
|
|
4010
|
+
// [x: string]: unknown;
|
|
4011
|
+
// [x: number]: number;
|
|
4012
|
+
// [x: symbol]: unknown;
|
|
4013
|
+
// foo: string;
|
|
4014
|
+
// bar: Date;
|
|
4015
|
+
// baz: boolean;
|
|
4016
|
+
// }
|
|
4017
|
+
```
|
|
4018
|
+
|
|
4019
|
+
@category Object
|
|
4020
|
+
*/
|
|
4021
|
+
export type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
4022
|
+
/**
|
|
4023
|
+
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
4024
|
+
|
|
4025
|
+
@see {@link IsAny}
|
|
4026
|
+
|
|
4027
|
+
@example
|
|
4028
|
+
```
|
|
4029
|
+
import type {IfAny} from 'type-fest';
|
|
4030
|
+
|
|
4031
|
+
type ShouldBeTrue = IfAny<any>;
|
|
4032
|
+
//=> true
|
|
4033
|
+
|
|
4034
|
+
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
4035
|
+
//=> 'bar'
|
|
4036
|
+
```
|
|
4037
|
+
|
|
4038
|
+
@category Type Guard
|
|
4039
|
+
@category Utilities
|
|
4040
|
+
*/
|
|
4041
|
+
export type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
4042
|
+
/**
|
|
4043
|
+
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
4044
|
+
*/
|
|
4045
|
+
export type BuiltIns = Primitive$1 | void | Date | RegExp;
|
|
4046
|
+
/**
|
|
4047
|
+
Matches non-recursive types.
|
|
4048
|
+
*/
|
|
4049
|
+
export type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown);
|
|
4050
|
+
/**
|
|
4051
|
+
Merges user specified options with default options.
|
|
4052
|
+
|
|
4053
|
+
@example
|
|
4054
|
+
```
|
|
4055
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
4056
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
4057
|
+
type SpecifiedOptions = {leavesOnly: true};
|
|
4058
|
+
|
|
4059
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
4060
|
+
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
4061
|
+
```
|
|
4062
|
+
|
|
4063
|
+
@example
|
|
4064
|
+
```
|
|
4065
|
+
// Complains if default values are not provided for optional options
|
|
4066
|
+
|
|
4067
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
4068
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
4069
|
+
type SpecifiedOptions = {};
|
|
4070
|
+
|
|
4071
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
4072
|
+
// ~~~~~~~~~~~~~~~~~~~
|
|
4073
|
+
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
4074
|
+
```
|
|
4075
|
+
|
|
4076
|
+
@example
|
|
4077
|
+
```
|
|
4078
|
+
// Complains if an option's default type does not conform to the expected type
|
|
4079
|
+
|
|
4080
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
4081
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
4082
|
+
type SpecifiedOptions = {};
|
|
4083
|
+
|
|
4084
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
4085
|
+
// ~~~~~~~~~~~~~~~~~~~
|
|
4086
|
+
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
4087
|
+
```
|
|
4088
|
+
|
|
4089
|
+
@example
|
|
4090
|
+
```
|
|
4091
|
+
// Complains if an option's specified type does not conform to the expected type
|
|
4092
|
+
|
|
4093
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
4094
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
4095
|
+
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
4096
|
+
|
|
4097
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
4098
|
+
// ~~~~~~~~~~~~~~~~
|
|
4099
|
+
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
4100
|
+
```
|
|
4101
|
+
*/
|
|
4102
|
+
export type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny<SpecifiedOptions, Defaults, IfNever<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, {
|
|
4103
|
+
[Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key];
|
|
4104
|
+
}> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
4105
|
+
>>;
|
|
4106
|
+
/**
|
|
4107
|
+
Recursively simplifies a type while including and/or excluding certain types from being simplified.
|
|
4108
|
+
|
|
4109
|
+
This type is **experimental** and was introduced as a result of this {@link https://github.com/sindresorhus/type-fest/issues/436 issue}. It should be used with caution.
|
|
4110
|
+
|
|
4111
|
+
See {@link ConditionalSimplify} for usages and examples.
|
|
4112
|
+
|
|
4113
|
+
@internal
|
|
4114
|
+
@experimental
|
|
4115
|
+
@category Object
|
|
4116
|
+
*/
|
|
4117
|
+
export type ConditionalSimplifyDeep<Type, ExcludeType = never, IncludeType = unknown> = Type extends ExcludeType ? Type : Type extends IncludeType ? {
|
|
4118
|
+
[TypeKey in keyof Type]: ConditionalSimplifyDeep<Type[TypeKey], ExcludeType, IncludeType>;
|
|
4119
|
+
} : Type;
|
|
4120
|
+
/**
|
|
4121
|
+
Deeply simplifies an object type.
|
|
4122
|
+
|
|
4123
|
+
You can exclude certain types from being simplified by providing them in the second generic `ExcludeType`.
|
|
4124
|
+
|
|
4125
|
+
Useful to flatten the type output to improve type hints shown in editors.
|
|
4126
|
+
|
|
4127
|
+
@example
|
|
4128
|
+
```
|
|
4129
|
+
import type {SimplifyDeep} from 'type-fest';
|
|
4130
|
+
|
|
4131
|
+
type PositionX = {
|
|
4132
|
+
left: number;
|
|
4133
|
+
right: number;
|
|
4134
|
+
};
|
|
4135
|
+
|
|
4136
|
+
type PositionY = {
|
|
4137
|
+
top: number;
|
|
4138
|
+
bottom: number;
|
|
4139
|
+
};
|
|
4140
|
+
|
|
4141
|
+
type Properties1 = {
|
|
4142
|
+
height: number;
|
|
4143
|
+
position: PositionY;
|
|
4144
|
+
};
|
|
4145
|
+
|
|
4146
|
+
type Properties2 = {
|
|
4147
|
+
width: number;
|
|
4148
|
+
position: PositionX;
|
|
4149
|
+
};
|
|
4150
|
+
|
|
4151
|
+
type Properties = Properties1 & Properties2;
|
|
4152
|
+
// In your editor, hovering over `Props` will show the following:
|
|
4153
|
+
//
|
|
4154
|
+
// type Properties = Properties1 & Properties2;
|
|
4155
|
+
|
|
4156
|
+
type SimplifyDeepProperties = SimplifyDeep<Properties1 & Properties2>;
|
|
4157
|
+
// But if wrapped in SimplifyDeep, hovering over `SimplifyDeepProperties` will show a flattened object with all the properties:
|
|
4158
|
+
//
|
|
4159
|
+
// SimplifyDeepProperties = {
|
|
4160
|
+
// height: number;
|
|
4161
|
+
// width: number;
|
|
4162
|
+
// position: {
|
|
4163
|
+
// top: number;
|
|
4164
|
+
// bottom: number;
|
|
4165
|
+
// left: number;
|
|
4166
|
+
// right: number;
|
|
4167
|
+
// };
|
|
4168
|
+
// };
|
|
4169
|
+
```
|
|
4170
|
+
|
|
4171
|
+
@example
|
|
4172
|
+
```
|
|
4173
|
+
import type {SimplifyDeep} from 'type-fest';
|
|
4174
|
+
|
|
4175
|
+
// A complex type that you don't want or need to simplify
|
|
4176
|
+
type ComplexType = {
|
|
4177
|
+
a: string;
|
|
4178
|
+
b: 'b';
|
|
4179
|
+
c: number;
|
|
4180
|
+
...
|
|
4181
|
+
};
|
|
4182
|
+
|
|
4183
|
+
type PositionX = {
|
|
4184
|
+
left: number;
|
|
4185
|
+
right: number;
|
|
4186
|
+
};
|
|
4187
|
+
|
|
4188
|
+
type PositionY = {
|
|
4189
|
+
top: number;
|
|
4190
|
+
bottom: number;
|
|
4191
|
+
};
|
|
4192
|
+
|
|
4193
|
+
// You want to simplify all other types
|
|
4194
|
+
type Properties1 = {
|
|
4195
|
+
height: number;
|
|
4196
|
+
position: PositionY;
|
|
4197
|
+
foo: ComplexType;
|
|
4198
|
+
};
|
|
4199
|
+
|
|
4200
|
+
type Properties2 = {
|
|
4201
|
+
width: number;
|
|
4202
|
+
position: PositionX;
|
|
4203
|
+
foo: ComplexType;
|
|
4204
|
+
};
|
|
4205
|
+
|
|
4206
|
+
type SimplifyDeepProperties = SimplifyDeep<Properties1 & Properties2, ComplexType>;
|
|
4207
|
+
// If wrapped in `SimplifyDeep` and set `ComplexType` to exclude, hovering over `SimplifyDeepProperties` will
|
|
4208
|
+
// show a flattened object with all the properties except `ComplexType`:
|
|
4209
|
+
//
|
|
4210
|
+
// SimplifyDeepProperties = {
|
|
4211
|
+
// height: number;
|
|
4212
|
+
// width: number;
|
|
4213
|
+
// position: {
|
|
4214
|
+
// top: number;
|
|
4215
|
+
// bottom: number;
|
|
4216
|
+
// left: number;
|
|
4217
|
+
// right: number;
|
|
4218
|
+
// };
|
|
4219
|
+
// foo: ComplexType;
|
|
4220
|
+
// };
|
|
4221
|
+
```
|
|
4222
|
+
|
|
4223
|
+
@see Simplify
|
|
4224
|
+
@category Object
|
|
4225
|
+
*/
|
|
4226
|
+
export type SimplifyDeep<Type, ExcludeType = never> = ConditionalSimplifyDeep<Type, ExcludeType | NonRecursiveType | Set<unknown> | Map<unknown, unknown>, object>;
|
|
4227
|
+
/**
|
|
4228
|
+
@see {@link PartialDeep}
|
|
4229
|
+
*/
|
|
4230
|
+
export type PartialDeepOptions = {
|
|
4231
|
+
/**
|
|
4232
|
+
Whether to affect the individual elements of arrays and tuples.
|
|
4233
|
+
|
|
4234
|
+
@default false
|
|
4235
|
+
*/
|
|
4236
|
+
readonly recurseIntoArrays?: boolean;
|
|
4237
|
+
/**
|
|
4238
|
+
Allows `undefined` values in non-tuple arrays.
|
|
4239
|
+
|
|
4240
|
+
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
4241
|
+
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
4242
|
+
|
|
4243
|
+
@default true
|
|
4244
|
+
|
|
4245
|
+
@example
|
|
4246
|
+
You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
|
|
4247
|
+
|
|
4248
|
+
```
|
|
4249
|
+
import type {PartialDeep} from 'type-fest';
|
|
4250
|
+
|
|
4251
|
+
type Settings = {
|
|
4252
|
+
languages: string[];
|
|
4253
|
+
};
|
|
4254
|
+
|
|
4255
|
+
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}>;
|
|
4256
|
+
|
|
4257
|
+
partialSettings.languages = [undefined]; // Error
|
|
4258
|
+
partialSettings.languages = []; // Ok
|
|
4259
|
+
```
|
|
4260
|
+
*/
|
|
4261
|
+
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
4262
|
+
};
|
|
4263
|
+
export type DefaultPartialDeepOptions = {
|
|
4264
|
+
recurseIntoArrays: false;
|
|
4265
|
+
allowUndefinedInNonTupleArrays: true;
|
|
4266
|
+
};
|
|
4267
|
+
/**
|
|
4268
|
+
Create a type from another type with all keys and nested keys set to optional.
|
|
4269
|
+
|
|
4270
|
+
Use-cases:
|
|
4271
|
+
- Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
|
|
4272
|
+
- Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
|
|
4273
|
+
|
|
4274
|
+
@example
|
|
4275
|
+
```
|
|
4276
|
+
import type {PartialDeep} from 'type-fest';
|
|
4277
|
+
|
|
4278
|
+
const settings: Settings = {
|
|
4279
|
+
textEditor: {
|
|
4280
|
+
fontSize: 14,
|
|
4281
|
+
fontColor: '#000000',
|
|
4282
|
+
fontWeight: 400
|
|
4283
|
+
},
|
|
4284
|
+
autocomplete: false,
|
|
4285
|
+
autosave: true
|
|
4286
|
+
};
|
|
4287
|
+
|
|
4288
|
+
const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
|
|
4289
|
+
return {...settings, ...savedSettings};
|
|
4290
|
+
}
|
|
4291
|
+
|
|
4292
|
+
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
4293
|
+
```
|
|
4294
|
+
|
|
4295
|
+
By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
|
|
4296
|
+
|
|
4297
|
+
```
|
|
4298
|
+
import type {PartialDeep} from 'type-fest';
|
|
4299
|
+
|
|
4300
|
+
type Settings = {
|
|
4301
|
+
languages: string[];
|
|
4302
|
+
}
|
|
4303
|
+
|
|
4304
|
+
const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
|
|
4305
|
+
languages: [undefined]
|
|
4306
|
+
};
|
|
4307
|
+
```
|
|
4308
|
+
|
|
4309
|
+
@see {@link PartialDeepOptions}
|
|
4310
|
+
|
|
4311
|
+
@category Object
|
|
4312
|
+
@category Array
|
|
4313
|
+
@category Set
|
|
4314
|
+
@category Map
|
|
4315
|
+
*/
|
|
4316
|
+
export type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
|
|
4317
|
+
export type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : IsNever<keyof T> extends true // For functions with no properties
|
|
4318
|
+
? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep<ItemType, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
4319
|
+
? Options["recurseIntoArrays"] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
4320
|
+
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
4321
|
+
? ReadonlyArray<_PartialDeep<Options["allowUndefinedInNonTupleArrays"] extends false ? ItemType : ItemType | undefined, Options>> : Array<_PartialDeep<Options["allowUndefinedInNonTupleArrays"] extends false ? ItemType : ItemType | undefined, Options>> : PartialObjectDeep<T, Options> // Tuples behave properly
|
|
4322
|
+
: T // If they don't opt into array testing, just use the original type
|
|
4323
|
+
: PartialObjectDeep<T, Options> : unknown;
|
|
4324
|
+
/**
|
|
4325
|
+
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
4326
|
+
*/
|
|
4327
|
+
export type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
4328
|
+
/**
|
|
4329
|
+
Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
|
|
4330
|
+
*/
|
|
4331
|
+
export type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
|
|
4332
|
+
/**
|
|
4333
|
+
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
4334
|
+
*/
|
|
4335
|
+
export type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
4336
|
+
/**
|
|
4337
|
+
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
4338
|
+
*/
|
|
4339
|
+
export type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
|
|
4340
|
+
/**
|
|
4341
|
+
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
4342
|
+
*/
|
|
4343
|
+
export type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = (ObjectType extends (...arguments_: any) => unknown ? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType> : {}) & ({
|
|
4344
|
+
[KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>;
|
|
4345
|
+
});
|
|
4324
4346
|
export type RemovePrefix<Prefix extends string, Value> = Value extends `${Prefix}${infer Rest}` ? Rest : Value;
|
|
4325
4347
|
export type OnlyOnKeys<Keys> = Keys extends `on${string}` ? (Keys extends `on:${string}` ? never : Keys) : never;
|
|
4326
4348
|
export type HtmlListenersFor<Obj> = {
|