dnd-kit icon indicating copy to clipboard operation
dnd-kit copied to clipboard

Generated types are broken

Open TrySound opened this issue 2 years ago • 4 comments

Looks like too old typescript version or old react types generates types incompatible with modern react.

Here NamedExoticComponent produces any with noLibCheck

https://unpkg.com/browse/@dnd-kit/[email protected]/dist/components/DndContext/DndContext.d.ts

I use [email protected] and @types/[email protected]

TrySound avatar Nov 23 '21 19:11 TrySound

Alright, I see NamedExoticComponent in latest react types. But it doesn't work because of default import import React from 'react';

Not recommended by react team anymore. Better use import * as React from 'react';.

TrySound avatar Nov 23 '21 20:11 TrySound

Another negative point of default react import is not manglable React.createElement(). Namespace import would be expanded by rollup (tsdx) into import { createElement } from 'react' and each call could be minified.

TrySound avatar Nov 23 '21 20:11 TrySound

Oh, I got it now. esModuleInterop is required. Thought it doesn't affect types. But anyway named exports rock.

TrySound avatar Nov 26 '21 17:11 TrySound

Hey @TrySound, thanks for the detailed report 👍 I'm planning to update the development and build tooling of this project in the coming months, will tackle this issue at the same time when I start working on this.

From the sounds of it, this isn't a blocker for you at the moment since there is a workaround.

clauderic avatar Jan 07 '22 03:01 clauderic