Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/core/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,41 @@ export function getDeclaration(ctx: Context, filepath: string, originalImports?:
directive: stringifyDeclarationImports({ ...originalImports?.directive, ...imports.directive }),
}

let code = `/* eslint-disable */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {`

let items = ''
if (Object.keys(declarations.component).length > 0) {
code += `
items += `
export interface GlobalComponents {
${declarations.component.join('\n ')}
}`
}

if (Object.keys(declarations.directive).length > 0) {
code += `
items += `
export interface ComponentCustomProperties {
${declarations.directive.join('\n ')}
}`
}

let code = `/* eslint-disable */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {`
if (items)
code += items
code += '\n}\n'

if (ctx.options.runtime)
code += `
/* prettier-ignore */
declare module '@vue/runtime-core' {`
if (items)
code += items
code += '\n}\n'

return code
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const defaultOptions: Omit<Required<Options>, 'include' | 'exclude' | 'ex
importPathTransform: v => v,

allowOverrides: false,

runtime: false,
}

function normalizeResolvers(resolvers: (ComponentResolver | ComponentResolver[])[]): ComponentResolverObject[] {
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ export interface Options {
* Vue version of project. It will detect automatically if not specified.
*/
version?: 2 | 2.7 | 3

/**
* Whether runtime is needed
*/
runtime?: boolean
}

export type ResolvedOptions = Omit<
Expand Down