Giter Site home page Giter Site logo

denoland / vscode_deno Goto Github PK

View Code? Open in Web Editor NEW
1.5K 1.5K 138.0 24.6 MB

Visual Studio Code plugin for Deno

Home Page: https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno

License: MIT License

TypeScript 98.53% CSS 1.11% JavaScript 0.36%

vscode_deno's Introduction

Deno for Visual Studio Code

GitHub Workflow Status

Visual Studio Marketplace Version Visual Studio Marketplace Installs Visual Studio Marketplace Downloads Visual Studio Marketplace Rating (Stars)

This extension adds support for using Deno with Visual Studio Code, powered by the Deno language server.

⚠️ Important: You need to have a version of Deno CLI installed (v1.13.0 or later). The extension requires the executable and by default will use the environment path. You can explicitly set the path to the executable in Visual Studio Code Settings for deno.path.

Check here for instructions on how to install the Deno CLI.

Basic Usage of the Extension

Features

  • Type checking for JavaScript and TypeScript, including quick fixes, hover cards, intellisense, and more.
  • Integrates with the version of the Deno CLI you have installed, ensuring there is alignment between your editor and the Deno CLI.
  • Resolution of modules in line with Deno CLI's module resolution strategy allows caching of remote modules in Deno CLI's cache.
  • Integration to Deno CLI's linting functionality, including inline diagnostics and hover cards.
  • Integration to Deno CLI's formatting functionality.
  • Allow specifying of import maps and TypeScript configuration files that are used with the Deno CLI.
  • Auto completion for imports.
  • Workspace folder configuration.
  • Testing Code Lens.
  • Provides Tasks for the Deno CLI.

Usage

  1. Install the Deno CLI.
  2. Install this extension.
  3. Ensure deno is available in the environment path, or set its path via the deno.path setting in VSCode.
  4. Open the VS Code command palette with Ctrl+Shift+P, and run the Deno: Enable command.

We recognize that not every TypeScript/JavaScript project that you might work on in VSCode uses Deno — therefore, by default, this extension will only apply the Deno language server when the setting deno.enable is set to true. This can be done via editing the settings or using the command Deno: Initialize Workspace Configuration.

While you can enable Deno globally, you probably only want to do that if every JavaScript/TypeScript workspace you work on in VSCode is a Deno based one.

Commands

The extension provides several commands:

  • Deno: Cache - instructs Deno to fetch and cache all the dependencies of the current file open in the editor. This is similar to doing deno cache on the command line. Deno will not automatically fetch and cache remote dependencies.

    ℹ️   If there are missing dependencies in a module, the extension will provide a quick fix to fetch and cache those dependencies, which invokes this command for you.

  • Deno: Enable - will enable Deno on the current workspace. Alternatively you can create a deno.json or deno.jsonc file at the root of your workspace.

  • Deno: Language Server Status - displays a page of information about the status of the Deno Language Server. Useful when submitting a bug about the extension or the language server.

  • Deno: Reload Import Registries Cache - reload any cached responses from the configured import registries.

  • Deno: Welcome - displays the information document that appears when the extension is first installed.

Formatting

The extension provides formatting capabilities for JavaScript, TypeScript, JSX, TSX, JSON and markdown documents. When choosing to format a document or setting up a default formatter for these type of files, the extension should be listed as an option.

When configuring a formatter, you use the extension name, which in the case of this extension is denoland.vscode-deno. For example, to configure Deno to format your TypeScript files automatically on saving, you might set your settings.json in the workspace like this:

{
  "deno.enable": true,
  "deno.lint": true,
  "editor.formatOnSave": true,
  "[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" }
}

Or if you wanted to have Deno be your default formatter overall:

{
  "deno.enable": true,
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "denoland.vscode-deno"
}

Troubleshoot: If you choose this option, ensure your user settings don't have any language-specific settings set for this. VSCode will add this automatically in some cases:

// User `settings.json`:
{
  // Remove this:
  "[typescript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  }
}

