Skip to content

fix: code match regexp #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2021
Merged
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
3 changes: 2 additions & 1 deletion examples/vite-vue3/components.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// generated by unplugin-vue-components
// read more https://github.com/vuejs/vue-next/pull/3399
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/vue-next/pull/3399

declare module 'vue' {
export interface GlobalComponents {
Expand Down
2 changes: 1 addition & 1 deletion src/core/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { notNullish, slash } from '@antfu/utils'
import { Context } from './context'

export function parseDeclaration(code: string): Record<string, string> {
return Object.fromEntries(Array.from(code.matchAll(/\s+['"]?(.+?)['"]?:\s(.+?)\n/g)).map(i => [i[1], i[2]]))
return Object.fromEntries(Array.from(code.matchAll(/(?<!\/\/)\s+\s+['"]?(.+?)['"]?:\s(.+?)\n/g)).map(i => [i[1], i[2]]))
}

export async function generateDeclaration(ctx: Context, root: string, filepath: string) {
Expand Down