TypeScript Version: ^2.9.2 (also tested with @next with no difference)
Search Terms:
duplicated type, implicit return, type definition file
Code
// component-a/component-a.tsx
export type ComponentAPosition = 'top' | 'bottom' | 'left' | 'right';
export class ComponentA {
doAThing(value: ComponentAPosition) {}
}
// component-b/component-b.tsx
export type ComponentBPosition = 'top' | 'right' | 'bottom' | 'left';
export class ComponentB {
doSomething(values: ComponentBPosition) {
return values;
}
}
Expected behavior:
// component-b.d.ts
export declare type ComponentBPosition = 'top' | 'right' | 'bottom' | 'left';
export declare class ComponentB {
doSomething(values: ComponentBPosition): ComponentBPosition;
}
Actual behavior:
// component-b.d.ts
export declare type ComponentBPosition = 'top' | 'right' | 'bottom' | 'left';
export declare class ComponentB {
doSomething(values: ComponentBPosition): import("../component-a/component-a").ComponentAPosition;
}
Playground Link: Not a playground, but a repo (run npm i && tsc, although the output is in the repo anyway under the build/ directory): https://github.com/lorem--ipsum/tsc-test
Related Issues: -
Thoughts:
The file that gets its type definition is component-b.tsx. It needs to be compiled after component)-a.tsx (I assume the order is alphabetical). The bug does happen when running tsc --watch, but only on the first run, not when component-b.tsx is changed. The returned type is correct when stated explicitly in the source file. It doesn't occur either when the two types (ComponentAPosition and ComponentBPosition aren't strictly similar).
TypeScript Version: ^2.9.2 (also tested with @next with no difference)
Search Terms:
duplicated type, implicit return, type definition file
Code
Expected behavior:
Actual behavior:
Playground Link: Not a playground, but a repo (run
npm i && tsc, although the output is in the repo anyway under thebuild/directory): https://github.com/lorem--ipsum/tsc-testRelated Issues: -
Thoughts:
The file that gets its type definition is
component-b.tsx. It needs to be compiled aftercomponent)-a.tsx(I assume the order is alphabetical). The bug does happen when runningtsc --watch, but only on the first run, not whencomponent-b.tsxis changed. The returned type is correct when stated explicitly in the source file. It doesn't occur either when the two types (ComponentAPositionandComponentBPositionaren't strictly similar).