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

GenType: fix runtime error on @genType.as output #6509

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#### :bug: Bug Fix
- Fix issue where an inline record with attributes did not parse. https://github.com/rescript-lang/rescript-compiler/pull/6499
- Fix issue with uncurried function with 1 arg being a variable where an undefined variable could be emitted. https://github.com/rescript-lang/rescript-compiler/pull/6507
- Fix runtime errors on `@genType.as("alias")` output. https://github.com/rescript-lang/rescript-compiler/pull/6509

# 11.0.0-rc.6

Expand Down
4 changes: 2 additions & 2 deletions jscomp/gentype/Translation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ let translateValue ~attributes ~config ~docString ~outputFileRelative ~resolver
|> addAnnotationsToFunction
in
let resolvedNameOriginal =
nameAs |> TypeEnv.addModulePath ~typeEnv |> ResolvedName.toString
name |> TypeEnv.addModulePath ~typeEnv |> ResolvedName.toString
in
let resolvedName = name |> TypeEnv.addModulePath ~typeEnv in
let resolvedName = nameAs |> TypeEnv.addModulePath ~typeEnv in
let moduleAccessPath =
typeEnv |> TypeEnv.getModuleAccessPath ~name:resolvedNameOriginal
in
Expand Down
35 changes: 13 additions & 22 deletions jscomp/gentype_tests/typescript-react-example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const ExportWithRenameBS: any = ExportWithRenameBS__Es6Import;

export type Props = { readonly s: string };

export const make: React.ComponentType<{ readonly s: string }> = ExportWithRenameBS.ExportWithRename;
export const Renamed: React.ComponentType<{ readonly s: string }> = ExportWithRenameBS.make;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@genType.as("ExportWithRename") @react.component
@genType.as("Renamed") @react.component
let make = (~s) => React.string(s)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
import * as WarningsBS__Es6Import from './Warnings.bs';
const WarningsBS: any = WarningsBS__Es6Import;

export const x: number = WarningsBS.ddd;
export const ddd: number = WarningsBS.x;