Description
Version
3.6.0
Reproduction link
https://github.com/prigaux/vue-cli-prefer-ts-over-js
Steps to reproduce
Have both foo.js
and foo.ts
files in the same directory. Use import ... from './foo'
What is expected?
foo.ts
should be used
What is actually happening?
foo.js
is used instead
This is an issue when foo.ts is shared between server (tsc generates foo.js) and client (vue).
Suggested fix
ensure '.ts' and '.tsx' are added in front of config.resolve.extensions
in file @vue/cli-plugin-typescript/index.js
Workaround
add this to vue.config.js
module.exports = {
...
chainWebpack: config => {
config.resolve.extensions.prepend('.ts')
},
}