Skip to content
This repository has been archived by the owner on Jan 28, 2025. It is now read-only.

Vue-Cli template/TypeScript support? #47

Open
hawkerm opened this issue Apr 1, 2019 · 7 comments
Open

Vue-Cli template/TypeScript support? #47

hawkerm opened this issue Apr 1, 2019 · 7 comments
Labels
enhancement New feature or request

Comments

@hawkerm
Copy link

hawkerm commented Apr 1, 2019

I started my project with the new vue-cli builder (it'd be great to have a template for vue-babylonjs to help getting started easier).

Anyway, since I set my project up with TypeScript, I'm having trouble importing vue-babylonjs in my main.ts file:

Could not find a declaration file for module 'vue-babylonjs'. 'node_modules/vue-babylonjs/dist/umd.js' implicitly has an 'any' type.

Because of that I think I'm not importing the lib correctly, I tried just Vue.use(require('vue-babylonjs')); instead, but am getting an error of Unknown custom element: <Scene> when I load my component/page.

Any advice? Thanks!

@hawkerm
Copy link
Author

hawkerm commented Apr 1, 2019

Ah, I didn't go far enough with VS Code's help last time (I didn't save its changes to the tsconfig file). I was able to get going by having VS Code generate the dummy type file (with no types). I still get a red-squiggle, but it seems I can ignore it.

@BrainBacon BrainBacon added the enhancement New feature or request label Apr 4, 2019
@BrainBacon
Copy link
Collaborator

TypeScript typings support is something I'm definitely interested in adding, but I probably won't start to prioritize it until after Vue 3 is out. There's definitely a lot that could be done to integrate the typings with Babylon.js as well. I'm on the fence about switching the source code of this library to TS, but I believe there's ways to do it without switching the source. If you have any ideas or comments here I'm all ears.

@hawkerm
Copy link
Author

hawkerm commented Apr 5, 2019

I'm unfortunately not well versed in js/ts library development, at least as much as I'd like to be, so no comment there. As far as I understand though, a .d.ts file can be generated/created and included without the library being written in TypeScript.

I can understand waiting for Vue 3, Babylon 4 will be out by then too. It sounds like a Babylon 4 was getting more stabilized from a recent tweet, so I'm looking to start playing more with that.

@BrainBacon
Copy link
Collaborator

Yeah when Babylonjs 4 is good I plan on releasing a build with some new features. For now there's not much point to restructuring the build more than once. As for the CLI template, I'll probably release that with 1.0 stable.

@davidAlittle
Copy link

I got around this by adding "noImplicitAny" : false, to the "compilerOptions" section of my tsconfig.json file.

@notwhoyouthink1
Copy link

Ah, I didn't go far enough with VS Code's help last time (I didn't save its changes to the tsconfig file). I was able to get going by having VS Code generate the dummy type file (with no types). I still get a red-squiggle, but it seems I can ignore it.

@hawkerm Im getting the same issue as you but no vscode quick fix, could you copy in the blank import it generated?

@SnowNooDLe
Copy link

Simply add

declare module 'vue-babylonjs'

in shims-vue.d.ts
in src directory.

So, in your main.ts
will have

import vb from 'vue-babylonjs';
Vue.use(vb);

in shims-vue.d.ts

declare module '*.vue' {
  import Vue from 'vue'
  export default Vue
}

declare module 'vue-babylonjs'

Reference

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants