Skip to content
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

Error when defining a function called "require" #1231

Open
quentinadam opened this issue Dec 30, 2024 · 0 comments
Open

Error when defining a function called "require" #1231

quentinadam opened this issue Dec 30, 2024 · 0 comments

Comments

@quentinadam
Copy link

Describe the bug

When defining a function called "require" the VSCode Deno extension reports unexpected errors (which I believe are related to the fact that the extension believes that this is a module import function from CommonJS).

To Reproduce

function require(value: unknown): string {
  if (typeof value !== 'string') {
    throw new Error('Argument is not a string');
  }
  return value;
}

console.log(require('hello')); // will report an error

const string = 'hello';

console.log(require(string)); // works fine

In the above code snippet the VSCode Deno extension will report the following error on the first require call:

Relative import path "hello" not prefixed with / or ./ or ../ and not in import map from "file:///Users/quentinadam/Projects/test/test.ts"deno(resolver-error)

Expected behavior

The extension should not report an error because this code compiles and checks correctly with deno (deno check).

Versions

vscode: 1.96.2
deno: 2.1.4
extension: 3.43.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant