<p dir="auto">There should be a way to add typings for specific version of ts(e.g. <code class="notranslate">2.1</code>). The tests should run on ts 2.1 and packages should require typescript 2.1 in their package.json.<br>
So what is the best way to do it?</p>
<p dir="auto">It makes sense to not want to break existing users with a "^" dependency on something like <code class="notranslate">@types/react</code>, but it hinders the very users and organizations that help the TS ecosystem. The introduction of <code class="notranslate">Partial&lt;&gt;</code> and co in particular is a big game changer, and many users would benefit from updates to react and lodash in particular.</p>
<p dir="auto">The current policy has been stated as waiting 30 days before allowing new features into DefinitelyTyped to avoid breaking people. While I disagree with the policy, I think it we as a community can do better to support those on the bleeding edge.</p>
<p dir="auto">Considering the situation, I'd like to propose a few options.</p>
<p dir="auto"><strong>Option A</strong>, do nothing. There are work arounds if you want to start moving fast, such as hacking <code class="notranslate">paths</code> and <code class="notranslate">typeRoots</code> in your tsconfig. I have documented one such solution here: <a href="https://medium.com/@ericlanderson/using-custom-typescript-definitions-with-ts-2-x-3121db84015d#.tvqw3rmth" rel="nofollow">https://medium.com/@ericlanderson/using-custom-typescript-definitions-with-ts-2-x-3121db84015d#.tvqw3rmth</a></p>
<p dir="auto">While this works, its a hassle.</p>
<p dir="auto"><strong>Option B</strong>: Someone (maybe me) forks DefinitelyTyped and allows changes for the latest and greatest right away. I could publish this as something like "types-edge" in npm and provide documentation for how to configure your tsconfig to allow for it to work.</p>
<p dir="auto">While this works, it half forks the community, and creates a burden on myself to keep up to date with DefinitelyTyped. It also hinders discoverability. I think this hurts the ecosystem, but its better than everyone manually forking type definitions.</p>
<p dir="auto"><strong>Option C</strong>: DefinitelyTyped and Microsoft support the development of these edge versions on a branch within DefinitelyTyped (lets call it "edge" or even use "master"). Microsoft could then register the org @types-edge and publish the edge branch. The DefinitelyTyped and Microsoft people could then as a group keep merging types-2.0 (which should really be called "stable" in this world) into edge, while allowing the community to grow and move quickly. If desired, there could also be a "nightly" branch and a corresponding @types-nightly (I would have personally liked this as the second <code class="notranslate">Partial&lt;&gt;</code> and <code class="notranslate">keyof</code> got merged, I started using it immediately). This would also mean the types are already being updated and ready to go when the next TS release happens.</p>
<p dir="auto">There could also be a release of typescript 2.1.1 pretty quickly that adds "./node_modules/@types-edge" to the default list of for the <code class="notranslate">paths</code> and the <code class="notranslate">typeRoots</code> in tsconfig.</p>
<p dir="auto">I think this is the best short-term solution.</p>
<p dir="auto"><strong>Option D</strong>: Add macros to TS. (Yeah this is dirty). But the macros could allow things like <code class="notranslate">#if typescriptVersion &gt;= 2.1.0</code> and allow additional definitions to be placed into the type files. This would still require the 30 day grace period before it could be introduced (maybe in TS 2.2?) but would future proof this problem and allow just a single npm org for publishing types. Its also not backwards compatible, but it would be the easiest to maintain in DefinitelyTyped.</p>
<p dir="auto"><strong>Option E</strong>: Add additional meta-data support to package.json to declare types with a minimum version. This could look something like:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;...&quot;: &quot;...&quot;,
  &quot;types2&quot;: {
    &quot;&gt;=2.1.0&quot;: &quot;index-2.1.0.d.ts&quot;
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"..."</span>: <span class="pl-s"><span class="pl-pds">"</span>...<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"types2"</span>: {
    <span class="pl-ent">"&gt;=2.1.0"</span>: <span class="pl-s"><span class="pl-pds">"</span>index-2.1.0.d.ts<span class="pl-pds">"</span></span>
  }
}</pre></div>
<p dir="auto">Newer versions of typescript can look at this instead of <code class="notranslate">types</code> and choose the highest version that maps.</p>
<p dir="auto">This would be a PITA to support, IMHO. You could do it with branches in DT, but now we have to support forward merging changes to types-2.0 to types-2.1 and then types-2.2, etc. Or you have to keep the different versions in the same branch and remember to change them all when adding new functionality.</p>
<p dir="auto">Another way to do this, which I have no idea if it would work given future changes to TS are unknown, is write scripts that convert the latest typings into older versions. For example, pretty much every typing that would want <code class="notranslate">Partial&lt;T&gt;</code> could just be mutated at the time the publisher runs to replace it with <code class="notranslate">T</code>. <code class="notranslate">Pick</code> is probably <code class="notranslate">any</code> in the old world. <code class="notranslate">ReadonlyArray</code> support wouldn't have been broken cause it could just be <code class="notranslate">Array</code>. This would require custom scripts for each new release but it might not be awful.</p>
<p dir="auto">There are probably other ways to do it, but these are the ones that came to me today. I would really love to hear the opinions of a bunch of people: <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/andy-ms/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/andy-ms">@andy-ms</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ahejlsberg/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ahejlsberg">@ahejlsberg</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pspeter3/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pspeter3">@pspeter3</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/vsiao/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/vsiao">@vsiao</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/johnnyreilly/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/johnnyreilly">@johnnyreilly</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/jkillian/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/jkillian">@jkillian</a>, and more.</p>
<p dir="auto">Thanks</p>