Description
TypeScript Version: 3.4.0-dev.20190206
Search Terms: "cannot find name" type error
Code
If you use a type as a value you get a nice error message:
type t = number;
let x = t;
// error TS2693: 't' only refers to a type, but is being used as a value here.
But if you do the same thing in reverse, you get a really confusing one:
let t = 3;
let x: t;
// error TS2304: Cannot find name 't'.
Expected behavior:
Error message should say something more like the type one.
Actual behavior:
Error message suggests there is no 't' in scope at all, which is very confusing especially when you have imported t from some other file and you thought it was a type.
Playground Link:
Related Issues:
There are some around this same problem with namespaces I think, like
#26391 or #12075
I think this issue is more broadly complaining about issues in this area:
#27630
But the issue I'm filing here is very specific and concrete, with an easy repro.
This issue discusses some suggested fixes for this issue, but I think first we need to fix the error message.
#28975