Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes TS annotation issue #366

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

Akkuma
Copy link
Contributor

@Akkuma Akkuma commented Jun 24, 2024

This fixes The inferred type of 'ResizableHandle' cannot be named without a reference to 'react-resizable-panels/dist/declarations/src/PanelResizeHandleRegistry'. This is likely not portable. A type annotation is necessary.

I've exported out types not currently exported from index.ts. This resolves the issue that there were internal types not exported resolving annotation issues for PanelResizeHandle. I created a build to verify this as well https://www.npmjs.com/package/@akkuma/react-resizable-panels.

Copy link

vercel bot commented Jun 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-resizable-panels ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2024 2:47pm

@Akkuma Akkuma changed the title Fixes TS annotation issue (The inferred type of 'ResizableHandle' cannot be named without a reference to 'react-resizable-panels/dist/declarations/src/PanelResizeHandleRegistry'. This is likely not portable. A type annotation is necessary.) Fixes TS annotation issue Jun 24, 2024
@bvaughn
Copy link
Owner

bvaughn commented Jun 24, 2024

This fixes The inferred type of 'ResizableHandle' cannot be named without a reference to 'react-resizable-panels/dist/declarations/src/PanelResizeHandleRegistry'. This is likely not portable. A type annotation is necessary.

Where does this error come from?

The types you've added exports for don't seem like types that should be exported.

@Akkuma
Copy link
Contributor Author

Akkuma commented Jun 24, 2024

This fixes The inferred type of 'ResizableHandle' cannot be named without a reference to 'react-resizable-panels/dist/declarations/src/PanelResizeHandleRegistry'. This is likely not portable. A type annotation is necessary.

Where does this error come from?

This error is in an internal package that I built at my company that uses shadcn, which uses this package (https://ui.shadcn.com/docs/components/resizable). Our internal package uses vite to bundle up our customized version:

	publicDir: './src/css',
	build: {
		lib: {
			entry: Object.fromEntries(entries),
			formats: ['es'],
			fileName: '[name]',
		},
		rollupOptions: {
			external: ['react', 'react-dom', 'react/jsx-runtime', 'tailwindcss', 'tailwindcss-animate'],
		},
		target: 'esnext',
		sourcemap: true,
		emptyOutDir: true,
	},
	plugins: [
		muteWarningsPlugin(warningsToIgnore),
		react(),
		dts({ bundledPackages: ['class-variance-authority'], tsconfigPath: './tsconfig.build.json' }),
	],
});

dts is vite-plugin-dts and is likely raising this error preventing the generation of a .d.ts as some of the exports I added were private. So you could say that the source of this is taking this package -> packaging it up in our package. If we had no intermediary package I'd expect no issues in consuming this all directly.

The types you've added exports for don't seem like types that should be exported.

I thought it made sense to just expose all of the types at the same time, but I could pair this back too.

@bvaughn
Copy link
Owner

bvaughn commented Jun 24, 2024

Thanks for the extra context. that's helpful.

What would be the minimal set of types needing to be exported to fix the error you are referencing?

@Akkuma
Copy link
Contributor Author

Akkuma commented Jun 24, 2024

Thanks for the extra context. that's helpful.

What would be the minimal set of types needing to be exported to fix the error you are referencing?

I quickly checked and that would be:

import type { PointerHitAreaMargins } from "./PanelResizeHandleRegistry.js";
export { PointerHitAreaMargins }

I believe the reason for this is that PointerHitAreaMargins is part of the prop for PanelResizeHandle and being not exported makes it "not portable" in the extra hop downstream.

@bvaughn
Copy link
Owner

bvaughn commented Jun 24, 2024

Interesting. Okay.

Can you update this PR to just make the minimal change?

Copy link
Owner

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@bvaughn
Copy link
Owner

bvaughn commented Jun 25, 2024

CI is complaining about formatting. Mind running pnpm run prettier

@Akkuma
Copy link
Contributor Author

Akkuma commented Jun 25, 2024

CI is complaining about formatting. Mind running pnpm run prettier

Got it 👍

@bvaughn bvaughn merged commit 705d4cd into bvaughn:main Jun 25, 2024
7 checks passed
@bvaughn
Copy link
Owner

bvaughn commented Jul 2, 2024

Version 2.0.20 just deployed with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants