Skip to content

Conversation

cvsguimaraes
Copy link

@cvsguimaraes cvsguimaraes 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.

@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