<p dir="auto"><strong>I'm submitting a ...</strong>  (check one with "x")</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[x] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question"><pre class="notranslate"><code class="notranslate">[x] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
</code></pre></div>
<p dir="auto"><strong>Current behavior</strong></p>

<p dir="auto">The following would fail:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="export function getWindow() { return window; }

@NgModule({
  declarations: [
    AppComponent,
    SimpleRouteComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    AppRoutingModule
  ],
  providers: [
    {provide: 'window', useFactory: getWindow}
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(@Inject('window') w: Window) {
    console.log(w);
  }

}"><pre class="notranslate"><code class="notranslate">export function getWindow() { return window; }

@NgModule({
  declarations: [
    AppComponent,
    SimpleRouteComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    AppRoutingModule
  ],
  providers: [
    {provide: 'window', useFactory: getWindow}
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(@Inject('window') w: Window) {
    console.log(w);
  }

}
</code></pre></div>
<p dir="auto">With error</p>
<blockquote>
<p dir="auto">ERROR in Error encountered resolving symbol values statically. Could not resolve type Window (position 29:36 in the original .ts file), resolving symbol AppModule in /Users/Meligy/Code/github/Meligy/routing-angular-cli/src/app/app.module.ts</p>
</blockquote>
<p dir="auto"><strong>Expected behavior</strong></p>

<p dir="auto">I'd expect the AoT compiler to be able to understand</p>
<p dir="auto"><strong>Minimal reproduction of the problem with instructions</strong></p>

<ol dir="auto">
<li>Create a new app using latest Angular CLI</li>
<li>Go to <code class="notranslate">AppModule</code>, modify <code class="notranslate">providers</code> and add <code class="notranslate">constructor</code> as shown above</li>
<li>Run <code class="notranslate">npm start -- --aot</code></li>
</ol>
<p dir="auto"><strong>What is the motivation / use case for changing the behavior?</strong></p>

<p dir="auto">I want to be able to test the places where I happen to have to use <code class="notranslate">window</code>. I still want to have type safety for my calls to it.</p>
<p dir="auto"><strong>Please tell us about your environment:</strong></p>

<p dir="auto">Mac OS latest</p>
<p dir="auto">Running <code class="notranslate">npm run ng -- version</code> returns:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="angular-cli: 1.0.0-beta.26
node: 6.9.1
os: darwin x64
@angular/common: 2.4.4
@angular/compiler: 2.4.4
@angular/core: 2.4.4
@angular/forms: 2.4.4
@angular/http: 2.4.4
@angular/platform-browser: 2.4.4
@angular/platform-browser-dynamic: 2.4.4
@angular/router: 3.4.4
@angular/compiler-cli: 2.4.4"><pre class="notranslate"><code class="notranslate">angular-cli: 1.0.0-beta.26
node: 6.9.1
os: darwin x64
@angular/common: 2.4.4
@angular/compiler: 2.4.4
@angular/core: 2.4.4
@angular/forms: 2.4.4
@angular/http: 2.4.4
@angular/platform-browser: 2.4.4
@angular/platform-browser-dynamic: 2.4.4
@angular/router: 3.4.4
@angular/compiler-cli: 2.4.4
</code></pre></div>
<p dir="auto">Things to note:</p>
<ul dir="auto">
<li>The type <code class="notranslate">Window</code> is declared in default TypeScript lib <code class="notranslate">dom</code>.</li>
<li>The libs <code class="notranslate">["es6", "dom"]</code> are already added by default in my project (default Angular CLI layout)</li>
<li>I also tried to reference the file <code class="notranslate">node_modules/typescript/lib/lib.dom.d.ts</code> directly in several ways, and that didn't seem to help</li>
</ul>
<p dir="auto">Please note that the code WORKS JUST FINE when I'm not using AoT.</p>
<p dir="auto">That's <code class="notranslate">npm start</code> works, and <code class="notranslate">npm start -- --aot</code> fails (<code class="notranslate">npm start</code> here equals <code class="notranslate">ng serve</code>)</p>
<ul dir="auto">
<li><strong>Angular version:</strong> 2.0.X</li>
</ul>

<p dir="auto">Angular 2.4.4 as shown above.</p>
<ul dir="auto">
<li><strong>Browser:</strong> [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]</li>
</ul>

<p dir="auto">Tested in Chrome, but the error comes in Terminal anyway.</p>
<ul dir="auto">
<li><strong>Language:</strong> [all | TypeScript X.X | ES6/7 | ES5]</li>
</ul>
<p dir="auto">TypeScript 2.0.10</p>
<ul dir="auto">
<li><strong>Node (for AoT issues):</strong> <code class="notranslate">node --version</code> =<br>
node: 6.9.1</li>
</ul>
<p dir="auto">After few days of research I have realized that <a href="https://github.com/angular/di.js">di.js</a> repo is no longer maintained and <a href="https://github.com/angular/angular/tree/master/modules/di/src">dependency injection</a> from this repo is pretty away from previous code base.</p>
<p dir="auto">I guess you have a plan to separate it again or update old repo with new code? Will it happen any time soon?</p>
<p dir="auto">Thanks!</p>