LinkedSoftwareDependencies / Components.js

🧩 A semantic dependency injection framework
https://componentsjs.readthedocs.io/
Other
41 stars 6 forks source link

Error message of generics with default value is not clear #146

Open jitsedesmet opened 2 weeks ago

jitsedesmet commented 2 weeks ago

Issue type:


Description:

I had an issue where I had a class that was not generic, but should have a generic type with default value. This case, where it apparently needed to have this generic was hard too discover because the error message is not very clear.

For example, when I have a class like:

export abstract class ActorExpressionEvaluatorFactory extends

that should have a generic type like:

export abstract class ActorExpressionEvaluatorFactory<TS = undefined> extends

I would get the exception:

error: Detected fatal error. Generated 'componentsjs-error-state.json' with more information.
      TypeError: Cannot read properties of undefined (reading 'term')
          at ParameterPropertyHandlerRange.hasType (/home/jitsedesmet/Documents/werken/ugent/comunica/node_modules/componentsjs/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js:418:19)
          at typeTypeValidator (/home/jitsedesmet/Documents/werken/ugent/comunica/node_modules/componentsjs/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js:435:26)
          at GenericsContext.mergeRanges (/home/jitsedesmet/Documents/werken/ugent/comunica/node_modules/componentsjs/lib/preprocess/GenericsContext.js:123:14)
          at ParameterPropertyHandlerRange.hasType (/home/jitsedesmet/Documents/werken/ugent/comunica/node_modules/componentsjs/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js:469:60)
          at ParameterPropertyHandlerRange.hasType (/home/jitsedesmet/Documents/werken/ugent/comunica/node_modules/componentsjs/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js:488:42)
          at ParameterPropertyHandlerRange.hasType (/home/jitsedesmet/Documents/werken/ugent/comunica/node_modules/componentsjs/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js:488:42)
          at ParameterPropertyHandlerRange.hasValueType (/home/jitsedesmet/Documents/werken/ugent/comunica/node_modules/componentsjs/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js:86:47)
          at ParameterPropertyHandlerRange.hasValueType (/home/jitsedesmet/Documents/werken/ugent/comunica/node_modules/componentsjs/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js:291:38)
          at /home/jitsedesmet/Documents/werken/ugent/comunica/node_modules/componentsjs/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js:104:18
          at Array.map (<anonymous>)

(Sorry if this description isn't very clear)


Environment:

Crash log:

rubensworks commented 2 weeks ago

For reference, this issue may have been introduced in https://github.com/LinkedSoftwareDependencies/Components.js/commit/5edd29449537db07f3a732efbb0d95f4fc96d255