-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Operations Layer
Our operations defines a set of aspects that describe some behavior or functionality that is shared, but not via inheritance. With typescript we can take something like this:
Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
class FindOp {}
defineAspects(FindOp, [EXPLAINABLE])
And create this:
Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
interface Explainable { explainable: boolean; } class FindOp implements Explainable { explainable = true }
This is a simple example with just a boolean prop but the idea is there, then you can have a type guard function
Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
function isExplainable(op: any): op is Explainable { return 'explainable' in op }
Which would replace our current hasAspect check, but the benefit is that typescript can provide type completion to the op variable in this case. So for the example of Explainable, there could be a required instance method that builds the explain options / document.
As part of this work we should do this for each aspect.