Skip to content

Commit 28f550d

Browse files
committed
test: test types in module and fixtures
1 parent 295b8c4 commit 28f550d

8 files changed

Lines changed: 116 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
- run: pnpm lint
4646
- run: pnpm test
4747
- run: pnpm build
48+
- run: pnpm test:types
4849
- run: pnpm dev:build
4950
- name: Release Edge
5051
if: |

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"lint": "eslint --ext .ts --ext .vue .",
2222
"prepack": "pnpm build",
2323
"release": "pnpm test && standard-version && git push --follow-tags && npm publish",
24-
"test": "nuxi prepare playground && pnpm vitest run"
24+
"test": "nuxi prepare playground && pnpm vitest run",
25+
"test:types": "vue-tsc --noEmit && nuxi typecheck playground && nuxi typecheck example"
2526
},
2627
"dependencies": {
2728
"@nuxt/kit": "^3.5.1",
@@ -50,7 +51,8 @@
5051
"playwright": "^1.34.3",
5152
"standard-version": "latest",
5253
"typescript": "5.0.4",
53-
"vitest": "^0.30.1"
54+
"vitest": "^0.30.1",
55+
"vue-tsc": "^1.6.5"
5456
},
5557
"optionalDependencies": {
5658
"ipx": "1.1.0"

pnpm-lock.yaml

Lines changed: 96 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/components/_base.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ export const baseImageProps = {
3232
crossorigin: {
3333
type: [Boolean, String] as unknown as () => 'anonymous' | 'use-credentials' | boolean,
3434
default: undefined,
35-
validator: val => ['anonymous', 'use-credentials', '', true, false].includes(val)
35+
validator: (val: any) => ['anonymous', 'use-credentials', '', true, false].includes(val)
3636
},
3737
decoding: {
3838
type: String as () => 'async' | 'auto' | 'sync',
3939
default: undefined,
40-
validator: val => ['async', 'auto', 'sync'].includes(val)
40+
validator: (val: any) => ['async', 'auto', 'sync'].includes(val)
4141
}
4242
}
4343

@@ -73,7 +73,7 @@ export const useBaseImage = (props: ExtractPropTypes<typeof baseImageProps>) =>
7373
})
7474

7575
const attrs = computed<BaseImageAttrs>(() => {
76-
return <BaseImageAttrs>{
76+
return <BaseImageAttrs> {
7777
width: parseSize(props.width),
7878
height: parseSize(props.height),
7979
alt: props.alt,

src/runtime/components/nuxt-img.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default defineComponent({
2626
'data-nuxt-img'?: string
2727
}
2828

29-
const sizes = computed(() => $img.getSizes(props.src, {
29+
const sizes = computed(() => $img.getSizes(props.src!, {
3030
..._base.options.value,
3131
sizes: props.sizes,
3232
modifiers: {
@@ -55,7 +55,7 @@ export default defineComponent({
5555
? placeholder
5656
: (typeof placeholder === 'number' ? [placeholder, placeholder] : [10, 10])) as [w: number, h: number, q: number]
5757

58-
return $img(props.src, {
58+
return $img(props.src!, {
5959
..._base.modifiers.value,
6060
width: size[0],
6161
height: size[1],
@@ -66,7 +66,7 @@ export default defineComponent({
6666
const mainSrc = computed(() =>
6767
props.sizes
6868
? sizes.value.src
69-
: $img(props.src, _base.modifiers.value, _base.options.value)
69+
: $img(props.src!, _base.modifiers.value, _base.options.value)
7070
)
7171

7272
const src = computed(() => placeholder.value ? placeholder.value : mainSrc.value)

src/runtime/composables.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { $Img } from '../types'
12
import { useNuxtApp } from '#imports'
23

34
export const useImage = () => {
4-
return useNuxtApp().$img
5+
return useNuxtApp().$img as $Img
56
}

src/runtime/ipx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default lazyEventHandler(() => {
1616
const middleware = createIPXMiddleware(ipx)
1717

1818
return eventHandler(async (event) => {
19-
event.node.req.url = withLeadingSlash(event.context.params._)
19+
event.node.req.url = withLeadingSlash(event.context.params!._)
2020
await middleware(event.node.req, event.node.res)
2121
})
2222
})

tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"extends": "./.nuxt/tsconfig.json"
2+
"extends": "./.nuxt/tsconfig.json",
3+
"exclude": [
4+
"dist",
5+
"playground",
6+
"docs"
7+
]
38
}

0 commit comments

Comments
 (0)