[Vuejs]-Import npm module as source code

0👍

If you are creating your own fork of vue-form-generator, you may add type declarations right there as well.

create file index.d.ts in your copy of src/component/form-generator:

  const VueFormGenerator: any;
  export default VueFormGenerator;

There is no need to have declare module ... in there because this index.d.ts is right next to index.js, so TypeScript compiler should find it when you import it as

import VueFormGenerator from './relative-path-to/form-generator/index';

and generated javascript code will find it as index.js there. Note that the import path must be relative because otherwise, without any path mapping, it will look for the module in node_modules, not in your sources.

You also have to remove all references to the previous type declaration file, vfg.d.ts, in your project.

Leave a comment