Skip to content

The parameter names and positions of an overridden method must match its ancestor's #52

@mlhaufe

Description

@mlhaufe

There is no native API in the current version of ECMAScript (ECMAScript 2020) for accessing function parameters. There is only someFunction.length which is also imperfect. The alternative is to parse the string representation of the function. A regular expression is no longer sufficient though due to the new patterns and default values allowed in method declarations. Example:

class Foo {
  method({size = 'big', coords = {x: 0, y: 0}, radius = 25} = {}){ ... }
}

Sadly there is no native parser in the language either. The closest is the SpiderMonkey specific extension Reflect.parse(...) which is not currently on the standards track. The 3rd party option is the acorn library. This would effectively double the size of the contracts library or more if used...

Extending the Babel or TypeScript compiler is out of scope as the desire is to keep this library standards compliant and not extend the language itself

This should be a deferred requirement...

Metadata

Metadata

Assignees

Labels

feature/overrideThe override decoratorrequirementAn assertion or property that must be fulfilled

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions