-
Notifications
You must be signed in to change notification settings - Fork 53
Description
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.