Skip to content
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

Using defineUnlighthouseConfig doesn't give proper typing #264

Closed
Atulin opened this issue Mar 7, 2025 · 3 comments
Closed

Using defineUnlighthouseConfig doesn't give proper typing #264

Atulin opened this issue Mar 7, 2025 · 3 comments

Comments

@Atulin
Copy link

Atulin commented Mar 7, 2025

Describe the bug

/// <reference types="unlighthouse" />

export default defineUnlighthouseConfig({
	site: "https://localhost:5001",
	cache: false,
	scanner: {
		exclude: ["/rss/*", "/admin/*"],
	},
	puppeteerOptions: {
		channel: "stable",
	},
});

defineUnlightouseConfig() is typed as any, and provides zero autocompletion for the options object.

Trying to manually navigate to the unlighthouse types leads to types.d.ts

import type { DefineUnlighthouseConfig } from 'unlighthouse/config'

export * from './dist/index'

declare global {
  const defineUnlighthouseConfig: DefineUnlighthouseConfig
}

that seems to import the type from a nonexistent location:

Image

Reproduction

No response

System / Nuxt Info

@harlan-zw
Copy link
Owner

harlan-zw commented Mar 7, 2025

Hi, thanks for flagging this. Could you try the latest version v0.16.2

I've setup attw so hopefully working 🤞

@Atulin
Copy link
Author

Atulin commented Mar 7, 2025

The magic tricks with declare global and importing types with a comment are still wonky at best, result in an any and no autocomplete. There is no error from the screenshot, though.

That said, I can now use

import { defineUnlighthouseConfig } from 'unlighthouse/config'

export default defineUnlighthouseConfig({
	site: "https://localhost:5001",
	cache: false,
	scanner: {
		exclude: ["/rss/*", "/admin/*"],
		samples: 3,
	},
	puppeteerOptions: {
		channel: "chrome",
	},
});

and it works perfectly well

@harlan-zw
Copy link
Owner

You shouldn't actually need the comment if you have unlighthouse as a dependency, I'll look to improve the docs around this.

Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants