Skip to content

Commit 811ac82

Browse files
committed
Fix compiler errrors identified by tsc
1 parent c13fc05 commit 811ac82

25 files changed

Lines changed: 125 additions & 99 deletions

File tree

‎src/components/Animations/Computers/client/__tests__/index.spec.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { experimental_AstroContainer as AstroContainer } from 'astro/container'
55
import ComputersAnimationAstro from '@components/Animations/Computers/index.astro'
66
import type { ComputersAnimationElement } from '@components/Animations/Computers/client'
77
import type { WebComponentModule } from '@components/scripts/@types/webComponentModule'
8+
import type { AnimationControllerConfig, AnimationControllerHandle } from '@components/scripts/store'
89
import { executeRender, withJsdomEnvironment } from '@test/unit/helpers/litRuntime'
910
import { gsap } from 'gsap'
1011

@@ -51,7 +52,7 @@ const getComputersModule = () => {
5152
const addScriptBreadcrumbMock = vi.hoisted(() => vi.fn())
5253
const handleScriptErrorMock = vi.hoisted(() => vi.fn())
5354
const createAnimationControllerMock = vi.hoisted(() =>
54-
vi.fn(() => ({
55+
vi.fn((_config: AnimationControllerConfig): AnimationControllerHandle => ({
5556
requestPlay: vi.fn(),
5657
requestPause: vi.fn(),
5758
clearUserPreference: vi.fn(),
@@ -317,7 +318,5 @@ function createTimelineMock() {
317318

318319
const generateUniqueTagName = (): string => `computers-animation-${Math.random().toString(36).slice(2)}`
319320

320-
const getLastControllerHandle = () =>
321-
createAnimationControllerMock.mock.results.at(-1)?.value as
322-
| ReturnType<typeof createAnimationControllerMock>
323-
| undefined
321+
const getLastControllerHandle = (): AnimationControllerHandle | undefined =>
322+
createAnimationControllerMock.mock.results.at(-1)?.value

‎src/components/CallToAction/Newsletter/client/__tests__/index.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
33
import { experimental_AstroContainer as AstroContainer } from 'astro/container'
44
import Newsletter from '@components/CallToAction/Newsletter/index.astro'
5-
import type { Props as NewsletterProps } from '@components/CallToAction/Newsletter/index.astro'
5+
import type { NewsletterProps } from '@components/CallToAction/Newsletter/props'
66
import type { NewsletterFormElement } from '@components/CallToAction/Newsletter/client'
77
import type { WebComponentModule } from '@components/scripts/@types/webComponentModule'
88
import { executeRender } from '@test/unit/helpers/litRuntime'

‎src/components/CallToAction/Newsletter/client/__tests__/selectors.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { beforeEach, describe, expect, test } from 'vitest'
33
import { experimental_AstroContainer as AstroContainer } from 'astro/container'
44
import Newsletter from '@components/CallToAction/Newsletter/index.astro'
5-
import type { Props as NewsletterProps } from '@components/CallToAction/Newsletter/index.astro'
5+
import type { NewsletterProps } from '@components/CallToAction/Newsletter/props'
66
import type { NewsletterFormElement } from '@components/CallToAction/Newsletter/client'
77
import { SELECTORS, getNewsletterElements } from '@components/CallToAction/Newsletter/client/selectors'
88
import type { WebComponentModule } from '@components/scripts/@types/webComponentModule'

‎src/components/CallToAction/Newsletter/index.astro‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,9 @@
1616
*/
1717
1818
import GDPRConsent from '@components/Consent/Checkbox/index.astro'
19+
import type { NewsletterProps } from './props'
1920
20-
export interface Props {
21-
/** Main heading for the newsletter signup */
22-
title?: string
23-
/** Supporting description text */
24-
description?: string
25-
/** Input placeholder text */
26-
placeholder?: string
27-
/** Submit button text */
28-
buttonText?: string
29-
}
21+
export type Props = NewsletterProps
3022
3123
const {
3224
title = 'Stay Updated',
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export interface NewsletterProps {
2+
/** Main heading for the newsletter signup */
3+
title?: string
4+
/** Supporting description text */
5+
description?: string
6+
/** Input placeholder text */
7+
placeholder?: string
8+
/** Submit button text */
9+
buttonText?: string
10+
}

‎src/components/Carousel/client/__tests__/index.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { beforeEach, describe, expect, it, vi } from 'vitest'
44
import { experimental_AstroContainer as AstroContainer } from 'astro/container'
55
import CarouselComponent from '@components/Carousel/index.astro'
6-
import type { Props as CarouselProps } from '@components/Carousel/index.astro'
6+
import type { CarouselProps } from '@components/Carousel/props'
77
import type { CarouselElement } from '@components/Carousel/client'
88
import type { WebComponentModule } from '@components/scripts/@types/webComponentModule'
99
import { executeRender } from '@test/unit/helpers/litRuntime'

‎src/components/Carousel/index.astro‎

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,17 @@
22
// Generic Carousel component for displaying content - both featured and suggested
33
import { getCollection } from 'astro:content'
44
import type { CollectionEntry } from 'astro:content'
5+
import type { CarouselProps, CollectionKeyMap } from './props'
56
6-
// Type mapping from prop values to actual collection keys
7-
type CollectionKeyMap = {
8-
services: 'services'
9-
'case-studies': 'caseStudies'
10-
articles: 'articles'
11-
}
12-
13-
// Type-safe union of valid collection prop names
14-
type CollectionPropName = keyof CollectionKeyMap
15-
16-
// Generic interface that infers the collection type from the type prop
17-
export interface Props<T extends CollectionPropName = CollectionPropName> {
18-
title?: string
19-
limit?: number
20-
variant?: 'featured' | 'suggested' | 'random'
21-
currentSlug: string
22-
type: T
23-
}
7+
export type { CarouselProps as Props } from './props'
248
259
const {
2610
title = 'Featured Content',
2711
limit = 3,
2812
variant = 'featured',
2913
currentSlug,
3014
type,
31-
} = Astro.props
15+
} = Astro.props as CarouselProps
3216
3317
// Map the prop type to the actual collection key with proper typing
3418
const collectionKey = {

‎src/components/Carousel/props.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export type CarouselVariant = 'featured' | 'suggested' | 'random'
2+
3+
export type CollectionKeyMap = {
4+
services: 'services'
5+
'case-studies': 'caseStudies'
6+
articles: 'articles'
7+
}
8+
9+
export type CollectionPropName = keyof CollectionKeyMap
10+
11+
export interface CarouselProps<T extends CollectionPropName = CollectionPropName> {
12+
title?: string
13+
limit?: number
14+
variant?: CarouselVariant
15+
currentSlug: string
16+
type: T
17+
}

‎src/components/Consent/Checkbox/client/__fixtures__/checkbox.fixture.astro‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
---
2-
import ConsentCheckbox, { type Props as ConsentCheckboxProps } from '@components/Consent/Checkbox/index.astro'
3-
4-
export interface CheckboxFixtureProps extends ConsentCheckboxProps {
5-
formId?: string
6-
wrapInForm?: boolean
7-
}
2+
import ConsentCheckbox from '@components/Consent/Checkbox/index.astro'
3+
import type { CheckboxFixtureProps } from '@components/Consent/Checkbox/client/types'
84
95
const fixtureProps: CheckboxFixtureProps = {
106
purpose: 'Responding to your inquiry',

‎src/components/Consent/Checkbox/client/__tests__/testUtils.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect } from 'vitest'
22
import { experimental_AstroContainer as AstroContainer } from 'astro/container'
3-
import CheckboxFixture, { type CheckboxFixtureProps } from '@components/Consent/Checkbox/client/__fixtures__/checkbox.fixture.astro'
3+
import CheckboxFixture from '@components/Consent/Checkbox/client/__fixtures__/checkbox.fixture.astro'
4+
import type { CheckboxFixtureProps } from '@components/Consent/Checkbox/client/types'
45
import type { ConsentCheckboxElement } from '@components/Consent/Checkbox/client'
56
import type { WebComponentModule } from '@components/scripts/@types/webComponentModule'
67
import { executeRender } from '@test/unit/helpers/litRuntime'

0 commit comments

Comments
 (0)