diff --git a/CHANGELOG.md b/CHANGELOG.md index cc9502a827..e6b9f35608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/jscomp/gentype/Translation.ml b/jscomp/gentype/Translation.ml index a7851ceedf..bd787eadb9 100644 --- a/jscomp/gentype/Translation.ml +++ b/jscomp/gentype/Translation.ml @@ -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 diff --git a/jscomp/gentype_tests/typescript-react-example/package-lock.json b/jscomp/gentype_tests/typescript-react-example/package-lock.json index de73e10c11..a4283beaac 100644 --- a/jscomp/gentype_tests/typescript-react-example/package-lock.json +++ b/jscomp/gentype_tests/typescript-react-example/package-lock.json @@ -22,26 +22,6 @@ "typescript": "^5.2.2" } }, - "../../..": { - "name": "rescript", - "version": "11.0.0-rc.7", - "dev": true, - "hasInstallScript": true, - "license": "SEE LICENSE IN LICENSE", - "bin": { - "bsc": "bsc", - "bstracing": "lib/bstracing", - "rescript": "rescript" - }, - "devDependencies": { - "mocha": "10.1.0", - "nyc": "15.0.0", - "prettier": "2.7.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", @@ -1419,8 +1399,19 @@ } }, "node_modules/rescript": { - "resolved": "../../..", - "link": true + "version": "11.0.0-rc.7", + "resolved": "file:../../..", + "dev": true, + "hasInstallScript": true, + "license": "SEE LICENSE IN LICENSE", + "bin": { + "bsc": "bsc", + "bstracing": "lib/bstracing", + "rescript": "rescript" + }, + "engines": { + "node": ">=10" + } }, "node_modules/resolve-from": { "version": "4.0.0", diff --git a/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.gen.tsx index 9b5bc42b59..54bec1e7d2 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.gen.tsx @@ -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; diff --git a/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.res b/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.res index 3b90749968..fa6b2fa463 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.res +++ b/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.res @@ -1,2 +1,2 @@ -@genType.as("ExportWithRename") @react.component +@genType.as("Renamed") @react.component let make = (~s) => React.string(s) diff --git a/jscomp/gentype_tests/typescript-react-example/src/Warnings.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Warnings.gen.tsx index 92663ae709..23ecd25023 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Warnings.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Warnings.gen.tsx @@ -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;