Skip to content

semantic: TSQualifiedName incorrectly refernces generic argument when name is shadowed #17928

@camc314

Description

@camc314

Given the below code:

namespace Database {
  export type Table<T> = T;
}

// 'Database' generic shadows the namespace, but namespace is used in 'Database.Table'
export function test<Database, Table extends Database.Table<Database>>(
  database: Database,
  table: Table
): { database: Database; table: Table } {
  return { database, table };
}

the top level Database symbol has no references, this is incorrect as it is refernced in the extends Database.Table

Database (id: 0): {
  symbol_id: 0
  span: { start: 10, end: 18 }
  name: "Database"
  flags: ValueModule
  scope_id: 0
  references: []
}

In typescript the left side of Database.Table is resolved with SymbolFlags.Namespace

https://github.com/microsoft/typescript/blob/c574e4090d9f428f841d8098aebc302b0187182e/src/compiler/checker.ts#L4529

When TS uses SymbolFlags.Namespace, it understands that type parameters have SymbolFlags.TypeParameter, and automatically excludes them when resolving the left side of a qualified name.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions