ericelliott/rtype

Allow left-associativity for the defaults

Closed this issue · 8 comments

interface Options {
             '' = body: ArrayBuffer | Blob | Document | FormData | String,
  'same-origin' = credentials: 'include' | 'omit' | 'same-origin',
                  headers: Headers | Object,
                  mediaType: String,
          'GET' = method: /^(delete|get|head|patch|post|put)$/i,
  'same-origin' = mode: 'cors' | 'no-cors' | 'same-origin',
                  parameters: URLSearchParams | Object | String,
                  responseType: 'text' | 'json' | 'blob' | 'document' | 'arraybuffer' | 'formdata',
                  timeout: ℕ,
  location.href = url: String
}

As you can see it helps for the readability: it's way easier to parse visually.

Can't do this. It's not compatible with the JavaScript spec, and remember, the core design goal is to make this syntax as intuitive as possible for people who already know JS.

@ericelliott It's already not JS compatible to have the default inside an object so I don't see how it would hurt to allow it to be bidirectional.
IMO you closed this too fast; it notably improves the readability.

@Mouvedia It is with object destructuring, which is the source inspiration for the current syntax.

Also, it's just your opinion that it improves readability. Due to existing familiarity with the destructuring syntax, I would find this extremely confusing, particularly in the context of a function signature declaration.

Sorry for closing so fast. Not trying to be rude, just a bit busy.

Keep in mind, this syntax is already decided, and already in use in a lot of OSS docs. =)

@ericelliott RE: destructuring, I never saw the = being used on that side of the :, always after.

In destructuring, the : is used as a property selector. The = always immediately follows the variable name. Our syntax follows compatible convention, and there would have to be a very compelling reason to change it. One person saying something else is more readable is not adequate justification.

It depends on our priority, if it's tooling then forget about it. But if it's documentation for humans, I think that my proposal was an enhancement.

One person saying something else is more readable is not adequate justification.