Syndicated Actors feed for tag "typescript"2024-02-19T21:31:57+00:00https://syndicate-lang.org/journal/tag/typescript/index.atomTypeScript IDE Syndicate plugin: good news and bad news2023-04-29T08:34:51+00:00Tony Garnock-Joneshttps://syndicate-lang.org/journal/2023/04/29/syndicate-ts-plugin<p>Because the TypeScript implementation has been moving on along its own roadmap, the IDE-support
(Language Server Protocol, LSP) part of the <a href="https://git.syndicate-lang.org/syndicate-lang/syndicate-js/src/branch/main/packages/ts-plugin">TypeScript compiler plugin</a> that I
wrote (<a href="https://www.npmjs.com/package/@syndicate-lang/ts-plugin">npm</a>, <a href="https://git.syndicate-lang.org/syndicate-lang/syndicate-js/src/branch/main/packages/ts-plugin">git</a>) has stopped working properly with recent
TypeScript releases.</p>
<p><code class="language-plaintext highlighter-rouge">ts-plugin</code> versions older than 0.15.2 don’t work well with TypeScript 4.9; it’s possible they
haven’t worked well since TypeScript 4.5.</p>
<h2 id="the-good-news">The good news</h2>
<p>The good news is that <a href="https://www.npmjs.com/package/@syndicate-lang/ts-plugin"><code class="language-plaintext highlighter-rouge">@syndicate-lang/ts-plugin</code></a> version 0.15.2 includes a
few changes that make it work much better with TypeScript 4.9. So if you update to 0.15.2, you
should see good support for the Syndicate DSL overlaid atop the normal TypeScript support in
Emacs, VSCode, etc.</p>
<h2 id="the-bad-news">The bad news</h2>
<p>The bad news is that the monkeypatching I’ve been doing to hook into the necessary parts of the
TypeScript <code class="language-plaintext highlighter-rouge">tsserver</code> will no longer work for TypeScript versions 5.0 and higher. The problem
is that, in <code class="language-plaintext highlighter-rouge">tsserver</code> 4.9, simple properties were used for values like <code class="language-plaintext highlighter-rouge">ts.createSourceFile</code>
and <code class="language-plaintext highlighter-rouge">ts.server.ScriptInfo</code>, so the <code class="language-plaintext highlighter-rouge">ts-plugin</code> was able to hook them to insert the Syndicate
DSL expansion process. In 5.0, by contrast,
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty"><code class="language-plaintext highlighter-rouge">Object.defineProperty</code></a>
is used to define a non-writable, non-configurable property. It’s essentially game over for the
existing <code class="language-plaintext highlighter-rouge">ts-plugin</code> approach at this point.</p>
<h2 id="so-what-now">So what now?</h2>
<p>Having <code class="language-plaintext highlighter-rouge">ts-plugin</code> IDE support is <em>really nice</em> for Syndicate programming. So I feel compelled
to find <em>some</em> kind of solution.</p>
<p>Perhaps I need to write a real LSP implementation, backing into a captive <code class="language-plaintext highlighter-rouge">tsserver</code> instance?</p>
<p>I’ve <a href="https://git.syndicate-lang.org/syndicate-lang/syndicate-js/issues/2">opened an issue on the <code class="language-plaintext highlighter-rouge">ts-plugin</code> repository about this</a>.</p>