microsoft / microsoft/TypeScript

No intellisense for require in ts files

Open
#30,531 1 comment 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 3.4.0-rc
Search Terms: require, intellisense

Typescript does not resolve modules of require expressions as it does in plain js files.

Code

require("s:\\dev\\easy-attach\\")({
    eagerExitDebugProxy: true,
    port: "preconfigured",
    
});

Expected behavior:
This is what I get in VS Code in plain js files:
image

Actual behavior:
However, the module is not resolved in ts files:
image

Probably this is intended and my use case is a very special one.
However, typescripts repository description still says:

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

In this case, typescript has better support for require in js than in ts which is a little bit confusing considering typescript being a superset of javascript.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided require example in a TypeScript file and compare its IntelliSense with the same expression in a JavaScript file. Investigate the TypeScript language-service path that resolves require expressions; done means the module and its callable options are resolved in TypeScript as expected, or the intended limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.