-
-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Background
I'm building a React Component Library, and some components are nested, eg. <Form.Button />
& <Form.Input />
, but it also has a root element, named <Form />
.
Issue
If you take a look at the example repository (provided down below), especially the ./dist/components/form/form.d.ts
file. You'll see that it exports a const
named Form
which is of type FunctionComponent
, but it also have to other properties, Button
& Input
.
The Button
property is fine, but the Input
property isn't correct since it still imports the Input component from the following path: ~/components/form/input
.
The source code for Form.tsx
looks like the following
import { Button } from '~/components/form/button'
import { Input } from '~/components/form/input'
import { FunctionComponent } from 'react'
const FormRoot: FunctionComponent = () => (
<div>MenuRoot</div>
)
export const Form = Object.assign(FormRoot, {
Button,
Input
})
Actual output of form.d.ts
import { FunctionComponent } from 'react';
export declare const Form: FunctionComponent<{}> & {
Button: FunctionComponent<{}>;
Input: import("react").ForwardRefExoticComponent<import("~/components/form/input").InputProps & import("react").RefAttributes<HTMLInputElement>>;
};
Expected output of form.d.ts
import { FunctionComponent } from 'react';
export declare const Form: FunctionComponent<{}> & {
Button: FunctionComponent<{}>;
Input: import("react").ForwardRefExoticComponent<import("../../components/form/input").InputProps & import("react").RefAttributes<HTMLInputElement>>;
};
Example Repository
https://github.com/RobinBertilsson/ts-transform-paths-nested-issue
All help appreciated ❤️
Maintainers Note
This is likely because the child nodes are not visited with the transformer