title: Creating a typescript definition file for a vue package (vue-datetime)
body: <p>I am using Vue.js in combination with typescript. I would like to use the <a href="https://www.npmjs.com/package/vue-datetime" rel="nofollow noreferrer">vue-datetime package</a> in my project. The package has no typescript definition file yet so I'm trying to create a minimal version.</p>
  
  <p>I have added a <code>index.d.ts</code> file to the <code>node_modules/vue-datetime</code> folder:</p>
  
  <pre><code>import Vue from 'vue';
  
  declare class Datetime extends Vue { }
  declare class DatetimePopup extends Vue { }
  
  export default Datetime;
  export { Datetime, DatetimePopup };
  </code></pre>
  
  <p>In my Vue component I can now import and use the package like this (note that I am using the <a href="https://github.com/vuejs/vue-class-component" rel="nofollow noreferrer">vue-class-component package</a> so the syntax might look a bit different than you're used to).</p>
  
  <pre><code>&lt;template&gt;
      &lt;div&gt;
          &lt;v-datetimepicker v-model="someproperty" class="myclass"&gt;&lt;/v-datetimepicker&gt;
      &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script lang="ts"&gt;
  
      import Vue from 'vue';
      import Component from 'vue-class-component';
      import { Datetime } from 'vue-datetime';
  
      import 'vue-datetime/dist/vue-datetime.css';
  
      Vue.component('v-datetimepicker', Datetime);
  
      @Component({
          components: { Datetime }
      })
      export default class MyComponent extends Vue {
  
      }
  &lt;/script&gt;
  
  &lt;style&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>This works, nice. The problem is that I don't want to save my <code>node_modules</code> folder to source control. Because of this I thought it would be a good idea to save the definition file to the same directory as my vue component (are there better options?).</p>
  
  <p>I moved the <code>index.d.ts</code> file and renamed it to <code>datepicker.d.ts</code>. I also updated my vue component which now imports the datepicker like: <code>import { Datetime } from './datepicker'</code>. This will give me no compile errors, but opening the page will throw me the following Javascript error: <code>Uncaught Error: Cannot find module './datepicker'</code>.</p>
  
  <p>I've been unsuccesful looking for solutions to this error online. Any ideas on what I could try or what is going wrong?</p>