3 ms·
Yes, the requirement that static constructors are used makes this substantially less ergonomic than it would otherwise be for the reasons you point out. Some o
by rbalicki 3y ago
Yes, the requirement that static constructors are used makes this substantially less ergonomic than it would otherwise be for the reasons you point out.
Some of the React hooks in Isograph use this pattern, and as a result the constructor returns an instance in an invalid state: https://github.com/isographlabs/isograph/blob/1a8182355ac9d121318213d1d8591480d5c1da12/libs/isograph-react-disposable-state/src/CacheItem.ts#L69 https://github.com/isographlabs/isograph/blob/1a8182355ac9d1...
I'm of the opinion that this is a paper cut worth stomaching in favor of the addition of an idiom that provides genuine safety. The type for the class and the static conductor (ie a free function) could be exposed, but the class itself could be hidden.