[Bug] ImportType node children do not transform
See original GitHub issueBackground
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
Issue Analytics
- State:
- Created 2 years ago
- Comments:5

Top Related StackOverflow Question
Fixed in v3.4.1!
Thanks for catching this one!
I’m also seeing this problem in some of my compiled
.dfileshttps://github.com/EvanPurkhiser/prolink-connect/blob/0166963896bbfbd9fa22581ac0d4cdc9b5f61204/src/remotedb/message/response.ts#L194
Here
fieldsToItemis imported fromitem. It seems to struggle because it’s passing in a template argument here https://github.com/EvanPurkhiser/prolink-connect/blob/0166963896bbfbd9fa22581ac0d4cdc9b5f61204/src/remotedb/message/item.ts#L211-L213