Skip to content

Required shim for "PervasivesU", gentype #6807

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

Closed
jmagaram opened this issue Jun 4, 2024 · 4 comments · Fixed by #6808
Closed

Required shim for "PervasivesU", gentype #6807

jmagaram opened this issue Jun 4, 2024 · 4 comments · Fixed by #6808

Comments

@jmagaram
Copy link
Contributor

jmagaram commented Jun 4, 2024

I created a new empty ReScript project with the latest stuff and a small "Hello World" React component seems to work. BUT there is an error in the VS Code reporting. The generated .gen.tsx files has this code...

import * as HelloJS from './Hello.res.js';
import type {Jsx_element as PervasivesU_Jsx_element} from './PervasivesU.gen.tsx';
export type props = {};
export const make: (_1:props) => PervasivesU_Jsx_element = HelloJS.make as any;

The error is...

Cannot find module './PervasivesU.gen.tsx' or its corresponding type declarations.

I had no idea how to fix this. Using...

    "@rescript/core": "^1.3.0",
    "@rescript/react": "^0.12.2",
    "rescript": "^11.1.1"

This separate bug in the compiler has a repro scenario where the developer fixed this problem I ran into by creating a shim.

#6624
https://github.com/WhyThat/gentype-error-reproduction/blob/main/src/shims/PervasivesU.shim.ts

I think that (1) the shim should not be required, or (2) the documentation for getting started with ReScript and React needs to explain how to make the shim. Actually now I see that TypeScript shims have been deprecated so I'm confused how I'm supposed to handle this issue.

My rescript.json file...

{
  "name": "hotkey",
  "sources": [
    {
      "dir": "src",
      "subdirs": true
    }
  ],
  "package-specs": [
    {
      "module": "esmodule",
      "in-source": true
    }
  ],
  "suffix": ".res.js",
  "bs-dependencies": ["@rescript/core", "@rescript/react"],
  "bsc-flags": ["-open RescriptCore"],
  "jsx": { "version": 4 },
  "gentypeconfig": {
    "module": "esmodule",
    "moduleResolution": "bundler",
    "generatedFileExtension": ".gen.tsx"
  }
}
@jmagaram
Copy link
Contributor Author

jmagaram commented Jun 5, 2024

This might be related. I just tried to do a gentype export on a function that takes a ReactEvent.Keyboard.t as a parameter and see this in the .gen.tsx file and also an error about not being able to find it.

import type {Keyboard_t as ReactEvent_Keyboard_t} from '@rescript/react/src/ReactEvent.gen.tsx';

@cristianoc
Copy link
Collaborator

cristianoc commented Jun 6, 2024

gentype special-cases type React.element.
It could be that the example surfaces type Jsx.element, which is how React.element is defined.
Would you give the example that leads to this behaviour?

@jmagaram
Copy link
Contributor Author

jmagaram commented Jun 6, 2024

cristianoc added a commit that referenced this issue Jun 7, 2024
The type Jsx.element can show user-side in ppx V4 (at least), and affects gentype too.
It special-cases `React.element`, and needs to then special-case `Jsx.element` too.

Fixes #6807
@cristianoc
Copy link
Collaborator

The case for Jsx.element is handled here: #6808

cristianoc added a commit that referenced this issue Jun 7, 2024
The type Jsx.element can show user-side in ppx V4 (at least), and affects gentype too.
It special-cases `React.element`, and needs to then special-case `Jsx.element` too.

Fixes #6807
cristianoc added a commit that referenced this issue Jun 7, 2024
The type Jsx.element can show user-side in ppx V4 (at least), and affects gentype too.
It special-cases `React.element`, and needs to then special-case `Jsx.element` too.

Fixes #6807
cknitt pushed a commit that referenced this issue Jun 15, 2024
The type Jsx.element can show user-side in ppx V4 (at least), and affects gentype too.
It special-cases `React.element`, and needs to then special-case `Jsx.element` too.

Fixes #6807

# Conflicts:
#	CHANGELOG.md
cknitt pushed a commit that referenced this issue Jun 16, 2024
The type Jsx.element can show user-side in ppx V4 (at least), and affects gentype too.
It special-cases `React.element`, and needs to then special-case `Jsx.element` too.

Fixes #6807

# Conflicts:
#	CHANGELOG.md
cknitt pushed a commit that referenced this issue Jun 16, 2024
The type Jsx.element can show user-side in ppx V4 (at least), and affects gentype too.
It special-cases `React.element`, and needs to then special-case `Jsx.element` too.

Fixes #6807

# Conflicts:
#	CHANGELOG.md
cknitt pushed a commit that referenced this issue Jun 16, 2024
The type Jsx.element can show user-side in ppx V4 (at least), and affects gentype too.
It special-cases `React.element`, and needs to then special-case `Jsx.element` too.

Fixes #6807

# Conflicts:
#	CHANGELOG.md
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 a pull request may close this issue.

2 participants