The formatter will respect the settings in your Deno configuration file, which can be explicitly set via deno.config or automatically detected in the workspace. You can find more information about formatter settings at Deno Tools - Formatter.

ℹ️   It does not currently provide format-on-paste or format-on-type capabilities.

Configuration

You can control the settings for this extension through your VS Code settings page. You can open the settings page using the Ctrl+, keyboard shortcut. The extension has the following configuration options:

  • deno.enable: Controls if the Deno Language Server is enabled. When enabled, the extension will disable the built-in VSCode JavaScript and TypeScript language services, and will use the Deno Language Server (deno lsp) instead. boolean, default false
  • deno.disablePaths: Controls if the Deno Language Server is disabled for specific paths of the workspace folder. Defaults to an empty list.
  • deno.enablePaths: Controls if the Deno Language Server is enabled for only specific paths of the workspace folder.
  • deno.path: A path to the deno executable. If unset, the extension will use the environment path to resolve the deno executable. If set, the extension will use the supplied path. The path should include the executable name (e.g. /usr/bin/deno, C:\Program Files\deno\deno.exe).
  • deno.cache: Controls the location of the cache (DENO_DIR) for the Deno language server. This is similar to setting the DENO_DIR environment variable on the command line.
  • deno.cacheOnSave: Controls if the extension should cache the active document's dependencies on save.
  • deno.codeLens.implementations: Enables or disables the display of code lens information for implementations for items in the code. boolean, default false
  • deno.codeLens.references: Enables or disables the display of code lens information for references of items in the code. boolean, default false
  • deno.codeLens.referencesAllFunctions: Enables or disables the display of code lens information for all functions in the code. Requires deno.codeLens.references to be enabled as well. boolean, default false
  • deno.codeLens.test: Enables or disables the display of test code lens on Deno tests. boolean, default false. This feature is deprecated, see deno.testing below
  • deno.codeLens.testArgs: Provides additional arguments that should be set when invoking the Deno CLI test from a code lens. array of strings, default [ "--allow-all" ].
  • deno.config: The file path to a configuration file. This is the equivalent to using --config on the command line. The path can be either be relative to the workspace, or an absolute path. It is recommended you name this file either deno.json or deno.jsonc. string, default null, examples: ./deno.jsonc, /path/to/deno.jsonc, C:\path\to\deno.jsonc
  • deno.documentPreloadLimit: Maximum number of file system entries to traverse when finding scripts to preload into TypeScript on startup. Set this to 0 to disable document preloading.
  • deno.importMap: The file path to an import map. This is the equivalent to using --import-map on the command line. Import maps provide a way to "relocate" modules based on their specifiers. The path can either be relative to the workspace, or an absolute path. string, default null, examples: ./import_map.json, /path/to/import_map.json, C:\path\to\import_map.json
  • deno.inlayHints.enumMemberValues.enabled - Enable/disable inlay hints for enum values.
  • deno.inlayHints.functionLikeReturnTypes.enabled - Enable/disable inlay hints for implicit function return types.
  • deno.inlayHints.parameterNames.enabled - Enable/disable inlay hints for parameter names. Values can be "none", "literals", "all".
  • deno.inlayHints.parameterNames.suppressWhenArgumentMatchesName - Do not display an inlay hint when the argument name matches the parameter.
  • deno.inlayHints.parameterTypes.enabled - Enable/disable inlay hints for implicit parameter types.
  • deno.inlayHints.propertyDeclarationTypes.enabled - Enable/disable inlay hints for implicit property declarations.
  • deno.inlayHints.variableTypes.enabled - Enable/disable inlay hints for implicit variable types.
  • deno.inlayHints.variableTypes.suppressWhenTypeMatchesName - Suppress type hints where the variable name matches the implicit type.
  • deno.internalDebug: If enabled the Deno Language Server will log additional internal diagnostic information.
  • deno.internalInspect: Enables the inspector server for the JS runtime used by the Deno Language Server to host its TS server.
  • deno.lint: Controls if linting information will be provided by the Deno Language Server. boolean, default true
  • deno.maxTsServerMemory: Maximum amount of memory the TypeScript isolate can use. Defaults to 3072 (3GB).
  • deno.suggest.imports.hosts: A map of domain hosts (origins) that are used for suggesting import auto completions. (See: ImportCompletions for more information.)
  • deno.testing.args: Arguments to use when running tests via the Test Explorer. Defaults to [ \"--allow-all\" ].
  • deno.unstable: Controls if code will be executed with Deno's unstable APIs. Affects execution which is triggered through the extension, such as test code lenses. This is the equivalent to using --unstable on the command line. boolean, default false

Compatibility

To see which versions of this extension can be used with each version of the Deno CLI, consult the following table.

Deno CLI vscode-deno
1.37.2 onwards 3.34.0 onwards
1.37.1 3.32.0 - 3.33.3
1.37.0 3.28.0 - 3.31.0
? - 1.36.4 3.27.0

Version ranges are inclusive. Incompatibilites prior to 3.27.0 were not tracked.

Contribute

Learn how to setup & contribute to this project

Thanks

This project was inspired by justjavac/vscode-deno and axetroy/vscode-deno. Thanks for their contributions.

License

The MIT License

vscode_deno's People

Contributors

asyncmax avatar axetroy avatar bartlomieju avatar cgqaq avatar crowlkats avatar dependabot[bot] avatar dsherret avatar hashrock avatar irbull avatar jespertheend avatar jsejcksn avatar justjavac avatar kirlovon avatar kitsonk avatar leokuma avatar liamolucko avatar lightspeedlucas avatar lucacasonato avatar marvinhagemeister avatar maximousblk avatar mgenereu avatar msal4 avatar nayeemrmn avatar norio-nomura avatar parrotdance avatar qu4k avatar ry avatar wingzer0o avatar zandaqo avatar zhmushan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode_deno's Issues

importmap using local files

I can't get local files working using deno.importmap and the plugin. works from deno.
(deno rc1), plugin 1.28.0, windows.

image

Why vs code doesn't show types for Deno

I've installed this plugin, but when I try to write code, for example:

console.log(Deno.readDirSync("."));

vs code shows me an error:
Cannot find name 'Deno'.ts(2304)
I use built-in version of TypeScript. Do I need to download types somehow?

Configure deno executable path

I use direnv to set PATH per project. Which means:

~$ which deno
deno not found

~$ cd deno-playground 
direnv: loading .envrc                                                                                                                                                           
direnv: export ~PATH

~/deno-playground$ which deno
/home/user/.deno-1.0/bin/deno

I think a settings field like "deno.denoPath" should be introduced just like "python.pythonPath".

Debug support

I noticed if I hit F5 to run & debug it doesn't work. What's the status and upstream work to be done for this feature?

Unclear how to indicate tsconfig to plugin

I'm using a tsconfig.json to add "DOM" to the lib compilerOptions for typescript, and running deno bundle -c tsconfig.json whatever.ts. I can't see any way to get the plugin to acknowledge the existing of the DOM lib though. Is this supported?

Top-level 'await' is not recognized by extension

I have installed latest Deno extenstion version from VSCode marketplace and everything is ok except the top-level await statements. It seems that extension just does not recognize them:

image

Output of deno --version command:

❯ deno --version
deno 1.0.0
v8 8.4.300
typescript 3.9.2

VSCode version:

❯ code --version
1.42.1
c47d83b293181d9be64f27ff093689e8e7aed054
x64

OS: macOS Mojave 10.14.6 18G2022 x86_6

can't resolve wsl paths on windows10

Hi!

I'm using vscode on windows10.
My project is located in the wsl2 directory.

issue

when I use modules with URL, an error has occurred.

typescript server log is here.

Info 70   [21:46:3.354] [typescript-deno-plugin] baseUrl: file:///wsl$/Ubuntu-20.04/home/path/to/project/
Info 71   [21:46:3.354] [typescript-deno-plugin] module "https://deno.land/[email protected]/path/mod.ts" can not resolved

and relative path's error log is,



Info 75   [21:46:3.355] [typescript-deno-plugin] moduleName: ../util.ts
Info 76   [21:46:3.355] [typescript-deno-plugin] e: TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute
    at getPathFromURLWin32 (internal/url.js:1310:13)
    at Object.fileURLToPath (internal/url.js:1342:22)
    at parseModuleName (C:\Users\xxx\.vscode\extensions\denoland.vscode-deno-1.24.0\node_modules\typescript-deno-plugin\out\index.js:331:30)
    at ConfiguredProject.tsLsHost.resolveModuleNames (C:\Users\xxx\.vscode\extensions\denoland.vscode-deno-1.24.0\node_modules\typescript-deno-plugin\out\index.js:95:50)
    at Object.compilerHost.resolveModuleNames (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:135192:52)
    at resolveModuleNamesWorker (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97713:127)
    at resolveModuleNamesReusingOldState (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97983:24)
    at processImportedModules (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:99448:35)
    at findSourceFile (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:99191:17)
    at c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:99020:85
    at getSourceFileFromReferenceWorker (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:98987:34)
    at processSourceFile (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:99020:13)
    at processRootFile (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:98843:13)
    at c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97809:60
    at Object.forEach (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:167:30)
    at Object.createProgram (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97809:16)
    at synchronizeHostData (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:135218:26)
    at Object.getProgram (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:135310:13)
    at ConfiguredProject.Project.updateGraphWorker (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:139786:53)
    at ConfiguredProject.Project.updateGraph (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:139729:42)
    at ConfiguredProject.updateGraph (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:140654:63)
    at ProjectService.createLoadAndUpdateConfiguredProject (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:142246:25)
    at ProjectService.assignProjectToOpenedScriptInfo (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:143101:44)
    at c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:143396:107
    at Object.mapDefined (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:562:30)
    at ProjectService.applyChangesInOpenFiles (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:143396:48)
    at Session.handlers.ts.createMapFromTemplate._a.<computed> (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:144260:46)
    at c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:146003:88
    at IOSession.Session.executeWithRequestId (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:145994:28)
    at IOSession.Session.executeCommand (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:146003:33)
    at IOSession.Session.onMessage (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:146027:35)
    at Interface.<anonymous> (c:\tools\VSCode-win32-x64\resources\app\extensions\node_modules\typescript\lib\tsserver.js:147342:27)
    at Interface.emit (events.js:203:13)
    at Interface._onLine (readline.js:316:10)
    at Interface._normalWrite (readline.js:461:12)
    at Socket.ondata (readline.js:172:10)
    at Socket.emit (events.js:203:13)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at Socket.Readable.push (_stream_readable.js:210:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)

Do you have any solutions?

Go to definition on cached dependancy results in non-syntax highlighted code

Not sure if this extension is at fault for this, but hopefully this can be improved in some way.

When using VS Code's "Go to definition" on a type that comes from the cache, the resulting file opened in VS Code does not have syntax highlighting.

Example

import { serve } from "https://deno.land/std/http/server.ts";

const body = "Hello World\n";

const s = serve({ port: 8000 });
for await (const req of s) {
  req.respond({ body });
}

Right click > Go to Definition on serve

It correctly opens the file, but the file name does not end in ts, which is why I am assuming its not highlighted.

Screen Shot 2020-05-14 at 1 47 50 PM

'TSServer exited with code: 3221225477' since new VSCode version

Since the last version update of VS Code the extension causes the following error.

[Info  - 08:09:30.553] Starting TS Server 
[Info  - 08:09:30.553] Using tsserver from: c:\Users\Dev\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib
[Info  - 08:09:30.557] <syntax> Forking...
[Info  - 08:09:30.567] <syntax> Starting...
[Info  - 08:09:30.571] <semantic> Forking...
[Info  - 08:09:30.580] <semantic> Starting...
[Error  - 08:09:35.702] TSServer exited with code: 3221225477

After 5 retries it crashes and disables the TypeScript Language Service.

My tsconfig.json is:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "plugins": [
      {
        "name": "typescript-deno-plugin"
      }
    ]
  }
}

