typescript - Full Definition Of A "Common Root" -


enumerations, modules , interfaces merged if multiple blocks defined within same common root. can't find official definition of common root in language specification.

is more complicated than...

either:

  • the module, or
  • the global scope

(the complication can think of if module merged, members of parts of module being merged have same common root, zips go).

is there other kind of common root?

module x {     export interface y {         name: string;     } }  module x{     export interface y {         age: number;     } }  // x.y has both name , age properties 

it's "common root" in graph theory sense of term, since combination of typescript modules or programs forms tree of declarations (because declaration has 1 parent). second half of spec section 2.3 ("declarations") defines how tree constructed in terms of establishing parent relationships.

i think relevant phrase in spec here declarations merge if have "the same qualified name relative common root". simpler way define have been "same fully-qualified name", wouldn't have handled case declaration did not have name qualified global scope (e.g. unexported interface inside module).

the other complication when declarations exist in external module, top level of file external module rather global module:

export var x = 4;  /* not merge global 'window', because parent external module */ interface window { } 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -