Skip to content

How does TS support webpack's extensions? #19796

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
JounQin opened this issue Nov 7, 2017 · 5 comments
Closed

How does TS support webpack's extensions? #19796

JounQin opened this issue Nov 7, 2017 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@JounQin
Copy link

JounQin commented Nov 7, 2017

TypeScript Version: 2.6.1

Code

{
  resolve: {
    extensions: ['.ts', '.vue', '.js']
  }
}

And I've set paths in my tsconfig.json.

{
  "paths": {
      "*": [
        "*.ts",
        "*.vue"
      ]
  }
}

Expected behavior:

import Home from './views/Home'

Actual behavior:
I must write

import Home from './views/Home.vue'

Otherwise typescript service of IntelliJ IDEA will report an error: Error:(5, 17) TS2307:Cannot find module './views/Home'..

@mhegazy
Copy link
Contributor

mhegazy commented Nov 7, 2017

paths mapping do not affect relative paths. only non-relative ones. please see https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping.

The compiler does not rewrite module names at emit time. module names are considered resource identifiers and are not modified.. see #18971, #18951 and #16640

@mhegazy mhegazy added the Duplicate An existing issue was already created label Nov 7, 2017
@JounQin
Copy link
Author

JounQin commented Nov 7, 2017

@mhegazy So is there any workaround to support webpack extensions for now?

@DanielRosenwasser
Copy link
Member

In a global file, you can write something like

declare module "*.vue" {
    import Vue from "vue";
    export default Vue;
}

@JounQin
Copy link
Author

JounQin commented Nov 7, 2017

@DanielRosenwasser I've done that, my problem is that I want to remove .vue suffix when import .vue file.

@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants