I attempted to integrate TypeScript into my existing VueJS + Rails application. I started by cloning a demo from (https://github.com/gbarillot/rails-vue-demo-app) and then following the guidelines provided on https://github.com/rails/webpacker
$ bundle exec rails webpacker:install:vue
$ bundle exec rails webpacker:install:typescript
Next, I made changes to
config/webpack/loaders/typescript.js
as explained in this document here.
Though the compilation seems successful, when I switched the script
section of my "home" view to typescript:
<script lang="ts">
import Layout from '../shared/layout';
export default {
components: {
Layout
}
}
</script>
An error occurred with the message:
Failed to compile.
/Users/matt/projects/rails-vue-demo-app/app/javascript/packs/components/home/index.vue.ts
[tsl] ERROR in /Users/matt/projects/rails-vue-demo-app/app/javascript/packs/components/home/index.vue.ts(13,20)
TS2307: Cannot find module '../shared/layout'.
Why does enabling typescript cause the layout file to be not found?