Merge pull request #27452 from element-hq/dbkr/multi_return_type_rule

Add code style rule for multiple return types
pull/27471/head
David Baker 2024-05-13 09:13:14 +00:00 committed by GitHub
commit 35046bb7b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -225,6 +225,12 @@ Unless otherwise specified, the following applies to all code:
} }
``` ```
37. Avoid functions whose fundamental behaviour varies with different parameter types.
Multiple return types are fine, but if the function's behaviour is going to change significantly,
have two separate functions. For example, `SDKConfig.get()` with a string param which returns the
type according to the param given is ok, but `SDKConfig.get()` with no args returning the whole
config object would not be: this should just be a separate function.
## React ## React
Inheriting all the rules of TypeScript, the following additionally apply: Inheriting all the rules of TypeScript, the following additionally apply: