Skip to content

Commit

Permalink
chore: improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Nov 1, 2024
1 parent 18ccf7c commit 7a97c69
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/module.mjs"
".": {
"types": "./dist/module.d.ts",
"import": "./dist/module.mjs",
"require": "./dist/module.cjs"
}
},
"main": "./dist/module.cjs",
"types": "./dist/module.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const queryCollection = <T extends keyof Collections>(collection: T): Col
}

export async function queryCollectionNavigation<T extends keyof PageCollections>(collection: T, fields?: Array<keyof PageCollections[T]>) {
return generateNavigationTree(queryCollection(collection), fields as string[])
return generateNavigationTree(queryCollection(collection), fields)
}

export async function queryCollectionItemSurroundings<T extends keyof PageCollections>(collection: T, path: string, opts?: SurroundOptions<keyof PageCollections[T]>) {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/internal/query.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Collections, CollectionQueryBuilder, SQLOperator } from '@nuxt/content'
import { tables } from '#content/manifest'

export const collectionQureyBuilder = <T extends keyof Collections>(collection: T, fetch: (collection: T, sql: string) => Promise<T[]>): CollectionQueryBuilder<Collections[T]> => {
export const collectionQureyBuilder = <T extends keyof Collections>(collection: T, fetch: (collection: T, sql: string) => Promise<Collections[T][]>): CollectionQueryBuilder<Collections[T]> => {
const params = {
conditions: [] as Array<string>,
selectedFields: [] as Array<keyof Collections[T]>,
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { generateSearchSections } from './internal/search'
import { fetchQuery } from './internal/api'

export const queryCollectionWithEvent = <T extends keyof Collections>(event: H3Event, collection: T): CollectionQueryBuilder<Collections[T]> => {
return collectionQureyBuilder<T>(collection, (collection, sql) => fetchQuery<T>(event, collection, sql))
return collectionQureyBuilder<T>(collection, (collection, sql) => fetchQuery(event, collection, sql))
}

export async function queryCollectionNavigationWithEvent<T extends keyof PageCollections>(event: H3Event, collection: T, fields?: Array<keyof PageCollections[T]>) {
return generateNavigationTree(queryCollectionWithEvent(event, collection), fields as string[])
return generateNavigationTree(queryCollectionWithEvent(event, collection), fields)
}

export async function queryCollectionItemSurroundingsWithEvent<T extends keyof PageCollections>(event: H3Event, collection: T, path: string, opts?: SurroundOptions<keyof PageCollections[T]>) {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./.nuxt/tsconfig.json",
"exclude": [
"dist",
"node_modules"
"node_modules",
"docs"
]
}

0 comments on commit 7a97c69

Please # to comment.