react-flow-designer icon indicating copy to clipboard operation
react-flow-designer copied to clipboard

New API syntaxic sugar

Open sgendre opened this issue 7 years ago • 1 comments

About the brand new stronger type checking going with the new API, I think it might be interesting to

  • have named functions for

throwTypeError('Immutable.Map', map, 'map'); => throwImmutableMapTypeError(map) throwTypeError('PositionRecord', position, 'position', 'Position'); => throwPositionTypeError(position) etc

  • about the use of that function, we can try to be consistent about throwing for early exit for both portType checking and string type checking of the key eg to improve: https://github.com/Talend/react-flow-designer/blob/91bd0b6a2f7de581155883ef461a4cd6e16634e8/src/api/port/port.js#L112

  • throwInDev will require a UT to explicit that it can take either a string or a new TypeError(..)

those enhancement might help us to have concise and stronger code :)

sgendre avatar Aug 29 '18 09:08 sgendre

There is no duplicate use of a throwTypeError in the code base, yet it is now possible to create such function via partial application of throwTypeError

acateland avatar Aug 30 '18 11:08 acateland