The settings in VS Code for the extension are the defaults.

I am using Windows 10, and this is the VS Code version:

Version: 1.45.1 (user setup)
Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
Date: 2020-05-14T08:27:35.169Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363

1.0

vscode extension for Deno has a new repository now 🎉, so we should start from scratch(0.x), and publish a usable version when Deno 1.0 is released.

  • use github actions #2
  • publish 0.x on VS Code Marketplace
  • mark original extension as deprecated and redirect to the official extension justjavac/vscode-deno#76
  • use github actions to auto publish
  • use LSP #5
  • import maps
  • webworker #9
  • auto(or manual) deno cache when importing a module that has not been cached
  • provides deno fmt as a formatter #10
  • provide autocomplete for std modules when type 'import ... from "'
  • when package.json is detected in the root directory, display a prompt "disable Deno extension or not".(I've received a lot of feedback that this extension will break non Deno projects when it's enabled.) #7
  • support @deno_types #21
  • debug

beyond 1.0

  • force use of Deno's built-in version of typescript(current we use of VSCode's built-in version)
  • coexist deno and node in the same project

future

  • rewrite LSP's server side with Deno itself [need discuss]

Allow without semicolon

When I'm write
import { Application } from "https://deno.land/x/oak/mod.ts"

then save it, this will turn into a semicolon filled syntax:

