I'm new with angular universal and used this as a starter.
The problem is when I import a global typings like this: npm install -S @types/google-maps and use it as an input decorator:
@Input() f : google.maps.Map;
I get the error
ReferenceError: google is not defined
at Object.c (C:\work\tests\cli-universal-demo\dist\server.js:2601:31)
at __webpack_require__ (C:\work\tests\cli-universal-demo\dist\server.js:20:30)
at Object.c (C:\work\tests\cli-universal-demo\dist\server.js:3461:23)
at __webpack_require__ (C:\work\tests\cli-universal-demo\dist\server.js:20:30)
at Object.c (C:\work\tests\cli-universal-demo\dist\server.js:7441:20)
at __webpack_require__ (C:\work\tests\cli-universal-demo\dist\server.js:20:30)
at Object.<anonymous> (C:\work\tests\cli-universal-demo\dist\server.js:3550:10)
at __webpack_require__ (C:\work\tests\cli-universal-demo\dist\server.js:20:30)
at Object.<anonymous> (C:\work\tests\cli-universal-demo\dist\server.js:7566:37)
at Object.<anonymous> (C:\work\tests\cli-universal-demo\dist\server.js:7589:30)
The transpiled code section of the server.js file looks like this
__decorate([
core_1.Input(),
__metadata("design:type", google.maps.Map) //this is the error line
], AppComponent.prototype, "f", void 0);
AppComponent = __decorate([
core_1.Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
], AppComponent);
exports.AppComponent = AppComponent;
Note that only using as input decorator (for now at least) gives the error. Using as input to functions or inside functions doesn't give any errors.
Also note that google maps is included directly into the index.html as an external script rather than installed as a package which is likely the cause.