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

Typescript is not supported for nodejs #47

Open
daniellam258 opened this issue Nov 5, 2021 · 3 comments
Open

Typescript is not supported for nodejs #47

daniellam258 opened this issue Nov 5, 2021 · 3 comments

Comments

@daniellam258
Copy link

I'm new to neovim. It seems that typescript is not supported for jsnode?

@razin99
Copy link

razin99 commented Dec 2, 2021

I'm not sure if this is the correct way, but I got mine to work with this. Basically it loads defaults for jsnode and then configure typescript to use node2.

-- From the instruction on this repo
local dap_install = require("dap-install")
dap_install.config("jsnode", {})
-- From github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#Javascript
local dap = require("dap")
dap.configurations.typescript = {
  {
    name = 'Launch',
    type = 'node2',
    request = 'launch',
    program = '${file}',
    cwd = vim.fn.getcwd(),
    sourceMaps = true,
    protocol = 'inspector',
    console = 'integratedTerminal',
  },
  {
    -- For this to work you need to make sure the node process is started with the `--inspect` flag.
    name = 'Attach to process',
    type = 'node2',
    request = 'attach',
    processId = require'dap.utils'.pick_process,
  },
}

I think the fix applied to #38 (340cb26) can also be done for this issue

@nldev
Copy link

nldev commented Dec 14, 2021

I'm not sure if this is the correct way, but I got mine to work with this. Basically it loads defaults for jsnode and then configure typescript to use node2.

-- From the instruction on this repo
local dap_install = require("dap-install")
dap_install.config("jsnode", {})
-- From github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#Javascript
local dap = require("dap")
dap.configurations.typescript = {
  {
    name = 'Launch',
    type = 'node2',
    request = 'launch',
    program = '${file}',
    cwd = vim.fn.getcwd(),
    sourceMaps = true,
    protocol = 'inspector',
    console = 'integratedTerminal',
  },
  {
    -- For this to work you need to make sure the node process is started with the `--inspect` flag.
    name = 'Attach to process',
    type = 'node2',
    request = 'attach',
    processId = require'dap.utils'.pick_process,
  },
}

I think the fix applied to #38 (340cb26) can also be done for this issue

Not having much luck with this, :lua require"dap".continue() seems to just fail silently now (was having the same issue as OP before)

@nldev
Copy link

nldev commented Dec 14, 2021

Was able to get typescript working after running DIInstall jsnode, adding outFiles to the above config (see below), and running tsc -p . in the project root. Not sure if dap is supposed to build .ts files itself, but this is trivial to do from vim anyway. Full config:

local dap_install = require('dap-install')
dap_install.config('jsnode', {})
local dap = require('dap')
dap.configurations.typescript = {
  {
    name = 'Run',
    type = 'node2',
    request = 'launch',
    program = '${file}',
    cwd = vim.fn.getcwd(),
    sourceMaps = true,
    protocol = 'inspector',
    console = 'integratedTerminal',
    outFiles = {"${workspaceFolder}/build/**/*.js"},
  },
  {
    name = 'Attach to process',
    type = 'node2',
    request = 'attach',
    processId = require'dap.utils'.pick_process,
  },
}

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

3 participants