-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
feat: improve plugin params typing #2758
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more tests
@@ -0,0 +1,31 @@ | |||
import { createApp, App } from './index' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { createApp, App } from './index' | |
import { createApp, App, Plugin } from './index' | |
const app = createApp({}) |
app.use(PluginClass, { foo: [123] }) | ||
// no error | ||
app.use(PluginClass, { foo: ['asdf'] }) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}) | |
}) | |
describe('plugin function', () => { | |
const plugin = (app: App, config: { num: number; url: string }) => {} | |
// @ts-expect-error no arguments | |
app.use(plugin) | |
// @ts-expect-error invalid arguments | |
app.use(plugin, {}) | |
app.use(plugin, { | |
// @ts-expect-error invalid type | |
num: '', | |
url: '' | |
}) | |
app.use(plugin, { | |
num: 1, | |
url: '' | |
}) | |
app.use( | |
plugin, | |
{ | |
num: 1, | |
url: '' | |
}, | |
// @ts-expect-error too many arguments | |
true | |
) | |
}) | |
describe('no argument', () => { | |
const plugin = (app: App) => {} | |
app.use(plugin) | |
// @ts-expect-error too many arguments | |
app.use(plugin, {}) | |
}) | |
describe('using plugin type', () => { | |
const plugin = ({} as unknown) as Plugin | |
app.use(plugin) | |
app.use(plugin, true) | |
app.use(plugin, {}) | |
app.use(plugin, 1, 'string', {}, () => {}) | |
}) |
import { createApp, App } from './index' | ||
|
||
describe('plugin params inference', () => { | ||
const app = createApp({}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const app = createApp({}) |
Is this PR outdated? If so, it might make sense to close this if no one is working on it. If not, is there a timeline for when this fix can be merged? From my perspective, the changes to |
Thanks for the PR. Close in favor of #3969 |
support plugin params type inference
Close #2589, Closes #2588