Skip to content

Commit fc7b900

Browse files
authored
GenType: fix runtime error on @genType.as output (#6509)
* Gentype: fix runtime error on `@genType.as` output * [skip ci] add changelog
1 parent 3ec3479 commit fc7b900

File tree

6 files changed

+19
-27
lines changed

6 files changed

+19
-27
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#### :bug: Bug Fix
2121
- Fix issue where an inline record with attributes did not parse. https://github.com/rescript-lang/rescript-compiler/pull/6499
2222
- 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
23+
- Fix runtime errors on `@genType.as("alias")` output. https://github.com/rescript-lang/rescript-compiler/pull/6509
2324

2425
# 11.0.0-rc.6
2526

jscomp/gentype/Translation.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ let translateValue ~attributes ~config ~docString ~outputFileRelative ~resolver
9090
|> addAnnotationsToFunction
9191
in
9292
let resolvedNameOriginal =
93-
nameAs |> TypeEnv.addModulePath ~typeEnv |> ResolvedName.toString
93+
name |> TypeEnv.addModulePath ~typeEnv |> ResolvedName.toString
9494
in
95-
let resolvedName = name |> TypeEnv.addModulePath ~typeEnv in
95+
let resolvedName = nameAs |> TypeEnv.addModulePath ~typeEnv in
9696
let moduleAccessPath =
9797
typeEnv |> TypeEnv.getModuleAccessPath ~name:resolvedNameOriginal
9898
in

jscomp/gentype_tests/typescript-react-example/package-lock.json

+13-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.gen.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ const ExportWithRenameBS: any = ExportWithRenameBS__Es6Import;
1010

1111
export type Props = { readonly s: string };
1212

13-
export const make: React.ComponentType<{ readonly s: string }> = ExportWithRenameBS.ExportWithRename;
13+
export const Renamed: React.ComponentType<{ readonly s: string }> = ExportWithRenameBS.make;
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@genType.as("ExportWithRename") @react.component
1+
@genType.as("Renamed") @react.component
22
let make = (~s) => React.string(s)

jscomp/gentype_tests/typescript-react-example/src/Warnings.gen.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
import * as WarningsBS__Es6Import from './Warnings.bs';
77
const WarningsBS: any = WarningsBS__Es6Import;
88

9-
export const x: number = WarningsBS.ddd;
9+
export const ddd: number = WarningsBS.x;

0 commit comments

Comments
 (0)