Skip to content

Commit b6f02c0

Browse files
committed
Allow both Stdlib.X and Stdlib_X.
1 parent 46a8d2f commit b6f02c0

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

compiler/gentype/TranslateTypeExprFromTypes.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ let rec remove_option ~(label : Asttypes.Noloc.arg_label)
1313

1414
let rec path_to_list path =
1515
match path with
16+
| Path.Pident id when String.starts_with (Ident.name id) ~prefix:"Stdlib_" ->
17+
let name = Ident.name id in
18+
let without_stdlib_prefix = String.sub name 7 (String.length name - 7) in
19+
[without_stdlib_prefix; "Stdlib"]
1620
| Path.Pident id -> [id |> Ident.name]
1721
| Path.Pdot (p, s, _) -> s :: (p |> path_to_list)
1822
| Path.Papply _ -> []
@@ -248,7 +252,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
248252
| ( (["Js"; "Dict"; "t"] | ["Dict"; "t"] | ["dict"] | ["Stdlib"; "Dict"; "t"]),
249253
[param_translation] ) ->
250254
{param_translation with type_ = Dict param_translation.type_}
251-
| ["Stdlib_JSON"; "t"], [] -> {dependencies = []; type_ = unknown}
255+
| ["Stdlib"; "JSON"; "t"], [] -> {dependencies = []; type_ = unknown}
252256
| _ -> default_case ()
253257

254258
type process_variant = {

tests/gentype_tests/typescript-react-example/src/Core.gen.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,6 @@ export const option0: (x:(undefined | string)) => (undefined | string) = CoreJS.
6969

7070
export const option1: (x:(undefined | variant)) => (undefined | variant) = CoreJS.option1 as any;
7171

72-
export const jsonEncodeString: unknown = CoreJS.jsonEncodeString as any;
72+
export const jsonEncodeString1: unknown = CoreJS.jsonEncodeString1 as any;
73+
74+
export const jsonEncodeString2: unknown = CoreJS.jsonEncodeString2 as any;

tests/gentype_tests/typescript-react-example/src/Core.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,7 @@ external someFunWithNullUndefinedArg: (
8585
) => string = "someFunWithNullUndefinedArg"
8686

8787
@genType
88-
let jsonEncodeString = JSON.Encode.string("hello")
88+
let jsonEncodeString1 = JSON.Encode.string("hello")
89+
90+
@genType
91+
let jsonEncodeString2 : JSON.t = JSON.Encode.string("hello")

tests/gentype_tests/typescript-react-example/src/Core.res.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)