import { Application } from "https://deno.land/x/oak/mod.ts";

I think some programmers don't like the existence of this semicolon, so it is better to have the semicolon following the style of the programmer, without changing the code to semicolon or non-semicolon.

debugger Deno.openSync or Deno.open, Uncaught NotFound

image
vscode launch configuration

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Deno",
      "type": "node",
      "request": "launch",
      "cwd": "${workspaceFolder}",
      "runtimeExecutable": "deno",
      "runtimeArgs": [
        "run",
        "--inspect-brk",
        "-A",
        "demo/writeSync/index.ts"
      ],
      "port": 9229
    }
  ]
}

Installed VSCode plugin but still not able to catch deno syntax

Following the tutorial in the docs:

const res = await fetch("https://jsonplaceholder.typicode.com/todos/1");
const body = new Uint8Array(await res.arrayBuffer());
await Deno.stdout.write(body);

I still get underline on the await:

'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.ts(1375)

And underline on the Deno

Cannot find name 'Deno'.ts(2304)

while if I run the file with deno, it obv runs. But vscode underlines are very irritating as well as it is not giving any type suggestions for Deno object.

I installed the plugin Deno 1.32.0 by justjavac. I tried doing [command]+[p] and > Enable Deno, which says deno is already enabled.

I tried to find any similar issue but seems it's not there while my issue is very basic regarding installation. I went through Readme but not able to solve the problem. Can you please help me what more I need to do to get it working?

