Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/api/ecschema-metadata.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,7 @@ export class SchemaReadHelper<T = unknown> {
// (undocumented)
static isECSpecVersionNewer(ecSpecVersion?: ECSpecVersion): boolean;
protected isSchemaItemLoaded(schemaItem: SchemaItem | undefined): boolean;
protected isSchemaItemLoadedAndDefined(schemaItem: SchemaItem | undefined): schemaItem is SchemaItem;
protected loadCustomAttributes(container: AnyCAContainer, caProviders: Iterable<CAProviderTuple>): Promise<void>;
protected loadSchemaItem(schema: Schema, name: string, itemType: string, schemaItemObject?: Readonly<unknown>): Promise<SchemaItem | undefined>;
readSchema(schema: Schema, rawSchema: T, addSchemaToCache?: boolean): Promise<Schema>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/ecschema-editing",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/ecschema-editing"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/ecschema-locaters",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/ecschema-locaters"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/ecschema-metadata",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/ecschema-metadata"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/ecsql-common",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/ecsql-common"
}
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Constants extends SchemaItems {
const newConstant = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createConstant.bind(schema), constantProps);
return newConstant.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, constantProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, constantProps.name ?? "<unknown>", schemaKey), e);
}
}
}
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/CustomAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class CustomAttributes extends ECClasses {
const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createCustomAttributeClass.bind(schema), caProps);
return newClass.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, caProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, caProps.name ?? "<unknown>", schemaKey), e);
}
}
}
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/Entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class Entities extends ECClasses {
const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createEntityClass.bind(schema), entityProps);
return newClass.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, entityProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, entityProps.name ?? "<unknown>", schemaKey), e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/Enumerations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Enumerations extends SchemaItems {
const newEnum = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createEnumeration.bind(schema), enumProps);
return newEnum.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, enumProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, enumProps.name ?? "<unknown>", schemaKey), e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/Exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export class SchemaItemId implements ISchemaItemIdentifier {
if (!schemaKey)
throw new Error("schemaKey if required if the specified schemaItem the name of the schema item.");

this.schemaKey = schemaKey!;
this.schemaKey = schemaKey;
this.schemaItemKey = new SchemaItemKey(schemaItemKeyOrName, schemaKey);
} else {
this.schemaKey = schemaItemKeyOrName.schemaKey;
Expand Down
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/Formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Formats extends SchemaItems {
const newFormat = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createFormat.bind(schema), formatProps);
return newFormat.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, formatProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, formatProps.name ?? "<unknown>", schemaKey), e);
}
}
}
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/InvertedUnits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class InvertedUnits extends SchemaItems {
const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createInvertedUnit.bind(schema), invertedUnitProps);
return newUnit.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, invertedUnitProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, invertedUnitProps.name ?? "<unknown>", schemaKey), e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/KindOfQuantities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class KindOfQuantities extends SchemaItems {
const koqItem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createKindOfQuantity.bind(schema), koqProps);
return koqItem.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, koqProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, koqProps.name ?? "<unknown>", schemaKey), e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/Mixins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Mixins extends ECClasses {
const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createMixinClass.bind(schema), mixinProps);
return newClass.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, mixinProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, mixinProps.name ?? "<unknown>", schemaKey), e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/Phenomena.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class Phenomena extends SchemaItems {
const newPhenomenon = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPhenomenon.bind(schema), phenomenonProps);
return newPhenomenon.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, phenomenonProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, phenomenonProps.name ?? "<unknown>", schemaKey), e);
}
}
}
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/PropertyCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class PropertyCategories extends SchemaItems {
const newPropCategory = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), propertyCategoryProps);
return newPropCategory.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, propertyCategoryProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, propertyCategoryProps.name ?? "<unknown>", schemaKey), e);
}
}

Expand Down
7 changes: 4 additions & 3 deletions core/ecschema-editing/src/Editing/RelationshipClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @module Editing
*/

import { expectDefined } from "@itwin/core-bentley";
import {
CustomAttribute, DelayedPromiseWithProps, ECClass, ECClassModifier, EntityClass, LazyLoadedRelationshipConstraintClass, Mixin, NavigationPropertyProps,
RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaItemType,
Expand Down Expand Up @@ -102,7 +103,7 @@ export class RelationshipClasses extends ECClasses {

return newClass.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, relationshipProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, relationshipProps.name ?? "<unknown>", schemaKey), e);
}
}

