johngeorgewright / runtyping

Generate runtype validation from static types & JSON schema.
MIT License
43 stars 5 forks source link

Import resolution issue on entire module importing #438

Open Meterius opened 1 year ago

Meterius commented 1 year ago

Imports using entire module imports (using import * as ...) cause runtyping to import the types from the file that contains the import and not the file that is exporting.

Example:

common.ts

export enum Status { 
  Paused,
  Running
}

test.ts

import * as common from "./common";

export interface ExampleA {
  status: common.Status;
}

If runtypes are generated for ExampleA in test.ts, the generated file will attempt to import Status from test.ts instead of common.ts. If we instead imported Status directly from common.ts it would correctly import Status from common.ts.