Code Monkey home page Code Monkey logo

Comments (6)

rdhainaut avatar rdhainaut commented on May 30, 2024 1

The first file helps Typescript to compile (because it knows the vue-plugin-load-script module)
The second file adds the functions as global to a vue object / vue component (you can see them via auto completion in VS Code IDE)

from vue-plugin-load-script.

tobiasgubo avatar tobiasgubo commented on May 30, 2024

I am facing the same problem but I dont know where I have to put these Files so Vue recognises them?

from vue-plugin-load-script.

rdhainaut avatar rdhainaut commented on May 30, 2024

@tobiasgubo It depend on your typescript configuration (tsconfig.json file) but if your .d.ts file is in your "include" files, it should be automatically detected (except if you have manually defined types option)

In my project, i have this structure

/src
  /@types
      vue-plugin-load-script.module.d.ts
      vue.global.d.ts
  /components
     HelloWorld.vue
tsconfig.json
// HelloWorld.vue
@Component
export default class HelloWorld extends Vue {
  async mounted() {
    await this.$loadScript("http://url.com");
  }
}
// tsconfig.json
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "strictPropertyInitialization": false,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },
    "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
  },
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
  "exclude": ["node_modules"]
}

from vue-plugin-load-script.

Sergio1C avatar Sergio1C commented on May 30, 2024

hi @rdhainaut.
Faced with the same issue, but i have created only a declaration file with `declare module "vue-plugin-load-script"' content and it helped me. Could you explain why needed the second file which was mentioed above?

from vue-plugin-load-script.

es5es5 avatar es5es5 commented on May 30, 2024

@rdhainaut THANK U so much !

from vue-plugin-load-script.

tserkov avatar tserkov commented on May 30, 2024

Typings added in v1.3.4!

from vue-plugin-load-script.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.