pofile icon indicating copy to clipboard operation
pofile copied to clipboard

TypeScript: Add type `null` to `Item` properties

Open danielrentz opened this issue 2 years ago • 2 comments

As can be verified in source code, the properties Item#msgctxt and Item#msgid_plural will be initialized to null instead of undefined (https://github.com/rubenv/pofile/blob/master/lib/po.js#L279-L281). However, type undefined should remain to not break any existing code.

danielrentz avatar Feb 23 '23 07:02 danielrentz

Shouldn't the question mark be dropped when you explicitly add | undefined?

rubenv avatar Feb 24 '23 13:02 rubenv

I followed other projects here that explicitly added the "undefined" type to optional props withregards to compiler option "exactOptionalPropertyTypes", e.g. https://github.com/DefinitelyTyped/DefinitelyTyped/pull/54256

The question mark is needed if class Item should support property deletion. I think this is unusual and may be dropped, but thinking strictly it would be a breaking change.

So I would be happy to adapt the PR to remove the question marks if you like.

danielrentz avatar Feb 24 '23 14:02 danielrentz