Expand All @@ -121,9 +122,9 @@ export class RelationshipClasses extends ECClasses {
await super.setBaseClass(itemKey, baseClassKey);

try {
await this.validate(relClass!);
await this.validate(expectDefined(relClass));
} catch(e: any) {
await (relClass! as ECClass as MutableClass).setBaseClass(baseClass);
await (expectDefined(relClass) as ECClass as MutableClass).setBaseClass(baseClass);
Copy link
Member

@ColinKerr ColinKerr Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christophermlawson what is the expected behavior when the item key doesn't resolve to a relationship class?

This should be fixed properly rather than with this hack and the behavior should be documented and tested

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ColinKerr This would be unexpected, so I think an exception would be appropriate here.

throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(SchemaItemType.RelationshipClass, itemKey), e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/Structs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Structs extends ECClasses {
const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), structProps);
return newClass.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, structProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, structProps.name ?? "<unknown>", schemaKey), e);
}
}
}
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/UnitSystems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class UnitSystems extends SchemaItems {
const newUnitSystem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), unitSystemProps);
return newUnitSystem.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitSystemProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitSystemProps.name ?? "<unknown>", schemaKey), e);
}
}
}
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Editing/Units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Units extends SchemaItems {
const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);
return newUnit.key;
} catch (e: any) {
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);
throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name ?? "<unknown>", schemaKey), e);
}
}
}
2 changes: 1 addition & 1 deletion core/ecschema-editing/src/Merging/EnumerationMerger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function addEnumeration(context: SchemaMergeContext, change: Enumer
export async function modifyEnumeration(context: SchemaMergeContext, change: EnumerationDifference, itemKey: SchemaItemKey) {
const enumeration = await context.targetSchema.lookupItem(itemKey) as MutableEnumeration;
if(change.difference.type !== undefined) {
throw new Error(`The Enumeration ${itemKey.name} has an incompatible type. It must be "${primitiveTypeToString(enumeration.type!)}", not "${change.difference.type}".`);
throw new Error(`The Enumeration ${itemKey.name} has an incompatible type. It must be "${enumeration.type ? primitiveTypeToString(enumeration.type) : "<unknown>"}", not "${change.difference.type}".`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the underlying Enumeration._type property possibly undefined? Any valid enumeration MUST have a type set so we should not force callers to test if the type is null.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ColinKerr The constructor also has this as optional. It's internal so we can change this. Should we require the parameter or have a default (int or string)?

}
if(change.difference.label !== undefined) {
await context.editor.enumerations.setDisplayLabel(itemKey, change.difference.label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function mergeRelationshipConstraint(context: SchemaMergeContext, c
*/
export async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<void> {
if(change.changeType !== "add") {
throw new Error(`Change type ${change.changeType} is not supported for Relationship constraint classes.`);
throw new Error(`Change type ${String(change.changeType)} is not supported for Relationship constraint classes.`);
}

const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function modifySchemaReferences(context: SchemaMergeContext, change
}

if(!latest.matches(older, SchemaMatchType.LatestWriteCompatible)) {
throw new Error(`Schemas references of ${change.difference.name} have incompatible versions: ${older.version} and ${latest.version}`);
throw new Error(`Schemas references of ${change.difference.name} have incompatible versions: ${older.version.toString()} and ${latest.version.toString()}`);
}

const index = context.targetSchema.references.findIndex((reference) => reference === existingSchema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export abstract class SuppressionDiagnosticReporter implements IDiagnosticReport
public report(diagnostic: AnyDiagnostic) {
if (this._suppressions && this._suppressions.has(diagnostic.schema.fullName)) {
const suppressedCodes = this._suppressions.get(diagnostic.schema.fullName);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (suppressedCodes!.includes(diagnostic.code))
return;
}
Expand Down
3 changes: 2 additions & 1 deletion core/ecschema-editing/src/Validation/ECRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @module Validation
*/

import { expectDefined } from "@itwin/core-bentley";
import {
AnyClass, AnyProperty, CustomAttribute, CustomAttributeContainerProps, ECClass, ECClassModifier,
ECStringConstants, EntityClass, Enumeration, Mixin, PrimitiveProperty, PrimitiveType, primitiveTypeToString,
Expand Down Expand Up @@ -328,7 +329,7 @@ export async function* incompatibleValueTypePropertyOverride(property: AnyProper
if (!baseType || primitiveType === baseType)
return;

return new Diagnostics.IncompatibleValueTypePropertyOverride(property, [property.class.fullName, property.name, baseClass.fullName, primitiveTypeToString(baseType), primitiveTypeToString(primitiveType!)]);
return new Diagnostics.IncompatibleValueTypePropertyOverride(property, [property.class.fullName, property.name, baseClass.fullName, primitiveTypeToString(baseType), primitiveTypeToString(expectDefined(primitiveType))]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should be rewritten so the call back isn't reaching out of its scope to get primitiveType. It would be clearer if primitiveType was passed in as the overrideType of something like that indicating that this the type of the property that is trying to override a property from the base class. It would also avoid the need for expectDefined here.

Copy link
Member Author

@tcobbs-bentley tcobbs-bentley Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered that the requirement for ! or expectDefined was caused by what I feel is a compiler bug. (The compiler for some reason thinks that primitiveType might be undefined in callback, even though it's a const that has already been verified to be defined.) Introducing another const removed the need for either ! or expectDefined, so I made that change. Note that this doesn't address your actual comment here, but it does provide what I feel is a better fix to get rid of the !, and your comment no longer seems to be in the scope of this PR.

}

for await (const baseClass of property.class.getAllBaseClasses()) {
Expand Down
48 changes: 24 additions & 24 deletions core/ecschema-editing/src/Validation/SchemaChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ export abstract class BaseSchemaChanges implements ISchemaChanges {
* @param changeKey The key used to identify the ISchemaChanges in the Map (typically the name of the EC type, ie. SchemaItem.name).
*/
protected addChangeToMap<V extends ISchemaChanges>(changes: Map<string, V>, changesType: SchemaChangesConstructor, change: ISchemaChange, changeKey: string) {
if (changes.has(changeKey)) {
const existingChanges = changes.get(changeKey);
existingChanges!.addChange(change);
const existingChanges = changes.get(changeKey);
if (undefined !== existingChanges) {
existingChanges.addChange(change);
} else {
const newChanges = new changesType(this._schema, changeKey);
newChanges.addChange(change);
Expand Down Expand Up @@ -457,9 +457,9 @@ export class SchemaChanges extends BaseSchemaChanges {
}

private addChangeToSchemaItemMap(change: ISchemaChange, schemaItem: SchemaItem) {
if (this.schemaItemChanges.has(schemaItem.name)) {
const existingChanges = this.schemaItemChanges.get(schemaItem.name);
existingChanges!.addChange(change);
const existingChanges = this.schemaItemChanges.get(schemaItem.name)
if (undefined !== existingChanges) {
existingChanges.addChange(change);
} else {
const newChanges = new SchemaItemChanges(this.schema, schemaItem.name, schemaItem.schemaItemType);
newChanges.addChange(change);
Expand All @@ -468,9 +468,9 @@ export class SchemaChanges extends BaseSchemaChanges {
}

private addChangeToClassMap(change: ISchemaChange, ecClass: AnyClass) {
if (this.classChanges.has(ecClass.name)) {
const existingChanges = this.classChanges.get(ecClass.name);
existingChanges!.addChange(change);
const existingChanges = this.classChanges.get(ecClass.name);
if (undefined !== existingChanges) {
existingChanges.addChange(change);
} else {
const newChanges = new ClassChanges(this.schema, ecClass.name, ecClass.schemaItemType);
newChanges.addChange(change);
Expand All @@ -479,9 +479,9 @@ export class SchemaChanges extends BaseSchemaChanges {
}

private addChangeToEntityClassMap(change: ISchemaChange, ecClass: EntityClass) {
if (this.entityClassChanges.has(ecClass.name)) {
const existingChanges = this.entityClassChanges.get(ecClass.name);
existingChanges!.addChange(change);
const existingChanges = this.entityClassChanges.get(ecClass.name);
if (undefined !== existingChanges) {
existingChanges.addChange(change);
} else {
const newChanges = new EntityClassChanges(this.schema, ecClass.name, ecClass.schemaItemType);
newChanges.addChange(change);
Expand All @@ -490,9 +490,9 @@ export class SchemaChanges extends BaseSchemaChanges {
}

private addChangeToRelationshipClassMap(change: ISchemaChange, ecClass: RelationshipClass) {
if (this.relationshipClassChanges.has(ecClass.name)) {
const existingChanges = this.relationshipClassChanges.get(ecClass.name);
existingChanges!.addChange(change);
const existingChanges = this.relationshipClassChanges.get(ecClass.name);
if (undefined !== existingChanges) {
existingChanges.addChange(change);
} else {
const newChanges = new RelationshipClassChanges(this.schema, ecClass.name, ecClass.schemaItemType);
newChanges.addChange(change);
Expand All @@ -501,9 +501,9 @@ export class SchemaChanges extends BaseSchemaChanges {
}

private addChangeToEnumerationMap(change: ISchemaChange, enumeration: Enumeration) {
if (this.enumerationChanges.has(enumeration.name)) {
const existingChanges = this.enumerationChanges.get(enumeration.name);
existingChanges!.addChange(change);
const existingChanges = this.enumerationChanges.get(enumeration.name);
if (undefined !== existingChanges) {
existingChanges.addChange(change);
} else {
const newChanges = new EnumerationChanges(this.schema, enumeration.name, enumeration.schemaItemType);
newChanges.addChange(change);
Expand All @@ -512,9 +512,9 @@ export class SchemaChanges extends BaseSchemaChanges {
}

private addChangeToKOQMap(change: ISchemaChange, koq: KindOfQuantity) {
if (this.kindOfQuantityChanges.has(koq.name)) {
const existingChanges = this.kindOfQuantityChanges.get(koq.name);
existingChanges!.addChange(change);
const existingChanges = this.kindOfQuantityChanges.get(koq.name);
if (undefined !== existingChanges) {
existingChanges.addChange(change);
} else {
const newChanges = new KindOfQuantityChanges(this.schema, koq.name, koq.schemaItemType);
newChanges.addChange(change);
Expand All @@ -523,9 +523,9 @@ export class SchemaChanges extends BaseSchemaChanges {
}

private addChangeToFormatMap(change: ISchemaChange, format: Format) {
if (this.formatChanges.has(format.name)) {
const existingChanges = this.formatChanges.get(format.name);
existingChanges!.addChange(change);
const existingChanges = this.formatChanges.get(format.name);
if (undefined !== existingChanges) {
existingChanges.addChange(change);
} else {
const newChanges = new FormatChanges(this.schema, format.name, format.schemaItemType);
newChanges.addChange(change);
Expand Down
Loading