How Can I Avoid the "An Import Path Cannot End With. Ts Extension" Error in Vscode?

I'm using Visual Studio Code to write Deno programs.

The import statement in Deno contains the .ts extension, e.g.

import { Application } from "";

which is marked as a problem in VS-Code, error code ts(2691):

Despite the shown error, the program works fine, but I want to avoid the error message, because there's nothing wrong.

How can this be solved?

2 Answers

This can be solved by installing and configuring the Deno Extensions for VSCode.

Press CtrlShiftX to open the extensions view, then type "deno" and click on the entry name "Deno - Deno support for VSCode":

and install it.

After installation, you can choose any one of following methods:

  • Go to settings: (Ctrl, or Cmd, on MacOSX), select "Extensions>Deno" and click on the checkbox under "Deno:Enable" and "Deno:lint"
    • Just enable workspace settings only
    • Don't enable User settings if you have other Non node projects
  • Or, as @hong4rc mentioned, open the Command Palette(Ctrl+Shift+P) and select Deno:initialize

Either method creates a folder named .vscode and a file settings.json with the following lines in your workspace project ( workspace settings):

{
  "deno.enable": true,
  "deno.lint": true
}

In both cases, after restarting Visual Studio Code, the error should be gone.

7

Since this is the first question that pops up in search I will add my answer here although it was not related to Deno, but with Webdriver.

Adding allowImportingTsExtensions in tsconfig.json solved the issue.

My full answer here:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest