Skip to content

Auto import with wildcard imports with expanded path #51398

Closed
@dtdesign

Description

@dtdesign

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.73.0 (Universal)
  • OS Version: macOS 13.0 (arm64)

Context

We are maintaining TypeScript projects across multiple repositories with one repository being the primary framework that provides the majority of the functionality. For historic reasons we are using an AMD-based module bundler (require.js) that expects fully qualified paths for module dependencies.

Project Configuration

We are referencing this main project in the package.json using a commit id like this:

{
  "dependencies": {
    "@woltlab/wcf": "https://github.com/WoltLab/WCF.git#f8ba2b43c7fcc6428d61e5c9a31211e46db7f265"
  }
}

In the tsconfig.json we have set up a path wildcard to map references to modules from the primary repository:

{
  "include": [
    "node_modules/@woltlab/wcf/global.d.ts",
    "ts/**/*"
  ],
  "compilerOptions": {
    "module": "amd",
    "rootDir": "ts/",
    "baseUrl": ".",
    "paths": {
      "*": [
        "node_modules/@woltlab/wcf/ts/*"
      ]
    }
  }
}

Observed Behavior

The auto import works, but the generated import expands it to the entire path.

import { dialogFactory } from "@woltlab/wcf/ts/WoltLabSuite/Core/Component/Dialog";

Expected Behavior

Auto imports should be referenced using their full path, but not expanding it to the full path:

import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";

It is important to note that the TypeScript compiler will correctly resolve and validate the above dependency. This will also generate valid AMD dependencies that can be resolved by our module bundler.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions