Skip to content

Cannot get types for require(...) style imports with tsgo (but can with regular ts) #1181

Closed
@Zlatkovsky

Description

@Zlatkovsky

In a JS file (in my case, a webpack.config.js) of a project, I have a variable declaration that does a require of another package in the same repo:

const CssPrependClassPlugin =
  require('<myToolsPackage>/lib/webpack/CssPrependClassPlugin').CssPrependClassPlugin;

The <myToolsPackage> is compiled with "type": "commonjs" in the package.json, and "module": "node16", "moduleResolution": "node16", "verbatimModuleSyntax": false in its tsconfig. This combination works well, at least with the regular TypeScript engine.

With the regular TypeScript engine, I am able to get IntelliSense for that plugin, as well as alerts of invalid/incomplete input:

Image

Image

But with tsgo, the variable just resolves to any, and yields no errors:

Image

Image

Other IntelliSense still works in the file, e.g.,

Image

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