Skip to content

Conversation

@amirabbas-gh
Copy link
Collaborator

📚 Description

This PR introduces the following updates:

  1. Fix Issue with Import Detection (e.g., import * as React from 'react'):
    This update resolves an issue where imports like import * as React from 'react' were not being detected correctly by the codemod. This fix ensures that the codemod properly identifies and transforms such import statements, which is especially useful in projects using modern React patterns.

  2. Support for TypeScript Structures:
    Added support for handling TypeScript-specific constructs such as interfaces, enums, and type imports. This allows the codemod to seamlessly process TypeScript code and apply necessary transformations, enhancing the migration and refactoring process for TypeScript projects.

  3. Fix MouseEvent Handling:
    A fix for an issue where MouseEvent was not being handled properly during transformations. This bug was causing certain UI-related codemods to fail or behave incorrectly. With this fix, MouseEvent handling is now accurate, improving the reliability of transformations that involve DOM events.

🔗 Linked Issue

Fixes #325 - [update-react-imports] skips files that contain type imports

🧪 Test Plan

  1. Added test for testing for import patterns like import * as React from 'react'
  2. Added tests for TypeScript structure parsing and transformations.
  3. Manually tested MouseEvent handling with a sample codemod.
  4. Verified existing tests to ensure no regressions were introduced.

📄 Documentation to Update

  • Updated the handling of import statements, particularly the import * as React from 'react' pattern in src/index.ts.
  • Updated to reflect the new support for TypeScript structures, including handling type imports and specific constructs like interfaces and enums in src/index.ts.
  • Explained the fix for MouseEvent handling, describing common scenarios where this fix applies and how it improves transformation reliability in src/index.ts.
  • Created tests in src/test.ts and __testfixtures__.

…rt for TypeScript structures, and fix MouseEvent handling in the codemod
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.

[update-react-imports] skips files that contain type imports

3 participants