Skip to content

Commit

Permalink
Remove optional chaining for required properties
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed May 7, 2020
1 parent 155eeea commit 3e1eea6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions x-pack/plugins/lens/server/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const removeLensAutoDate: SavedObjectMigrationFn<LensDocShape, LensDocShape> = (
* Adds missing timeField arguments to esaggs in the Lens expression
*/
const addTimeFieldToEsaggs: SavedObjectMigrationFn<LensDocShape, LensDocShape> = (doc, context) => {
const expression = doc.attributes?.expression;
const expression = doc.attributes.expression;
if (!expression) {
return doc;
}
Expand Down Expand Up @@ -178,9 +178,8 @@ const removeInvalidAccessors: SavedObjectMigrationFn<
LensDocShape<XYStatePost77>
> = doc => {
const newDoc = cloneDeep(doc);
if (newDoc.attributes?.visualizationType === 'lnsXY') {
const datasourceState = newDoc.attributes.state.datasourceStates.indexpattern;
const datasourceLayers = datasourceState?.layers ?? {};
if (newDoc.attributes.visualizationType === 'lnsXY') {
const datasourceLayers = newDoc.attributes.state.datasourceStates.indexpattern.layers || {};
const xyState = newDoc.attributes.state.visualization;
(newDoc.attributes as LensDocShape<
XYStatePost77
Expand Down

0 comments on commit 3e1eea6

Please sign in to comment.