gdsestimating/dxf-parser

Compilation issue with ParseHelpers

Opened this issue · 3 comments

Hi, iam updating packages in my project and after dxf-parser update i got compilation error:

Error: node_modules/dxf-parser/src/ParseHelpers.ts:112:4 - error TS2322: Type '{ customStrings: string[]; applicationName: string; } | {}' is not assignable to type '{ customStrings: string[]; applicationName: string; }'.
Type '{}' is missing the following properties from type '{ customStrings: string[]; applicationName: string; }': customStrings, applicationName

112 entity.extendedData = entity.extendedData || {};

image

as you can see IEntity.extendedData has 2 required params but you are assigning {} in some case.

Can you fix it ASAP, i want to update this package because it is now in TS with types but i cannot do it with compilation error.

Btw best solution should be to use somethink like DxfEntityAny instead of IEntity.

export type DxfEntityAny = I3DfaceEntity|IArcEntity|IAttdefEntity|ICircleEntity|IDimensionEntity|IEllipseEntity|IInsertEntity|ILineEntity| ILwpolylineEntity|IMtextEntity|IPointEntity|IPolylineEntity|ISolidEntity|ISplineEntity|ITextEntity| IVertexEntity;

Ah, yes. I see. Interesting that didn't come up for me. Must be some kind of stricter compilation option?

After reading more about XData, I see our solution is not quite right. https://ezdxf.readthedocs.io/en/stable/tutorials/custom_data.html#tut-custom-data

I think we need to make deprecate customStrings and just create an array of (group code, value) tuples. We don't know the meaning of these codes in the context of XData so we have to provide the raw data.

Hi, when you estimate that this error will be fixed?

Can you fix it for now with simple replacement of:

  • entity.extendedData = entity.extendedData || {}; for
  • entity.extendedData = entity.extendedData || {customStrings: [], applicationName: ""}; at lines 131 & 136 in ParseHelpers.ts???