Repository: TypeScript
Issue: More poor errors with value/type/namespace confusion
Labels: Bug,Help Wanted,Domain: Error Messages

<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨

Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section!

Please help us by doing the following steps before logging an issue:
  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues
  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ

Please fill in the *entire* template below.
-->

"Cannot find name" or "Namespace ... has no exported member", but I see it right there!  Some of the more common cases came up in two recent Stack Overflow questions: [1](https://stackoverflow.com/questions/52617485/typescript-constant-string-cannot-be-found), [2](https://stackoverflow.com/questions/52711753/cannot-get-func-from-proptypes).  Maybe we should just fix all the cases?

<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->
**TypeScript Version:**  master (f6ca10565d8fb0a9737b687b85e14ee94ad244d7)

<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**Search Terms:** value type namespace meaning error (and all the error messages below)

**Code**

```ts
const v = 42;
type t = number;
namespace n {}
const vt = 42;
type vt = number;
const vn = 42;
namespace vn {}
type tn = number;
namespace tn {}

namespace M { 
    export const v = 42;
    export type t = number;
    export namespace n {}
    export const vt = 42;
    export type vt = number;
    export const vn = 42;
    export namespace vn {}
    export type tn = number;
    export namespace tn {}    
}

// Actual is OK: 't' only refers to a type, but is being used as a value here.
const v1 = t;
// Actual: Property 't' does not exist on type 'typeof M'.
// Proposed: 't' only refers to a type, but is being used as a value here.
const v2 = M.t;
// Actual is OK: Cannot use namespace 'n' as a value.
const v3 = n;
// Actual: Property 'n' does not exist on type 'typeof M'.
// Proposed: Cannot use namespace 'n' as a value.
const v4 = M.n;
// Actual: Cannot use namespace 'tn' as a value.
// Proposed: 'tn' only refers to a type and a namespace, but is being used as a value here.
const v5 = tn;
// Actual: Property 'tn' does not exist on type 'typeof M'.
// Proposed: 'tn' only refers to a type and a namespace, but is being used as a value here.
const v6 = M.tn;

// Actual: Cannot find name 'v'.
// Proposed: 'v' only refers to a value, but is being used as a type here.
type t1 = v;
// Actual: Namespace 'M' has no exported member 'v'.
// Proposed: 'v' only refers to a value, but is being used as a type here.
type t2 = M.v;
// Actual is OK: Cannot use namespace 'n' as a type.
type t3 = n;
// Actual: Namespace 'M' has no exported member 'n'.
// Proposed: Cannot use namespace 'n' as a type.
type t4 = M.n;
// Actual: Cannot use namespace 'vn' as a type.
// Proposed: 'vn' only refers to a value and a namespace, but is being used as a type here.
type t5 = vn;
// Actual: Namespace 'M' has no exported member 'vn'.
// Proposed: 'vn' only refers to a value and a namespace, but is being used as a type here.
type t6 = M.vn;

// Actual: Cannot find namespace 'v'.
// Proposed: 'v' only refers to a value, but is being used as a namespace here.
type nt1 = v.oops;
// Actual: Namespace 'M' has no exported member 'v'.
// Proposed: 'v' only refers to a value, but is being used as a namespace here.
type nt2 = M.v.oops;
// Actual is OK: 't' only refers to a type, but is being used as a namespace here.
type nt3 = t.oops;
// Actual: Namespace 'M' has no exported member 't'.
// Proposed: 't' only refers to a type, but is being used as a namespace here.
type nt4 = M.t.oops;
// Actual: 'vt' only refers to a type, but is being used as a namespace here.
// Proposed: 'vt' only refers to a value and a type, but is being used as a namespace here.
type nt5 = vt.oops;
// Actual: Namespace 'M' has no exported member 'vt'.
// Proposed: 'vt' only refers to a value and a type, but is being used as a namespace here.
type nt6 = M.vt.oops;
```

**Expected behavior:** As indicated above

**Actual behavior:** As indicated above

**Playground Link:** [link](https://www.typescriptlang.org/play/#src=const%20v%20%3D%2042%3B%0D%0Atype%20t%20%3D%20number%3B%0D%0Anamespace%20n%20%7B%7D%0D%0Aconst%20vt%20%3D%2042%3B%0D%0Atype%20vt%20%3D%20number%3B%0D%0Aconst%20vn%20%3D%2042%3B%0D%0Anamespace%20vn%20%7B%7D%0D%0Atype%20tn%20%3D%20number%3B%0D%0Anamespace%20tn%20%7B%7D%0D%0A%0D%0Anamespace%20M%20%7B%20%0D%0A%20%20%20%20export%20const%20v%20%3D%2042%3B%0D%0A%20%20%20%20export%20type%20t%20%3D%20number%3B%0D%0A%20%20%20%20export%20namespace%20n%20%7B%7D%0D%0A%20%20%20%20export%20const%20vt%20%3D%2042%3B%0D%0A%20%20%20%20export%20type%20vt%20%3D%20number%3B%0D%0A%20%20%20%20export%20const%20vn%20%3D%2042%3B%0D%0A%20%20%20%20export%20namespace%20vn%20%7B%7D%0D%0A%20%20%20%20export%20type%20tn%20%3D%20number%3B%0D%0A%20%20%20%20export%20namespace%20tn%20%7B%7D%20%20%20%20%0D%0A%7D%0D%0A%0D%0A%2F%2F%20Actual%20is%20OK%3A%20't'%20only%20refers%20to%20a%20type%2C%20but%20is%20being%20used%20as%20a%20value%20here.%0D%0Aconst%20v1%20%3D%20t%3B%0D%0A%2F%2F%20Actual%3A%20Property%20't'%20does%20not%20exist%20on%20type%20'typeof%20M'.%0D%0A%2F%2F%20Proposed%3A%20't'%20only%20refers%20to%20a%20type%2C%20but%20is%20being%20used%20as%20a%20value%20here.%0D%0Aconst%20v2%20%3D%20M.t%3B%0D%0A%2F%2F%20Actual%20is%20OK%3A%20Cannot%20use%20namespace%20'n'%20as%20a%20value.%0D%0Aconst%20v3%20%3D%20n%3B%0D%0A%2F%2F%20Actual%3A%20Property%20'n'%20does%20not%20exist%20on%20type%20'typeof%20M'.%0D%0A%2F%2F%20Proposed%3A%20Cannot%20use%20namespace%20'n'%20as%20a%20value.%0D%0Aconst%20v4%20%3D%20M.n%3B%0D%0A%2F%2F%20Actual%3A%20Cannot%20use%20namespace%20'tn'%20as%20a%20value.%0D%0A%2F%2F%20Proposed%3A%20'tn'%20only%20refers%20to%20a%20type%20and%20a%20namespace%2C%20but%20is%20being%20used%20as%20a%20value%20here.%0D%0Aconst%20v5%20%3D%20tn%3B%0D%0A%2F%2F%20Actual%3A%20Property%20'tn'%20does%20not%20exist%20on%20type%20'typeof%20M'.%0D%0A%2F%2F%20Proposed%3A%20'tn'%20only%20refers%20to%20a%20type%20and%20a%20namespace%2C%20but%20is%20being%20used%20as%20a%20value%20here.%0D%0Aconst%20v6%20%3D%20M.tn%3B%0D%0A%0D%0A%2F%2F%20Actual%3A%20Cannot%20find%20name%20'v'.%0D%0A%2F%2F%20Proposed%3A%20'v'%20only%20refers%20to%20a%20value%2C%20but%20is%20being%20used%20as%20a%20type%20here.%0D%0Atype%20t1%20%3D%20v%3B%0D%0A%2F%2F%20Actual%3A%20Namespace%20'M'%20has%20no%20exported%20member%20'v'.%0D%0A%2F%2F%20Proposed%3A%20'v'%20only%20refers%20to%20a%20value%2C%20but%20is%20being%20used%20as%20a%20type%20here.%0D%0Atype%20t2%20%3D%20M.v%3B%0D%0A%2F%2F%20Actual%20is%20OK%3A%20Cannot%20use%20namespace%20'n'%20as%20a%20type.%0D%0Atype%20t3%20%3D%20n%3B%0D%0A%2F%2F%20Actual%3A%20Namespace%20'M'%20has%20no%20exported%20member%20'n'.%0D%0A%2F%2F%20Proposed%3A%20Cannot%20use%20namespace%20'n'%20as%20a%20type.%0D%0Atype%20t4%20%3D%20M.n%3B%0D%0A%2F%2F%20Actual%3A%20Cannot%20use%20namespace%20'vn'%20as%20a%20type.%0D%0A%2F%2F%20Proposed%3A%20'vn'%20only%20refers%20to%20a%20value%20and%20a%20namespace%2C%20but%20is%20being%20used%20as%20a%20type%20here.%0D%0Atype%20t5%20%3D%20vn%3B%0D%0A%2F%2F%20Actual%3A%20Namespace%20'M'%20has%20no%20exported%20member%20'vn'.%0D%0A%2F%2F%20Proposed%3A%20'vn'%20only%20refers%20to%20a%20value%20and%20a%20namespace%2C%20but%20is%20being%20used%20as%20a%20type%20here.%0D%0Atype%20t6%20%3D%20M.vn%3B%0D%0A%0D%0A%2F%2F%20Actual%3A%20Cannot%20find%20namespace%20'v'.%0D%0A%2F%2F%20Proposed%3A%20'v'%20only%20refers%20to%20a%20value%2C%20but%20is%20being%20used%20as%20a%20namespace%20here.%0D%0Atype%20nt1%20%3D%20v.oops%3B%0D%0A%2F%2F%20Actual%3A%20Namespace%20'M'%20has%20no%20exported%20member%20'v'.%0D%0A%2F%2F%20Proposed%3A%20'v'%20only%20refers%20to%20a%20value%2C%20but%20is%20being%20used%20as%20a%20namespace%20here.%0D%0Atype%20nt2%20%3D%20M.v.oops%3B%0D%0A%2F%2F%20Actual%20is%20OK%3A%20't'%20only%20refers%20to%20a%20type%2C%20but%20is%20being%20used%20as%20a%20namespace%20here.%0D%0Atype%20nt3%20%3D%20t.oops%3B%0D%0A%2F%2F%20Actual%3A%20Namespace%20'M'%20has%20no%20exported%20member%20't'.%0D%0A%2F%2F%20Proposed%3A%20't'%20only%20refers%20to%20a%20type%2C%20but%20is%20being%20used%20as%20a%20namespace%20here.%0D%0Atype%20nt4%20%3D%20M.t.oops%3B%0D%0A%2F%2F%20Actual%3A%20'vt'%20only%20refers%20to%20a%20type%2C%20but%20is%20being%20used%20as%20a%20namespace%20here.%0D%0A%2F%2F%20Proposed%3A%20'vt'%20only%20refers%20to%20a%20value%20and%20a%20type%2C%20but%20is%20being%20used%20as%20a%20namespace%20here.%0D%0Atype%20nt5%20%3D%20vt.oops%3B%0D%0A%2F%2F%20Actual%3A%20Namespace%20'M'%20has%20no%20exported%20member%20'vt'.%0D%0A%2F%2F%20Proposed%3A%20'vt'%20only%20refers%20to%20a%20value%20and%20a%20type%2C%20but%20is%20being%20used%20as%20a%20namespace%20here.%0D%0Atype%20nt6%20%3D%20M.vt.oops%3B)

**Related Issues:** #7900