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

Relay Resolver has module resolution problem in TypeScript #3989

Closed
ellemedit opened this issue Jun 22, 2022 · 5 comments
Closed

Relay Resolver has module resolution problem in TypeScript #3989

ellemedit opened this issue Jun 22, 2022 · 5 comments
Labels
bug rust Related to the compiler written in Rust typescript

Comments

@ellemedit
Copy link

ellemedit commented Jun 22, 2022

Screen Shot 2022-06-22 at 15 34 22

Screen Shot 2022-06-22 at 15 37 58

As above images, generated relay artifacts import relay resolver with extension.
I think using ".js" extension or skipping extension are correct solution at this moment. So we can inference return type of RelayResolver function in TypeScript.

@ellemedit ellemedit changed the title Problem at inferencing Relay Resolver return type in TypeScript Relay Resolver has module resolution problem in TypeScript Jun 22, 2022
@alunyov alunyov added bug rust Related to the compiler written in Rust typescript labels Jun 22, 2022
@alunyov
Copy link
Contributor

alunyov commented Jun 22, 2022

The Relay Resolvers is still in active development, and typescript support maybe lacking in some places. Thanks for reporting!

@captbaritone
Copy link
Contributor

Thanks for the report @beingbook. If you're interested in working on a fix, I suspect stripping the extension would be the right approach and the I think the code that derives this path lives here: https://github.com/facebook/relay/blob/main/compiler/crates/relay-config/src/project_config.rs#L360

cc @tbezman

@ellemedit
Copy link
Author

ellemedit commented Jul 10, 2022

oops, I'm too late. thank you for suggesting contribution! I want to work if there's next time.

@chriserickson
Copy link

This was not fixed in 14.1 - the dynamic imports in the AST omit extensions, however the type imports still have the extensions.

It appears that

fn write_import_module_default(&mut self, name: &str, from: &str) -> FmtResult {

and
fn write_import_type(&mut self, types: &[&str], from: &str) -> FmtResult {

Both also need to strip extensions, as typescript requires that extensions not be provided.

Is it possible to re-open this? I'm happy to work on a fix.

@chriserickson
Copy link

I went ahead and created a new issue:

#4056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug rust Related to the compiler written in Rust typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants