Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.8] [Security Solution] getDataViewStateFromIndexFields was using wrong type as part of a cast (#158594) #158784

Merged

Commits on May 31, 2023

  1. [Security Solution] getDataViewStateFromIndexFields was using wrong t…

    …ype as part of a cast (elastic#158594)
    
    ## Summary
    
    Fixes an issue with the field browser where all types currently display
    as unkown, this was because in a code path where a type cast happens, we
    were using the wrong type. To see this, remove the as unknown from the
    cast, and the typescript compiler will show the problem:
    ```
    'BrowserField' is deprecated.ts(6385)
    index.ts(70, 4): The declaration was marked as deprecated here.
    Conversion of type 'DataViewField' to type 'BrowserField' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
      Type 'DataViewField' is missing the following properties from type 'BrowserField': category, description, example, fields, and 2 more.ts(2352)
    ```
    DataViewField actually only has spec and kbnFieldType properties, spec
    is of type FieldSpec which is basically the same type as BrowserField,
    and has sufficient overlap for the (still unsafe, but more safe than as
    unknown) cast to occur.
    
    Before:
    <img width="338" alt="image"
    src="https://github.com/elastic/kibana/assets/56408403/f31c1f9e-25f0-41ee-9e1c-a70171e41d29">
    
    After:
    <img width="555" alt="image"
    src="https://github.com/elastic/kibana/assets/56408403/8b462477-2dce-41bb-9592-f34b20634b84">
    
    ---------
    
    Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
    (cherry picked from commit 1c75903)
    
    # Conflicts:
    #	x-pack/plugins/security_solution/public/detections/components/alerts_table/alerts_grouping.tsx
    #	x-pack/plugins/security_solution/tsconfig.json
    kqualters-elastic committed May 31, 2023
    Configuration menu
    Copy the full SHA
    4483622 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    555b765 View commit details
    Browse the repository at this point in the history