<p dir="auto">Hello Typescipters,</p>
<p dir="auto">I'm using the <code class="notranslate">Q</code> library with its typings installed via <code class="notranslate">tsd</code>.<br>
In a module I'm using</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/// &lt;reference path=&quot;../typings/q/Q.d.ts&quot;/&gt;
// ..."><pre class="notranslate"><span class="pl-c">/// &lt;reference path="../typings/q/Q.d.ts"/&gt;</span>
<span class="pl-c">// ...</span></pre></div>
<p dir="auto">compiled with</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="tsc -m commonjs --out test.js test.ts
tsc --version
message TS6029: Version 1.4.1.0"><pre class="notranslate">tsc -m commonjs --out test.js test.ts
tsc --version
message TS6029: Version 1.4.1.0</pre></div>
<p dir="auto">and would like <code class="notranslate">test.js</code> to contain a line like</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var Q = require(&quot;path/to/q&quot;); // to be executed by nodejs"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">Q</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"path/to/q"</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// to be executed by nodejs</span></pre></div>
<p dir="auto">where <code class="notranslate">path/to/q</code> points to the javascript file and has nothing to do with <code class="notranslate">../typings/q/Q.d.ts</code>.<br>
Using <code class="notranslate">import Q = require("path/to/q");</code> won't work as it probably expects a typescript module.</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="builder.ts(5,32): error TS2307: Cannot find external module './../bower_components/q/q'."><pre class="notranslate">builder.ts(5,32): error TS2307: Cannot find external module <span class="pl-s"><span class="pl-pds">'</span>./../bower_components/q/q<span class="pl-pds">'</span></span>.</pre></div>
<p dir="auto">I haven't found how to achieve this without rolling out some hackish <em>ad-hoc</em> source markup/parse/replace. Have I overlooked something?</p>
<p dir="auto">In a way I'm trying to "link" to the library code (in the C meaning) with node's <code class="notranslate">require</code> after having included the declarations (references to the <code class="notranslate">d.ts</code>).</p>
<p dir="auto">If this is not currently possible, may I suggest a pass-through version of <code class="notranslate">require()</code> which kicks in when <code class="notranslate">-m commonjs</code> is used? Perhaps <code class="notranslate">js_require("blabla")</code> which would be emitted as node's <code class="notranslate">require("blabla")</code>. This would make it a lot easier to leverage other tools which analyze <code class="notranslate">require</code> statements.</p>
<p dir="auto">Greetings</p>
<p dir="auto">After seeing <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="107380107" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/4884" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/4884/hovercard" href="https://github.com/microsoft/TypeScript/issues/4884">#4884</a>, I'd like to ask about this. Having <code class="notranslate">diagnosticInformationMap.generated.ts</code> in the repo seems fine since it's part of the build, but since we want to check if for duplicate IDs we should consider incorporating the generation of the code into the standard build process, rather than a script run by hand as-needed.</p>
<p dir="auto">The only downsides I can see are that editor intellisense for the Diagnostic object won't work after a clean clone until after a build or pre-build is run, and we'll lose the ability to simply run <code class="notranslate">tsc</code> over the compiler folder and get a functioning compiler (you have to generate the generated code first).</p>
<p dir="auto">As far as upsides go, adopting this strategy should result in fewer merge conflicts in diagnostic messages and, additionally, will add a warning in the form of a failed build in a PRs when someone tries to add a message with an identical message id to one in master.</p>
<p dir="auto">To do this, we should remove the generated code file from the repo, add the filename to the <code class="notranslate">.gitignore</code>, and make the script to rebuild it run as part of the build process.</p>
<p dir="auto">Does anyone feel strongly about this?</p>