TypeScript Error: Cannot find namespace 'google'

typescript namespace
cannot use namespace as a type angular
cannot find namespace angular
typescript extend namespace
typescript namespace deprecated
typescript namespace alias
typescript nested namespaces
cannot find namespace 'google

I have project angular-cli

~root~/src/typings.json

{
  "globalDevDependencies": {
    "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654"
  },
  "globalDependencies": {
    "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
    "google.maps": "registry:dt/google.maps#3.20.0+20160914131659"
  }
}

~root~/typings/index.d.ts

/// <reference path="globals/angular-protractor/index.d.ts" />
/// <reference path="globals/es6-shim/index.d.ts" />
/// <reference path="globals/google.maps/index.d.ts" />
/// <reference path="globals/hammerjs/index.d.ts" />
/// <reference path="globals/jasmine/index.d.ts" />
/// <reference path="globals/selenium-webdriver/index.d.ts" />

~root~/src/tsconfig.json

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types",
      "../typings"
    ],
    "files": [
      "../typings/index.d.ts"
    ]
  }
}

After run ng serve I have error message in console

ERROR in [default] F:~root~\src\app\ui\google-map\map-marker\map-marker.directive.ts:7:26

Cannot find namespace 'google'

and

ERROR in [default] ~root~\src\app\trip-entry-page\trip-entry-page.component.ts:188:21

Cannot find name 'google'

~root~\src\app\ui\google-map\map-marker\map-marker.directive.ts:7:26

... 
@Input() veyoMapMarker: google.maps.MarkerOptions 
...

~root~\src\app\trip-entry-page\trip-entry-page.component.ts:188:21

... 
if (status === google.maps.DirectionsStatus.OK) { 
...

After build app correct working

How me resolve this Error messages?


A bit of a late response but I had a similar issue using Angular CLI RC.0.

It turned out that I hadn't install and imported the typings, which can be done as follows:

npm install --save-dev @types/googlemaps

import {} from '@types/googlemaps';

Typescript: Cannot find namespace, Cannot find namespace 'express'. If I switch the 'require' to 'import' it fixes the namespace error but is no longer valid Node code so doesn'  Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.


Try to run the below command in a node prompt...

typings install dt~google.maps --global --save

Typescript does not work, cannot find namespace 'Phaser'. · Issue , An error in the TypeScript definitions Be nice. We do this for free. Sure ;) I cannot make typescript recognise Phaser types, still getting error  luckylooke changed the title Typescript does not work, maybe due to duplicate identifier in definition files? Typescript does not work, cannot find namespace 'Phaser'. Jul 17, 2018


I was facing same problem and what I did was, I just removed these

import { } from 'googlemaps';
declare var google: any;

from my component.ts and add "types": [ "googlemaps" ] in my tsconfig.app.json . . Now my tsconfig.app.json looks like this.

{
    "extends": "../tsconfig.json",
    "compilerOptions": {
        "outDir": "../out-tsc/app",
        "module": "es2015",
        "types": [
            "googlemaps"
          ]
    },
    "exclude": [
        "test.ts",
        "**/*.spec.ts"
    ]
}

And its working perfectly.

TS2503: Cannot find namespace 'moment' · Issue #12634 · microsoft , TypeScript Version: 2.0.10 I am not sure if it is a moment problem or a typescript behavior/bug. I'm just trying to use moment within a d.ts file. In this file Visual Studio Code is complaining about the ng.IDirective type that it "Cannot find namespace 'ng'" and it is complaining about the moment.MomentStatic type that it "Cannot find namespace 'moment'". edit: Explicitely referencing the type definition files by adding the following to the top of navbar.directive.ts removes the problem:


I had the same problem with angular 7. I did not need to import anything just run npm install @types/googlemaps again and if there is any vulnerabilities, run npm audit fix or npm audit fix --force if needed.

After I did so, everything worked fine for me...

Ambient Namespaces, Namespaces. Table of contents #. Introduction. First steps. Validators in a single file. Namespacing. Namespaced Validators. Splitting Across Files. Multi-file  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Typescript cannot find name even though it is referenced


In IONIC 4 I fixed it by installing @types/google-maps not @types/googlemaps

just run this

npm install @types/google-maps --save

and import google in your component using

import { google } from "google-maps";

Namespaces and Modules · TypeScript, See the Namespaces documentation for more information about TypeScript If a specific file could not be found, then the compiler will look for an ambient  The premise that you shouldn't need or want namespaces for external modules is a faulty one. While the file system is a sort of organization scheme you can kinda use for these purposes, it isn't nearly as nice for the consumer to have n import statements for using n classes or functions from a given project; especially since it also muddies the


TypeScript cannot find namespace – Onooks, I am trying to create a web game using webGL, TypeScript and node. when I run npm start , I get that src/index.ts:5:22 - error TS2304: Cannot find name '​EngineSpace'. . I am not sure why it cannot resolve this namespace. TypeScript Version: 2.0.10 I am not sure if it is a moment problem or a typescript behavior/bug. I'm just trying to use moment within a d.ts file. Moment ships with a d.ts file and everything works as soon as I import something from ther


Namespace Imports in TypeScript, I've written about TypeScript imports on my blog before, but as I recently Since there doesn't seem to be an official NPM package available, I referenced the script in my index.html directly: Cannot find name 'google'. Yes, you cannot avoid that, it is what typescript emits after compiling. We usually strip those out using some sed script / patch / whatever. Which then moves the responsibility of providing react.d.ts to the consumers of the lib you might be building.


T3086, 24 in our project. Now we have a problem with build. It seems that this problem come from typescript. The compiler cannot find namespace 'ko'. I  TS2307: Cannot find module './file-a.js' or its corresponding type declarations. When the import statement is moved outside of the namespace, all errors disappear (makes sense from a JS point of view). Beside this highlighted errors, only seen when opening the generated declaration files.