Skip to content

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

Closed
javascript-indonesias/vue-cli
#11
@prigaux

Description

@prigaux

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')
  },
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions