Skip to content

Commit

Permalink
GenType: fix runtime error on @genType.as output (#6509)
Browse files Browse the repository at this point in the history
* Gentype: fix runtime error on `@genType.as` output

* [skip ci] add changelog
  • Loading branch information
cometkim authored Dec 6, 2023
1 parent 3ec3479 commit fc7b900
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
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;

0 comments on commit fc7b900

Please sign in to comment.