类型 'string | number | symbol' 不可分配给类型 'string'

Type 'string | number | symbol' is not assignable to type 'string'

我在 L102 处遇到以下类型定义错误。

Too long url link to read

TypeScript 4.6.2 表示...

(property) Schema.items?: Schema | undefined
Type 'Schema & p["items"]' does not satisfy the constraint 'Schema'.
  Types of property 'required' are incompatible.
    Type '(readonly (keyof NonNullable<(Schema & p["items"])["properties"]>)[] & readonly (keyof NonNullable<p["items"]["properties"]>)[]) | undefined' is not assignable to type 'readonly string[] | undefined'.
      Type 'readonly (keyof NonNullable<(Schema & p["items"])["properties"]>)[] & readonly (keyof NonNullable<p["items"]["properties"]>)[]' is not assignable to type 'readonly string[] | undefined'.
        Type 'readonly (keyof NonNullable<(Schema & p["items"])["properties"]>)[] & readonly (keyof NonNullable<p["items"]["properties"]>)[]' is not assignable to type 'readonly string[]'.
          The types returned by 'concat(...)' are incompatible between these types.
            Type '(keyof NonNullable<(Schema & p["items"])["properties"]>)[]' is not assignable to type 'string[]'.
              Type 'keyof NonNullable<(Schema & p["items"])["properties"]>' is not assignable to type 'string'.
                Type 'string | number | symbol' is not assignable to type 'string'.
                  Type 'number' is not assignable to type 'string'.(2344)

如果我更改 L34,Schema 接口定义,从

    readonly required?: ReadonlyArray<keyof NonNullable<this['properties']>>;

    readonly required?: ReadonlyArray<keyof NonNullable<Schema['properties']>>;

这消除了错误,但我想使用 this

使用this时有什么方法可以清除错误吗?

使用提取物。

    readonly required?: ReadonlyArray<Extract<keyof NonNullable<this['properties']>, string>>;

https://zenn.dev/jiftechnify/scraps/6f0bdab4be0a8f