Open lenowng opened 5 years ago
The above example could likely be handled by just naming the manufacturer type differently between the files. Here's a simpler and more broken example that will result in the same error, even for a single Manufacturer
type.
Haven't really found a workaround for this
// common.ts
export interface Manufacturer {
name: string;
country: string;
..
}
// engine.ts
export interface Engine {
manufacturer: Manufacturer;
engine: Engine;
}
// engine.ts
export interface Engine {
name: String
manufacturer: Manufacturer;
}
Any updates on this?
FWIW my workaround ended up being something like this:
// validators.ts
const checkers = createCheckers(
// EVERYTHING goes here
fooSpecs,
barSpecs
commonSpecs
)
export default checkers
// foo.ts
import validator from 'utils/validator'
const FooValidator = validator.Foo
Essentially doing createCheckers once with everything, rather than making separate ones, which avoided multiple repeated definitions of the same thing. This doesn't fully solve the problem but it was sufficient for my use case
@fastfrwrd, since you added the --inline-imports
option, do you have any suggestions here?
TS source:
Car-type.ts
Bike-type.ts
Vehicle-type.ts
Above scenario is sketched out to brings out the idea of the possible problem. Building interface type from
Vehicle-type.ts
with--inline-imports
will lead to having duplicated variable named Manufacturer being generated in the same type file because import alias was not respected.Suggestion: Use the import alias a prefix to generated variable name.