Skip to content

Commit

Permalink
test: test types in module and fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 28, 2023
1 parent 295b8c4 commit 28f550d
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- run: pnpm lint
- run: pnpm test
- run: pnpm build
- run: pnpm test:types
- run: pnpm dev:build
- name: Release Edge
if: |
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"lint": "eslint --ext .ts --ext .vue .",
"prepack": "pnpm build",
"release": "pnpm test && standard-version && git push --follow-tags && npm publish",
"test": "nuxi prepare playground && pnpm vitest run"
"test": "nuxi prepare playground && pnpm vitest run",
"test:types": "vue-tsc --noEmit && nuxi typecheck playground && nuxi typecheck example"
},
"dependencies": {
"@nuxt/kit": "^3.5.1",
Expand Down Expand Up @@ -50,7 +51,8 @@
"playwright": "^1.34.3",
"standard-version": "latest",
"typescript": "5.0.4",
"vitest": "^0.30.1"
"vitest": "^0.30.1",
"vue-tsc": "^1.6.5"
},
"optionalDependencies": {
"ipx": "1.1.0"
Expand Down
104 changes: 96 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/runtime/components/_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export const baseImageProps = {
crossorigin: {
type: [Boolean, String] as unknown as () => 'anonymous' | 'use-credentials' | boolean,
default: undefined,
validator: val => ['anonymous', 'use-credentials', '', true, false].includes(val)
validator: (val: any) => ['anonymous', 'use-credentials', '', true, false].includes(val)
},
decoding: {
type: String as () => 'async' | 'auto' | 'sync',
default: undefined,
validator: val => ['async', 'auto', 'sync'].includes(val)
validator: (val: any) => ['async', 'auto', 'sync'].includes(val)
}
}

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

const attrs = computed<BaseImageAttrs>(() => {
return <BaseImageAttrs>{
return <BaseImageAttrs> {
width: parseSize(props.width),
height: parseSize(props.height),
alt: props.alt,
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/components/nuxt-img.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineComponent({
'data-nuxt-img'?: string
}

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

return $img(props.src, {
return $img(props.src!, {
..._base.modifiers.value,
width: size[0],
height: size[1],
Expand All @@ -66,7 +66,7 @@ export default defineComponent({
const mainSrc = computed(() =>
props.sizes
? sizes.value.src
: $img(props.src, _base.modifiers.value, _base.options.value)
: $img(props.src!, _base.modifiers.value, _base.options.value)
)

const src = computed(() => placeholder.value ? placeholder.value : mainSrc.value)
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/composables.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { $Img } from '../types'
import { useNuxtApp } from '#imports'

export const useImage = () => {
return useNuxtApp().$img
return useNuxtApp().$img as $Img
}
2 changes: 1 addition & 1 deletion src/runtime/ipx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default lazyEventHandler(() => {
const middleware = createIPXMiddleware(ipx)

return eventHandler(async (event) => {
event.node.req.url = withLeadingSlash(event.context.params._)
event.node.req.url = withLeadingSlash(event.context.params!._)
await middleware(event.node.req, event.node.res)
})
})
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"extends": "./.nuxt/tsconfig.json"
"extends": "./.nuxt/tsconfig.json",
"exclude": [
"dist",
"playground",
"docs"
]
}

0 comments on commit 28f550d

Please sign in to comment.