Open scottwillmoore opened 2 years ago
I also noticed that my forwardRefWithAs
function defines the return type with as
(which is required in this case).
export const forwardRefWithAs = <T extends As, P = {}>(
render: ForwardRefWithAsRenderFunction<T, P>
) => forwardRef(render) as ForwardRefExoticComponentWithAs<T, P>;
However, even with an explicit return type, it still does not work.
export const forwardRefWithAs = <T extends As, P = {}>(
render: ForwardRefWithAsRenderFunction<T, P>
): ForwardRefExoticComponentWithAs<T, P> =>
forwardRef(render) as ForwardRefExoticComponentWithAs<T, P>;
export function forwardRefWithAs<T extends As, P = {}>(
render: ForwardRefWithAsRenderFunction<T, P>
): ForwardRefExoticComponentWithAs<T, P> {
return forwardRef(render) as ForwardRefExoticComponentWithAs<T, P>;
}
I'm also experiencing this issue. Any updates on this?
I also noticed that my
forwardRefWithAs
function defines the return type withas
(which is required in this case).export const forwardRefWithAs = <T extends As, P = {}>( render: ForwardRefWithAsRenderFunction<T, P> ) => forwardRef(render) as ForwardRefExoticComponentWithAs<T, P>;
However, even with an explicit return type, it still does not work.
export const forwardRefWithAs = <T extends As, P = {}>( render: ForwardRefWithAsRenderFunction<T, P> ): ForwardRefExoticComponentWithAs<T, P> => forwardRef(render) as ForwardRefExoticComponentWithAs<T, P>;
export function forwardRefWithAs<T extends As, P = {}>( render: ForwardRefWithAsRenderFunction<T, P> ): ForwardRefExoticComponentWithAs<T, P> { return forwardRef(render) as ForwardRefExoticComponentWithAs<T, P>; }
Best workaround ever! Just always use
import * as Whatever from './whatever.ts'
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.
If this is still an issue, please share a minimal reproduction.
I don't use Parcel at the moment, and don't have the time to create a minimal reproduction, but I did provide a commit hash to a reproduction (non-minimal) in my original post.
Phew, this was quite some effort. Worth it if it gets fixed sometime though ;)
Here you go: parcel-d.ts-import-bug.zip
You will see the output file contains:
import { EUnavailabilityType } from "../../../../lib/api_schema/TrackV2Request";
export function send_product_unavailable_to_depict(unavailability_type: EUnavailabilityType): Promise<void>;
Which it shouldn't - parcel as bundler should make sure that everything that's not included from other packages (or even completely everything) should be bundled into the output .d.ts file
I am also experiencing this issue with imports popping up in the generated typings, and it is making typings borderline unusable in larger projects.
π bug report
I am building a TypeScript library for my UI components, which should include a TypeScript definition file in the output. The TypeScript definition file is generated, but for some reason some types are generated with
import("...")
in the type. You can see this in the example below.π Configuration (.babelrc, package.json, cli command)
See the linked repository.
π€ Expected Behavior
The TypeScript types do not include
import("...")
.π― Current Behavior
For example, you can see
export const Button: import("utilities/forwardRefWithAs").ForwardRefExoticComponentWithAs<"button", ButtonProps>;
, however it should beexport const Button: ForwardRefExoticComponentWithAs<"button", ButtonProps>;
(without the import statement).π Possible Solution
Edit: You can directly import the type, rather than it being implicitly imported alongside the function.
When the type is implicitly imported as below, it does not work.
When the type is directly imported (shouldn't be needed) as below, it does work.
π¦ Context
I am building a TypeScript library for my UI components, but the generated type definition file is incorrect. Therefore, when I reference these types from other packages in my repository, they appear as
any
.π» Code Sample
I don't have time at the moment to create a small reproducible example, but you should be able to reproduce the issue with my repository pinned at this commit: https://github.com/scottwillmoore/ece4094/tree/627089096657f91b768f7d65f024c84a4fee102e. At the moment, the repository is almost minimal anyway. You should be able to see the issue by by running
npm install
at the project root, and then runningnpm run build
at the project root, or in thepackages/ui
folder.π Your Environment
Please let me know if there is any addition information required.