Skip to content

importModuleSpecifierEnding: 'js' not honored when path aliases are used #46739

Open

Description

Bug Report

🔎 Search Terms

  • importModuleSpecifierEnding
  • paths
  • js es modules

🕗 Version & Regression Information

reproduced with TypeScript 4.4.4 as well as 4.6.0-dev.20211108 (i.e. npm install typescript@next at the time of writing).

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about __ Modules __
  • I was unable to test this on prior versions because _______

⏯ Playground Link

I could not figure out how to configure the Bug Workbench to contain multiple files, so I created an example git repository instead:

https://github.com/orzechowskid/ts-example-repo

💻 Code

// ./tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "baseUrl": ".",
    "checkJs": true,
    "paths": {
      "~/*": [ "./src/*" ]
    },
    "strict": true
  },
  "include": [
    "./src/**/*"
  ]
}

// ./src/utils/foo/bar/baz.js

export const baz = (a, b) => a + b;

// ./src/components/foo/Bar.js

import * from '~/utils/foo/bar/b
                                ^- wait for auto-suggest

🙁 Actual behavior

baz suggested as autocomplete text

🙂 Expected behavior

baz.js suggested as autocomplete text, since it's referring to a module import and I've set importModuleSpecifierEnding: 'js' in my preferences. (FWIW the file extension is appended if I write a relative path, e.g. 'import * from '../../utils/foo/bar/baz.js).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions