emacs/var/elfeed/db/data/eb/ebc6629788bb0fb47d77a6453eb873a9940154ea
2022-01-03 12:49:32 -06:00

1 line
1.5 KiB
Plaintext

<!-- SC_OFF --><div class="md"><p>I have node project (type: module in package.json) and I use typescript lang server.</p> <p>want to make this work: <code>import { scaleBand } from &quot;d3-scale&quot;;</code> but can&#39;t figure out how. require-ing it works fine.</p> <p>autocomplete and lsp-find-definition don&#39;t work, with the latter giving this error</p> <pre><code>helm-M-x-execute-command: Wrong type argument: (or eieio-object class), #s(xref-item #(&quot;export function scaleBand&lt;Domain extends { toString(): string } = string&gt;(&quot; 16 25 (face highlight)) #s(xref-file-location &quot;/Users/xxx/Library/Caches/typescript/4.2/node_modules/@types/d3-scale/index.d.ts&quot; 2517 16)), obj </code></pre> <p>edit: </p> <p>eldoc works, no the symbol&#39;s type is known to lsp. autocomplete is actually OK.</p> <p>however it&#39;s not about import vs. require. The destructuring seems to cause the problem. Doing like bellow causes no errors, but still does not navigate to the definition inside the d3-scale module.</p> <pre><code>import d3_scale from &quot;d3-scale&quot;; const { scaleBand } = d3_scale; </code></pre> <p>&#x200B;</p> </div><!-- SC_ON --> &#32; submitted by &#32; <a href="https://www.reddit.com/user/gdanov"> /u/gdanov </a> <br/> <span><a href="https://www.reddit.com/r/emacs/comments/q87eg8/lspmode_javascript_node_es2020_import_problem/">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/emacs/comments/q87eg8/lspmode_javascript_node_es2020_import_problem/">[comments]</a></span>