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

Remove .js and .ts from require / import #4002

Closed
wants to merge 5 commits into from

Conversation

tbezman
Copy link
Contributor

@tbezman tbezman commented Jul 6, 2022

Fixes #3989 (comment)

This PR updates relay-codegen's printer not to include the file's extension when writing imports / requires. This might be a naive implementation, maybe there's a better, more holistic approach.

@captbaritone
Copy link
Contributor

Awesome!

@facebook-github-bot
Copy link
Contributor

@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.


if extension == ".js" || extension == ".ts" {
path = path[0..path.len() - 3].to_string();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

the Path/PathBuf types have utilities for extracting the extension, let's use those? there is also the camino crate, which is basically utf8-only versions of Path/PathBuf which might help since the string is already utf8.

-- @josephsavona (internal review)

Copy link
Contributor

Choose a reason for hiding this comment

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

missing tsx

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed #4303

@facebook-github-bot
Copy link
Contributor

@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit that referenced this pull request Sep 12, 2022
…erated code (#4057)

Summary:
# What does this PR do

* This PR, imported from github, scrubs `.ts` extensions from filepaths in imports in generated typescript files
* Typescript does not like `.ts`: microsoft/TypeScript#37582

In the typegen for Typescript when we're writing the pathname for module and type imports, this PR strips any trailing `.ts` that might exist on the path. This is required for TypeScript file imports which don't like the trailing file suffix. This was partially fixed in #4002 but not completely.

Pull Request resolved: #4057

Test Plan: 👀

Reviewed By: alunyov

Differential Revision: D39437828

Pulled By: rbalicki2

fbshipit-source-id: 53b3f5f7e467cefbc9ae73bf455ca040ea8a69aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relay Resolver has module resolution problem in TypeScript
4 participants