-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Add ts declaration for @vue/cli-test-utils, Plugin API, Generator API #5324
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
Comments
Hi, I am interested in this issue and I had generated GeneratorAPI declaration file and PluginAPI declaration file like this: /**
* Note: if a plugin-registered command needs to run in a specific default mode,
* the plugin needs to expose it via `module.exports.defaultModes` in the form
* of { [commandName]: mode }. This is because the command mode needs to be
* known and applied before loading user options / applying plugins.
*/
declare interface PluginAPI {
/**
*
* @param id
* @param service
*/
new (id: string, service: any);
/**
*
* @param range
*/
assertVersion(range: string): void;
/**
* Current working directory.
* @return
*/
getCwd(): any;
/**
* Resolve path for a project.
*
* @param {string} _path - Relative path from project root
* @return {string} The resolved absolute path.
*/
resolve(_path: string): string;
/**
* Check if the project has a given plugin.
*
* @param {string} id - Plugin id, can omit the (@vue/|vue-|@scope/vue)-cli-plugin- prefix
* @return {boolean}
*/
hasPlugin(id: string): boolean;
/**
* Register a command that will become available as `vue-cli-service [name]`.
*
* @param {string} name
* @param {object} [opts]
* {
* description: string,
* usage: string,
* options: { [string]: string }
* }
* @param {function} fn
* (args: { [string]: string }, rawArgs: string[]) => ?Promise
*/
registerCommand(name: string, opts?: any, fn: any): void;
/**
* Register a function that will receive a chainable webpack config
* the function is lazy and won't be called until `resolveWebpackConfig` is
* called
*
* @param {function} fn
*/
chainWebpack(fn: any): void;
/**
* Register
* - a webpack configuration object that will be merged into the config
* OR
* - a function that will receive the raw webpack config.
* the function can either mutate the config directly or return an object
* that will be merged into the config.
*
* @param {object | function} fn
*/
configureWebpack(fn: any): void;
/**
* Register a dev serve config function. It will receive the express `app`
* instance of the dev server.
*
* @param {function} fn
*/
configureDevServer(fn: any): void;
/**
* Resolve the final raw webpack config, that will be passed to webpack.
*
* @param {ChainableWebpackConfig} [chainableConfig]
* @return {object} Raw webpack config.
*/
resolveWebpackConfig(chainableConfig?: any): any;
/**
* Resolve an intermediate chainable webpack config instance, which can be
* further tweaked before generating the final raw webpack config.
* You can call this multiple times to generate different branches of the
* base webpack config.
* See https://github.com/mozilla-neutrino/webpack-chain
*
* @return {ChainableWebpackConfig}
*/
resolveChainableWebpackConfig(): any;
/**
* Generate a cache identifier from a number of variables
* @param id
* @param partialIdentifier
* @param configFiles
* @return
*/
genCacheConfig(id: any, partialIdentifier: any, configFiles: any): any;
} But 'add declaration for @vue/cli-test-utils, like createTestProject.d.ts' makes me confused, because there is only a function in createTestProject.js. |
fangbinwei
added a commit
to fangbinwei/vue-cli
that referenced
this issue
Apr 5, 2020
fangbinwei
added a commit
to fangbinwei/vue-cli
that referenced
this issue
Apr 5, 2020
fangbinwei
added a commit
to fangbinwei/vue-cli
that referenced
this issue
Apr 5, 2020
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What problem does this feature solve?
I code by vscode, and these is no code intelliSense when coding vue-cli-plugin and plugin unit test.
If ts declarations are provided, it will be helpful. I'm maintaing some vue cli plugins for some times, it's just a pain point for me.
What does the proposed API look like?
for @vue/cli-test-utils, add declaration to cli-test-utils folder, like
createTestProject.d.ts
, vscode can finish code completion even in .js file.for plugin, generator api, maybe like this?
The text was updated successfully, but these errors were encountered: