Skip to content

Dependency tracking system uses declared names for imported types/guards/classes #218

@download13

Description

@download13

So I was working on #166, which took me down a rabbithole with #162, of which one of the test cases revealed a deeper problem that isn't only restricted to class imports, but any situation where imports are renamed to avoid identifier conflicts.

For example:

import { Timestamp } from './timestamp'
import { Timestamp as TS } from 'other-library/timestamp'

export type TimeThing = {
  ts1: Timestamp
  ts2: TS
}

results in a guard that contains duplicate identifiers or references non-existent identifiers.

This isn't restricted to duplicate import names. The same problem occurs any time imported bindings are renamed:

import * as AnyNameWeWant from './name'`
import SomeOtherWildName from './name'
import { Name as Name2 } from './name'

Including any of these lines will break dependency tracking, and therefor guard generation.

I think the solution to this is to have the code generation and dependency tracking use the imported identifier rather than the declared and exported name. I'm currently working on a solution, but opening an issue first to explain the changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions