Menu

Catch Invented React Imports with a Small TypeScript Check
📰

Catch Invented React Imports with a Small TypeScript Check

DEV Community: typescript·Cihan Koç·11 days ago
#V2QVVkKW
#devtotypescript#devto#dev#react#import
Reading 0:00
15s threshold

AI disclosure: OpenAI Codex drafted this tutorial. The examples below were checked by executing TypeScript against the listed installed packages. I maintain Ninna UI; this version uses standard React APIs. The example is a controlled reproduction, not a personal debugging story or a measurement of any agent's error rate.

Cover created with AI-assisted vector code. It maps createPortal to react-dom and useState and Fragment to react.

A generated React feature can contain a familiar API name and still import it from the wrong package. A short TypeScript fixture turns that plausible import into something you can check before accepting the feature.

The useful technique is to check a few dependency boundaries and prove that the check fails for a known wrong import. A passing command alone is weaker evidence if the fixture was never included in the compilation.

Start with a real export boundary

React's documentation imports createPortal from react-dom .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.