Conflict with Prettier extension

I've find out that even if Deno extension is disabled, my JS/TS code is still being formatted according to Deno rules. So, if there's a Node.js project which uses Prettier (and has required configuration), VSCode uses Deno extension to format all the code instead of Prettier. It is unexpected behavior for cases when Deno extension is explicitly disabled.

The remote module has not been cached locally

Hello,
I have been trying out Deno a bit, but I always have this same error in my .ts file.
The remote module "https://deno.land/std/async/delay.ts" has not been cached locally ts(10002)

But the file IS cached locally, it doesn't get downloaded again when I start the file, but it still always shows me this error. This is really annoying, and I can't seem to find a way to fix it.

Squiggly lines

Still seeing squiggly lines even after installing the extension.

Screenshot 2020-05-19 at 12 14 55 PM

Screenshot 2020-05-19 at 12 15 06 PM

Use github actions

Here is the old travis.yml

sudo: false
language: node_js

env:
  global:
    - DENO_VERSION=v0.40.0
    - YARN_VERSION=1.19.2

node_js:
  - "12"

cache:
  directories:
    - "node_modules"
  yarn: true

before_install:
  - curl -L https://deno.land/x/install/install.sh | sh -s $DENO_VERSION
  - export PATH="$HOME/.deno/bin:$PATH"
  - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
  - export PATH="$HOME/.yarn/bin:$PATH"
