From 36b0ed4c95ebe11a31dead7f776c93bec250a644 Mon Sep 17 00:00:00 2001 From: muqiuhan Date: Tue, 23 Jul 2024 09:37:53 +0000 Subject: deploy: 9afb69c7ab5733a5b139f136983933a2e64ccdf7 --- search.xml | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 125 insertions(+), 28 deletions(-) (limited to 'search.xml') diff --git a/search.xml b/search.xml index a31d3894..53329cad 100644 --- a/search.xml +++ b/search.xml @@ -609,6 +609,103 @@
  • Github - robur-coop/orb: check opam package reproductibility.
  • Github - ocaml-multicore/dscheck: Experimental model checker for testing concurrent algorithms.
  • +]]> + + Technique + OCaml + + + + OCaml News 2024-6 + /2024/07/23/OCaml-News-2024-6/ +
           ^o3
    ~/\_/\_|)
    |/=_=\|
    " "
    + +

    语言的发展

    +

    新消息

    +

    有价值的文章

    +

    有趣的项目

    ]]>
    Technique @@ -636,34 +733,6 @@ Medicine
    - - Rescript @genType import 问题 - /2024/05/20/Rescript-genType-import-%E9%97%AE%E9%A2%98/ - Rescript 11 之后,@genType 被合并进编译器,无需任何依赖就能使用,当在 Rescript 中 @genType 了使用某些 Rescript built-in 的基本类型时,可能会生成有问题的 import 相关代码,例如:

    -
    @genType
    module LoginResponse = {
    let status = response => {
    response
    ->Js.Json.decodeObject
    ->Option.flatMap(response => {
    response->Js_dict.get("status")
    })
    }
    }
    - -

    status 函数具有 Js.Json.t => option<Js.Json.t> 类型,那么在生成的 TypeScript 文件中,会出现这样的 import:

    -
    import type { Json_t as Js_Json_t } from "./Js.gen.tsx"
    - -

    而 Js.gen.tsx 这个文件是不存在的,解决方案是使用 @genType 的 shim:

    -
      -
    • 在 rescript.json 中的 gentypeconfig 中添加 shim 配置:

      -
      ...
      "gentypeconfig": {
      ...
      "shims": {
      "Js": "Js"
      },
      ...
      }
      ...
      -
    • -
    • 然后新建 Js.shim.ts:

      -
      export type Json_t = unknown;

      export type t = unknown;

      export type Exn_t = Error;
      -
    • -
    • 删除原来由 @genType 生成的 TypeScript 文件并重新生成

      -
    • -
    -

    现在生成的 TypeScript 文件将会从 Js.shim.ts import 类型:

    -
    import type {Json_t as Js_Json_t} from '../../src/model/Js.shim.ts';
    -]]>
    - - Technique - Rescript - -
    Rescript and React Native /2024/01/22/Rescript-React-Native/ @@ -689,6 +758,34 @@ +]]> + + Technique + Rescript + + + + Rescript @genType import 问题 + /2024/05/20/Rescript-genType-import-%E9%97%AE%E9%A2%98/ + Rescript 11 之后,@genType 被合并进编译器,无需任何依赖就能使用,当在 Rescript 中 @genType 了使用某些 Rescript built-in 的基本类型时,可能会生成有问题的 import 相关代码,例如:

    +
    @genType
    module LoginResponse = {
    let status = response => {
    response
    ->Js.Json.decodeObject
    ->Option.flatMap(response => {
    response->Js_dict.get("status")
    })
    }
    }
    + +

    status 函数具有 Js.Json.t => option<Js.Json.t> 类型,那么在生成的 TypeScript 文件中,会出现这样的 import:

    +
    import type { Json_t as Js_Json_t } from "./Js.gen.tsx"
    + +

    而 Js.gen.tsx 这个文件是不存在的,解决方案是使用 @genType 的 shim:

    +
      +
    • 在 rescript.json 中的 gentypeconfig 中添加 shim 配置:

      +
      ...
      "gentypeconfig": {
      ...
      "shims": {
      "Js": "Js"
      },
      ...
      }
      ...
      +
    • +
    • 然后新建 Js.shim.ts:

      +
      export type Json_t = unknown;

      export type t = unknown;

      export type Exn_t = Error;
      +
    • +
    • 删除原来由 @genType 生成的 TypeScript 文件并重新生成

      +
    • +
    +

    现在生成的 TypeScript 文件将会从 Js.shim.ts import 类型:

    +
    import type {Json_t as Js_Json_t} from '../../src/model/Js.shim.ts';
    ]]>
    Technique -- cgit v1.2.3