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

types: add loader options declarations #1542

Merged
merged 2 commits into from
Apr 24, 2019
Merged

types: add loader options declarations #1542

merged 2 commits into from
Apr 24, 2019

Conversation

kbtz
Copy link

@kbtz kbtz commented Apr 23, 2019

This PR essentially adds the interface VueLoaderOptions that can aid type checking
when writting Webpack configuration with Typescript:

// webpack.config.ts

import { VueLoaderOptions, VueLoaderPlugin } from 'vue-loader'

export default {
  module: {
    rules: {
      // ...
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          // * autocompletion available here *
        } as VueLoaderOptions
      }
    }
  },
  plugins: [
    new VueLoaderPlugin()
  ]
}

I'm studying the possibility of using a discriminated union to assign the options type when a match loader: 'vue-loader' is found, but this will come in a later PR. For now the casting on the options object is required.


Please note the compiler interface use types that were added only in Vue 2.6 (vuejs/vue#7918), but folks with older versions of the template compiler shouldn't experience any errors, they will just not get any type checking on compile and compileOptions properties.

lib/index.d.ts Outdated Show resolved Hide resolved
@haoqunjiang haoqunjiang merged commit 423b834 into vuejs:master Apr 24, 2019
@vue-bot
Copy link

vue-bot commented Apr 24, 2019

Hey @kbtzr, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

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

Successfully merging this pull request may close these issues.

3 participants