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

fix: import fails when folder name overlaps with file name #1000

Merged

Conversation

lukealvoeiro
Copy link
Collaborator

@lukealvoeiro lukealvoeiro commented Feb 14, 2024

Description

This PR shows the error that occurs when the a proto file imports a file named the same thing as its containing folder.

Example of the old codegen behavior

Example:

<root>/
├─ ui/
│  ├─ simple.proto (imports ui.proto)
├─ ui.proto

This results in generated Typescript such as:

import {
  Simple as Simple2,
  SimpleEnum as SimpleEnum1,
  simpleEnumFromJSON as simpleEnumFromJSON3,
  simpleEnumToJSON as simpleEnumToJSON4,
} from "./";

This is not valid Typescript.

If you use the fileSuffix or importSuffix options, this issue disappears.

Fix

This PR in ts-poet fixes the issue

@lukealvoeiro
Copy link
Collaborator Author

@stephenh Do you have any ideas on what may be going on here? Spent a few hours on it but didn't manage to track down the issue.

@lukealvoeiro lukealvoeiro reopened this Feb 15, 2024
@stephenh
Copy link
Owner

Hi @lukealvoeiro ; great job diagnosing & fixing this! Lmk when you've got the ts-poet bump incorporated here, and we can merge the PR, with the test case to keep it from regressing. Thank you!

@lukealvoeiro lukealvoeiro changed the title Import fails when folder name overlaps with file name fix: import fails when folder name overlaps with file name Feb 15, 2024
@stephenh
Copy link
Owner

This is great! Thanks for the test!

@stephenh stephenh merged commit 1e68e6f into stephenh:main Feb 15, 2024
6 checks passed
stephenh pushed a commit that referenced this pull request Feb 15, 2024
## [1.167.5](v1.167.4...v1.167.5) (2024-02-15)

### Bug Fixes

* import fails when folder name overlaps with file name ([#1000](#1000)) ([1e68e6f](1e68e6f))
@stephenh
Copy link
Owner

🎉 This PR is included in version 1.167.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants