diff --git a/src/features/achievements/achievement.tsx b/src/features/achievements/achievement.tsx index 29b5460..0919482 100644 --- a/src/features/achievements/achievement.tsx +++ b/src/features/achievements/achievement.tsx @@ -68,11 +68,11 @@ export type GenericAchievement = Replace< >; export function createAchievement( - optionsFunc: OptionsFunc, BaseAchievement> + optionsFunc?: OptionsFunc, BaseAchievement> ): Achievement { const earned = persistent(false); return createLazyProxy(() => { - const achievement = optionsFunc(); + const achievement = optionsFunc?.() ?? ({} as ReturnType>); achievement.id = getUniqueID("achievement-"); achievement.type = AchievementType; achievement[Component] = AchievementComponent; diff --git a/src/features/clickables/clickable.ts b/src/features/clickables/clickable.ts index 929599c..37b898e 100644 --- a/src/features/clickables/clickable.ts +++ b/src/features/clickables/clickable.ts @@ -70,10 +70,10 @@ export type GenericClickable = Replace< >; export function createClickable( - optionsFunc: OptionsFunc, BaseClickable> + optionsFunc?: OptionsFunc, BaseClickable> ): Clickable { return createLazyProxy(() => { - const clickable = optionsFunc(); + const clickable = optionsFunc?.() ?? ({} as ReturnType>); clickable.id = getUniqueID("clickable-"); clickable.type = ClickableType; clickable[Component] = ClickableComponent; diff --git a/src/features/links/links.ts b/src/features/links/links.ts index 4443b65..ea100f4 100644 --- a/src/features/links/links.ts +++ b/src/features/links/links.ts @@ -20,7 +20,7 @@ export interface Link extends SVGAttributes { } export interface LinksOptions { - links?: Computable; + links: Computable; } export interface BaseLinks { diff --git a/src/features/milestones/milestone.tsx b/src/features/milestones/milestone.tsx index 00322f9..879a253 100644 --- a/src/features/milestones/milestone.tsx +++ b/src/features/milestones/milestone.tsx @@ -84,11 +84,11 @@ export type GenericMilestone = Replace< >; export function createMilestone( - optionsFunc: OptionsFunc, BaseMilestone> + optionsFunc?: OptionsFunc, BaseMilestone> ): Milestone { const earned = persistent(false); - return createLazyProxy(persistent => { - const milestone = Object.assign(persistent, optionsFunc()); + return createLazyProxy(() => { + const milestone = optionsFunc?.() ?? ({} as ReturnType>); milestone.id = getUniqueID("milestone-"); milestone.type = MilestoneType; milestone[Component] = MilestoneComponent; diff --git a/src/features/particles/particles.tsx b/src/features/particles/particles.tsx index 4120a39..345191b 100644 --- a/src/features/particles/particles.tsx +++ b/src/features/particles/particles.tsx @@ -42,10 +42,10 @@ export type Particles = Replace< export type GenericParticles = Particles; export function createParticles( - optionsFunc: OptionsFunc, BaseParticles> + optionsFunc?: OptionsFunc, BaseParticles> ): Particles { return createLazyProxy(() => { - const particles = optionsFunc(); + const particles = optionsFunc?.() ?? ({} as ReturnType>); particles.id = getUniqueID("particles-"); particles.type = ParticlesType; particles[Component] = ParticlesComponent; diff --git a/src/features/tabs/tabFamily.ts b/src/features/tabs/tabFamily.ts index 741c4e6..2a4f332 100644 --- a/src/features/tabs/tabFamily.ts +++ b/src/features/tabs/tabFamily.ts @@ -101,8 +101,7 @@ export function createTabFamily( const selected = persistent(Object.keys(tabs)[0]); return createLazyProxy(() => { - const tabFamily = - optionsFunc?.() || ({} as ReturnType, BaseTabFamily>>); + const tabFamily = optionsFunc?.() ?? ({} as ReturnType>); tabFamily.id = getUniqueID("tabFamily-"); tabFamily.type = TabFamilyType; diff --git a/src/features/trees/tree.ts b/src/features/trees/tree.ts index 2f07573..459a392 100644 --- a/src/features/trees/tree.ts +++ b/src/features/trees/tree.ts @@ -73,10 +73,10 @@ export type GenericTreeNode = Replace< >; export function createTreeNode( - optionsFunc: OptionsFunc, BaseTreeNode> + optionsFunc?: OptionsFunc, BaseTreeNode> ): TreeNode { return createLazyProxy(() => { - const treeNode = optionsFunc(); + const treeNode = optionsFunc?.() ?? ({} as ReturnType>); treeNode.id = getUniqueID("treeNode-"); treeNode.type = TreeNodeType; treeNode[Component] = TreeNodeComponent;