boring-router icon indicating copy to clipboard operation
boring-router copied to clipboard

$query, $extension 和 $children 的属性不能重名但又没有正确的错误提示

Open noobnooc opened this issue 5 years ago • 2 comments

Makeflow task reference: https://staging.makeflow.io/app/?_redirect=/task/3223 比如有以下路由定义:

efforts: {
    $exact: true,
    $children: {
      team: {      // 1: $children 里的 team
        $exact: true,
        $query: {
          range: true,
          team: true,  // 2: $query 里的 team
        },
      },
    },
    $extension: {
      range: undefined as string | undefined,
      team: undefined as Team | undefined,   // 3: $extension 里的 team
    },
}

其中 `1` `2` `3` 中的 team 是冲突的,但 Boring Router 本身并不会报错或报错信息混乱从而导致一些看起来难以排查的 bug。可考虑改成命名互不冲突或者在定义时就报出提示信息明确的错误。

noobnooc avatar Feb 06 '20 08:02 noobnooc

这里好像 1 和 3 冲突,2 在这种情况下(1 的 $match 不是正则的时候)应该不冲突(实际实现可能有问题)。如果 1 的 $match 是正则,2 就也和 1,3冲突。

试试看 query 没有 team 的情况下,上面的 $params 里类型和运行时有没有 team 属性?

vilicvane avatar Feb 06 '20 08:02 vilicvane

试了下,$params 在运行时和类型上都没有team 属性

noobnooc avatar Feb 06 '20 08:02 noobnooc