install:
  - yarn global add vsce
  - yarn

script:
  - yarn run check
  - yarn compile
  - vsce package

Failed to Detect Deno

I'm experiencing the same issue as https://github.com/justjavac/vscode-deno/issues/78; starting a new issue here since this seems to be the location of new development.

Mac Mojave 10.14.6
VS Code 1.45.0
VS Code Deno Extension version 1.27.0
Deno 1.0.0

Environment

$ deno info
DENO_DIR location: "/Users/ME/.deno"
Remote modules cache: "/Users/ME/.deno/deps"
TypeScript compiler cache: "/Users/ME/.deno/gen"
$ deno eval 'console.log(JSON.stringify(Deno.version))'
{"deno":"1.0.0","v8":"8.4.300","typescript":"3.9.2"}
$ env | grep -i deno
DENO_INSTALL=/Users/ME/.deno
DENO_DIR=/Users/ME/.deno
$ which deno
/Users/ME/.deno/bin/deno

I use zsh as my main shell environment.

I tracked the error down to

const { stdout, stderr } = await execa("deno", [
and saw it's using execa. From the execa README.

Unless the shell option is used, no shell interpreter (Bash, cmd.exe, etc.) is used, so shell features such as variables substitution (echo $PATH) are not allowed.

I export DENO_INSTALL and DENO_DIR in my .zshrc file and add it to the path. Perhaps execa isn't finding Deno because it's not in the standard PATH locations?

Does anyone think it's better to set the default value of deno.enable to false

First of all, thank you for writing such a great plugin。When I wrote deno, it helped me a lot

But most of my projects are nodejs or pure front-end projects. When I use vscode to open these projects, I need to set the deno.enable property in the settings.json file. Otherwise, vscode will give a lot of warnings.

I feel a little annoyed. Because I don't want to create the settings.json file in some projects. If I forget to ignore the file in .gitignore, I may accidentally upload this file to the remote repository. This may confuse my partners.

Why not consider setting the default value of deno.enable to false?

Warning prompt in VS Code

Today, while working with some small TS files, I found this message popping up on my VS Code notification system. I don't know exactly why this happens, if it is a VS Code issue or a Deno extension issue.

The extension 'Deno' took a very long time to complete its last
operation and it has prevented other extensions from running.

image

  • Issue Type: Performance
  • Extension Name: vscode-deno
  • Extension Version: 1.24.0
  • OS Version: Windows_NT x64 10.0.18362
  • VSCode version: 1.45.1

Explain why deno.enable exists

The setting says:

Controls whether deno is enabled or not.

I'm assuming this is necessary so it doesn't clash with builtin TS/node support, it would be best to spell that out though.

Better Auto-Imports

One of the problem with importing files at the moment is that it does not do it properly. For example here we can see that when I auto-import this file it will create:

import { cache } from "utils/cache";

image

However the actual path is ./utils/cache.ts
It is missing the ./ and the ending of .ts
image

image

Note: These were all working on Axetroys extension but after switching over this is have quite a few issues.

Thank you

Set root folder for plugin

Is there a away to set the root folder for the deno code? Currently it seems like it can only be limited to a workspace but my workspace contains the following:

workspace
|--client (Angular app)
|--server (deno app)

Enabling the plugin globally or for the workspace results in me geting all sorts of errors in my Angular project (bad imports without extensions).

Multiple workspaces in a single window is not yet a feature in vscode so I have to use multiple vscode windows.

Is there a way to avoid this?

VScode JS IntelliSense

this VS code extension has removed/disabled VS code built in IntelliSense for JS
ie. doc... no longer suggests document
querys.. no longer suggests querySelector .

cannot find name 'Deno'

image

imports seem to work correctly, deno seems to be running:

image

I didn't change any settings. what am I missing?

Support @deno_types

the @deno_types directive don't work correctly in vscode type check. For example:
a.js

export const a = 100

a.d.ts

declare const a: boolean
export {a}

Variable a should has type boolean instead of number literal 100 in vscode type checker.
image

deno builtin type checker is correct when i run the program.
image

Option to enable single quotes

I have Prettier Single Quote enabled. When the plugin is installed, the prettier single quotes settings are overwritten to double quotes. That's fine when in a deno project. But when I went back to a node.js project, existing single quotes in the file gets converted to double quotes. Saw the Prettier Single Quote check in the settings was enabled but still double quotes are getting created. So I tried unchecking and checking it back making the Prettier single quote setting overwrite on the Deno plugin double quote setting and single quotes get set as expected.

So, if Deno plugin is disabling itself when in a node js project, it should also remove it's double quote setting so that user's Prettier settings get restored. When user gets back to a deno project, it can enable the double quotes.

Great work

I just wanted to pop by and say I enjoyed using this extension when working with deno!

The typescript language server plugin route is a smart idea

Option for deno plugin to be enabled in only some directories.

It would be great if I could specify whether the plugin was enabled per directory.
My use-case is the following directory structure:

server/ <- deno sources for my server code
web/ <- the typescript here will be bundled using parcel and served by the server code

When the deno plugin is enabled, the server/ code autocompletes just fine but the web/ code breaks with errors like "cannot find name document".

I know that you can use the .vscode/settings.json to enable and disable the deno plugin, but as far as I'm aware that doesn't work in the case where I want to have both of these folders open and the extension to run depending on which path the file I'm editing is in.

Using any PIKA.DEV package causes TypeScript language service to die. TS Server fatal error: Maximum call stack size exceeded

This plugin struggles with TS types received via X-TypeScript-Types in response header, and will cause TypeScript language service to die if you import any package from pika.dev

TypeScript Version: 4.0.0-dev.20200516
Steps to reproduce crash

  1. Create a file and name it mod.ts
  2. Paste this to it:
 import * as pkg from 'https://cdn.pika.dev/react@^16.13.1'
 console.log(pkg)
  1. Run
    deno run ./mod.ts

TS Server Error Stack

RangeError: Maximum call stack size exceeded
    at new URLSearchParams (internal/url.js:126:14)
    at URL.onParseComplete (internal/url.js:236:26)
    at parse (<anonymous>)
    at new URL (internal/url.js:319:5)
    at Function.create (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/hash_meta.js:78:43)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:19:43)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/universal_module_resolver.js:11:66)
    at Object.resolve (/home/igor/.vscode/extensions/justjavac.vscode-deno-1.31.0/node_modules/typescript-deno-plugin/out/module_resolver/remote_module_resolver.js:40:84)

