Skip to content

.ts files should be preferred over .js files #3898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
prigaux opened this issue Apr 26, 2019 · 0 comments · Fixed by #3909 or javascript-indonesias/vue-cli#11
Closed

.ts files should be preferred over .js files #3898

prigaux opened this issue Apr 26, 2019 · 0 comments · Fixed by #3909 or javascript-indonesias/vue-cli#11

Comments

@prigaux
Copy link

prigaux commented Apr 26, 2019

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')
  },
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants