<p dir="auto">This 'issue' may be behaviour by design, but I couldn't find a suitable reference to this logic anywhere. So apologies if that is the case.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ tsc --version
message TS6029: Version 1.8.0-dev.20151105"><pre class="notranslate"><code class="notranslate">$ tsc --version
message TS6029: Version 1.8.0-dev.20151105
</code></pre></div>
<p dir="auto">Steps to repro:</p>
<ul dir="auto">
<li>Create empty TypeScript project in <code class="notranslate">/tmp/path/to/my/project/</code></li>
<li>Create a <code class="notranslate">tsconfig.json</code> as follows:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
    &quot;compilerOptions&quot;: {
        &quot;module&quot;: &quot;system&quot;,
        &quot;target&quot;: &quot;es5&quot;,
        &quot;noImplicitAny&quot;: false,
        &quot;sourceMap&quot;: false
    },
    &quot;exclude&quot;: [
        &quot;node_modules&quot;
    ]
}"><pre class="notranslate"><code class="notranslate">{
    "compilerOptions": {
        "module": "system",
        "target": "es5",
        "noImplicitAny": false,
        "sourceMap": false
    },
    "exclude": [
        "node_modules"
    ]
}
</code></pre></div>
<ul dir="auto">
<li>Create a single TypeScript file <code class="notranslate">/tmp/path/to/my/project/test.ts</code>:</li>
</ul>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import * as React from &quot;react&quot;;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-smi">React</span> <span class="pl-k">from</span> <span class="pl-s">"react"</span><span class="pl-kos">;</span></pre></div>
<ul dir="auto">
<li>Compile with <code class="notranslate">tsc</code>. Observe the following output as expected (because we haven't installed the type definition file anywhere):</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test.ts(1,24): error TS2307: Cannot find module 'react'."><pre class="notranslate"><code class="notranslate">test.ts(1,24): error TS2307: Cannot find module 'react'.
</code></pre></div>
<p dir="auto">What's interesting however is the output of <code class="notranslate">strace</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ strace tsc 2&gt;&amp;1 | grep react
read(9, &quot;import * as React from \&quot;react\&quot;;\n&quot;, 32) = 32
stat(&quot;/tmp/path/to/my/project/react.ts&quot;, 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat(&quot;/tmp/path/to/my/project/react.d.ts&quot;, 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat(&quot;/tmp/path/to/my/react.ts&quot;, 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat(&quot;/tmp/path/to/my/react.d.ts&quot;, 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat(&quot;/tmp/path/to/react.ts&quot;, 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat(&quot;/tmp/path/to/react.d.ts&quot;, 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat(&quot;/tmp/path/react.ts&quot;, 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat(&quot;/tmp/path/react.d.ts&quot;, 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat(&quot;/tmp/react.ts&quot;, 0x7ffd985dbb00)   = -1 ENOENT (No such file or directory)
stat(&quot;/tmp/react.d.ts&quot;, 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat(&quot;/react.ts&quot;, 0x7ffd985dbb00)       = -1 ENOENT (No such file or directory)
stat(&quot;/react.d.ts&quot;, 0x7ffd985dbb00)     = -1 ENOENT (No such file or directory)"><pre class="notranslate"><code class="notranslate">$ strace tsc 2&gt;&amp;1 | grep react
read(9, "import * as React from \"react\";\n", 32) = 32
stat("/tmp/path/to/my/project/react.ts", 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat("/tmp/path/to/my/project/react.d.ts", 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat("/tmp/path/to/my/react.ts", 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat("/tmp/path/to/my/react.d.ts", 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat("/tmp/path/to/react.ts", 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat("/tmp/path/to/react.d.ts", 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat("/tmp/path/react.ts", 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat("/tmp/path/react.d.ts", 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat("/tmp/react.ts", 0x7ffd985dbb00)   = -1 ENOENT (No such file or directory)
stat("/tmp/react.d.ts", 0x7ffd985dbb00) = -1 ENOENT (No such file or directory)
stat("/react.ts", 0x7ffd985dbb00)       = -1 ENOENT (No such file or directory)
stat("/react.d.ts", 0x7ffd985dbb00)     = -1 ENOENT (No such file or directory)
</code></pre></div>
<p dir="auto">i.e. in trying to resolve the non-relative <code class="notranslate">import</code> of <code class="notranslate">"react"</code>, every parent directory up to and including <code class="notranslate">/</code> is considered as a potential location for either <code class="notranslate">react.ts</code> or <code class="notranslate">react.d.ts</code>.</p>
<p dir="auto">We got bitten by this the other day because I happened to have a copy of <code class="notranslate">react.d.ts</code> kicking around in a parent directory (two directories higher) of our project. The compiler also picked up the intended version within our project, installed via <code class="notranslate">tsd</code> in a <code class="notranslate">typings</code> subdirectory. This threw a number of 'duplicate definition' errors (which in the circumstances, i.e. loading two copies of the same file, is expected behaviour).</p>
<p dir="auto">So the unexpected behaviour here was:</p>
<ul dir="auto">
<li>walking all the way to '/'</li>
<li>but also the non-relative import trying to load a file in the first place given the <code class="notranslate">"system"</code> module setting (but again I could be missing something here)</li>
</ul>
<p dir="auto">Please can someone confirm whether this is by design on both counts?</p>
<p dir="auto">React's setState(state) method accepts an object with only some of the total set of keys found in a component's state but to express that in Typescript the definition of the interface passed to React.Component[Props, State] has to be somewhat sacrificed by making all fields optional (?):</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface State { stateField1?: number; stateField2?: number; }
class MyComponent extends React.Component&lt;any, State&gt; {
... this.setState({ stateField1: 123 }); ...
}"><pre class="notranslate"><span class="pl-k">interface</span> <span class="pl-smi">State</span> <span class="pl-kos">{</span> <span class="pl-c1">stateField1</span>?: <span class="pl-smi">number</span><span class="pl-kos">;</span> <span class="pl-c1">stateField2</span>?: <span class="pl-smi">number</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-k">class</span> <span class="pl-smi">MyComponent</span> <span class="pl-k">extends</span> <span class="pl-smi">React</span><span class="pl-kos">.</span><span class="pl-c1">Component</span><span class="pl-c1">&lt;</span><span class="pl-s1">any</span><span class="pl-kos">,</span> <span class="pl-smi">State</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
... <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">setState</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">stateField1</span>: <span class="pl-c1">123</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span> ...
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Better IMO would be to have some way of specifying that the argument to setState is a 'fragment' of State.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Component&lt;Props, State&gt; {
  ...
  setState(update: fragmentof State);
}

interface State { stateField1: number; stateField2: number; }
var s: State = { stateField1: 123 }; // ts error
this.setState({ stateField1: 123 }); // ts ok"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">Component</span><span class="pl-c1">&lt;</span><span class="pl-smi">Props</span><span class="pl-kos">,</span> <span class="pl-smi">State</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
  ...
  <span class="pl-c1">setState</span><span class="pl-kos">(</span><span class="pl-s1">update</span>: <span class="pl-smi">fragmentof</span> <span class="pl-smi">State</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">State</span> <span class="pl-kos">{</span> <span class="pl-c1">stateField1</span>: <span class="pl-smi">number</span><span class="pl-kos">;</span> <span class="pl-c1">stateField2</span>: <span class="pl-smi">number</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-k">var</span> <span class="pl-s1">s</span>: <span class="pl-smi">State</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-c1">stateField1</span>: <span class="pl-c1">123</span> <span class="pl-kos">}</span><span class="pl-kos">;</span> <span class="pl-c">// ts error</span>
<span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">setState</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">stateField1</span>: <span class="pl-c1">123</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// ts ok</span></pre></div>