Working with executable scripts that have extension-less filenames

Hi @justjavac - thank you for your work on vscode-deno!

I encountered a couple of issues related to executable scripts.

1. Auto detection of Deno executable scripts (without .ts file extension)

This is more of a suggestion for vscode-deno (however, the 2nd point below is directly related to this and seems like an issue).

It might be a good addition to this extension if it can recognize executable scripts (especially .ts extension-less ones) as possible Deno scripts.

For example, let's say I have some Deno executable scripts (without a .ts extension)

.
└── bin
   ├── setup
   ├── build
   └── deploy

And the content of those scripts looks something like this:

#! /usr/bin/env deno run --allow-read --allow-write

import * as fs from "https://deno.land/std/fs/mod.ts";
import * as path from "https://deno.land/std/path/mod.ts";

// ...

Currently, when I open such files in VS Code, they show up as plaintext.

If I have vscode-deno installed, it would be nice if it automatically switches the file language to typescript. This can be done by scanning the first line of the document - for example:

function setTextDocumentLanguageByFirstline(document: vscode.TextDocument) {
  if (document.lineAt(0).text.match(/^\#!.*\bdeno\b/)) {
    await vscode.languages.setTextDocumentLanguage(document, 'typescript');
  }
}

vscode.workspace.textDocuments.forEach(setTextDocumentLanguageByFirstline);
vscode.workspace.onDidOpenTextDocument(setTextDocumentLanguageByFirstline);

Worth mentioning that VSCode already does something like this with Node (and a plenty of other languages)! If I create a file without an extension and the first line in the file is #! /usr/bin/env node, VSCode automatically sets the language to javascript.

2. Deno features are not enabled when changing the language mode from Plain Text to TypeScript

Now, dealing with the same files above, when I try to manually change the language of a given script from plaintext to typescript, that does not seem to trigger the Deno Language Server/Service for those files.

It seems that Deno specific features are only available if the file has .ts extension in its filename. Axetroy's implementation, on the other hand, works with extension-less filenames after changing the language manually from plaintext to typescript.

[Discussion] Possible solution to fix delays and versioning confusion: Merge `typescript-deno-plugin` into `vscode_deno`?

Versioning confusion

At the moment we have:

The vscode_deno 1.24.0 official plugin that depends on, and is currently bundled with the 3rd party typescript-deno-plugin 1.29

  • typescript-deno-plugin v1.29.0 was released 19 days ago
  • It is now up to version v1.31.0 which was released 8 days ago. vscode_deno 1.24.0 still includes typescript-deno-plugin 1.29, not the new one.

There is no changelog for vscode_deno https://github.com/denoland/vscode_deno/releases

And the VS Marketplace one does not make sense: https://marketplace.visualstudio.com/items/denoland.vscode-deno/changelog

Moved from https://github.com/justjavac/vscode-deno to https://github.com/denoland/vscode_deno in order to have an "official" Deno plugin. Thank you 迷渡!

Problems of having a split codebase

It seems half the bug fixes are more relevant to the typescript-deno-plugin, which is not official and is not where users are directed to for reporting issues. If they do get through to that repo, and get the bug fixed, then they don't get merged into the vscode_deno extension right away. There is a random time-lapse that means all the error reports on the two different repos are out of sync.

I don't want to sound like I am complaining, and really appreciate the work @justjavac and others are doing, but something seems fundamentally wrong with the way this extension is setup and operates.

There should be one central place that people report bugs, and at least a few different people with the authority to accept the pull requests for the official Deno plugin as a whole, not split up. Having the extension split over two separate codebases, one official and the other 3rd party seems very complicated and unnecessary.

I spent a while this morning puzzling over why my JS was getting treated like it was TS even with "deno.enable": false. When I turn off the extension then it works! I think this bug was fixed in typescript-deno-plugin v1.30.0, 9 days ago #60, but I don't know as it is not yet merged into vscode_deno

I hope this issue has not been too confused, but I am very confused by the whole VS Code Deno extension situation.

THANKS again to everyone involved!

[Bug] Importing ES6 modules from the web isn't fool proof.

To experience this yourself, simply write the following:

import { encode as msgpackEncode, decode as msgpackDecode } from "https://cdn.pika.dev/messagepack@^1.1.10";

Because the JS attempts to import URLs that begin with a /, it interprets them relative to the harddrive than to the URL.

// NOTE: Don't directly import the browser-optimized URLs below! Import the current file/URL instead.
export * from '/-/[email protected]/dist=es2017/messagepack.js';
export {default} from '/-/[email protected]/dist=es2017/messagepack.js';
import '/-/@pika/[email protected]/dist=es2017/polyfill.js';

Feature request - disable Deno extension in Node.js projects

As I understand it is only possible to disable Deno extension manually with "deno.enable": false in vscode settings.json. But I think it can be more comfortable if extension would automatically being disabled in projects that have package.json file or node_modules folder inside.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.