title: Vue library typings
body: <p>I'm making a Vue library as an NPM package which is intented to be used by other projects.</p>
  
  <p>The entry point is <code>main.ts</code>, which exposes a plugin and some functions that I commonly use. A simplified example of <code>main.ts</code>:</p>
  
  <pre><code>import Vue from 'vue'
  import Button from '@/components/button.vue'
  
  const myPlugin = {
    install (vue: typeof Vue): void {
      vue.component('the-button', Button)
    }
  }
  
  function someFunction(a: number, b: number) {
    return a + b
  }
  
  export { myPlugin, someFunction }
  </code></pre>
  
  <p>I build the project using <code>vue-cli-service build --target lib --name myLibrary src/main.ts</code>.</p>
  
  <p>Now to my question; how to specify and/or generate typings correctly? As far as I can see, there are two options:</p>
  
  <ol>
  <li><p>Set <code>"typings": "src/main.ts"</code> in my <code>package.json</code> and use the .ts files themselves as type references. Seems to work but I haven't seen any examples of this being used so I assume it's bad practice?</p></li>
  <li><p>Set <code>"declaration": true</code> and <code>"outDir": "types"</code> in my <code>.tsconfig.json</code>. Along with <a href="https://github.com/vuejs/vue-cli/issues/1081" rel="noreferrer">some tweaking</a> in <code>vue.config.js</code> typings seems to be generated correctly, which I would specify with <code>"typings": "types/main.d.ts"</code> in the package.json file. Is this the preferred approach?</p></li>
  </ol>