samuelgoto/proposal-optional-types

Are types available in a flat namespace?

samuelgoto opened this issue · 1 comments

(porting @Waldemar's comments into github issues)

@Waldemar: on scoping, are types available in a flat namespace? For example:

function a() { 
  class B { foo() { console.log("bar"); } }; 
  var b = new B(); 
  b.foo();
}

class B {    
}

var c:B = new B();
// NOTE(waldemar): which B does c refer to from a type-checking perspective?
// NOTE(goto, dimvar): types follows the interpreter scoping rules. For example, 
// the typechecker complains on the following line that "property foo()" does not
// exist on type "B".
c.foo(); // Error

Modules?

@Waldemar: namespaces, scoping for identifiers versus types.