microsoft / TypeScript-Vue-Starter

A starter template for TypeScript and Vue with a detailed README describing how to use the two together.
MIT License
4.45k stars 592 forks source link

is it possible having .vue file path resolved? #43

Open noe132 opened 6 years ago

noe132 commented 6 years ago

if you import an non-existance typescript module like this

import mymodule from './src/non-existance-path/unknowfile.ts'

you will get an error show that cannot find module ./src/non-existance-path/unknowfile.ts

but when if import *.vue single file modules for instance in index.ts

// this is valid import
import HelloDecoratorComponent from "./components/HelloDecorator.vue";

// this is invalid import because there is no file "./components/HelloDeccorator.vue"
import HelloDecoratorComponent2 from "./components/HelloDeccorator.vue";

// this is invalid import because there is no file "./components/HelloDecorator_wtfisthisJKLQ#H@!*(.vue"
import HelloDecoratorComponent2 from "./components/HelloDecorator_wtfisthisJKLQ#H@!*(.vue";

the second import is invalid because of the import name typo (double c in deCCorator.vue), also the third one is invalid too.

I know that .vue file type is defined in vue-shims.d.ts,

but typescript engine doesn't resolve these file paths, and there is no error report when coding index.ts as you have import typo causes an invalid import.

is it possible to let typescript engine resolve these .vue file paths?

HerringtonDarkholme commented 6 years ago

Hi @noe132, you can try this plugin https://github.com/HerringtonDarkholme/vue-ts-plugin.

Merott commented 6 years ago

Running into this as well... Did you manage to solve this @noe132?

noe132 commented 6 years ago

@Merott im using eslint with typescript-eslint-plugin and eslint-import-plugin to lint those imports right now. Once have mistyped imports eslint will report it