Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

fix Use#end return type in OneOf #158

Conversation

bolasblack
Copy link
Contributor

No description provided.

@edmorley edmorley added the bug label Mar 24, 2019
@edmorley edmorley requested a review from eliperelman March 24, 2019 15:37
@eliperelman
Copy link
Member

Maybe I am just confused, but wouldn't all of the ends suffer from this?

@bolasblack
Copy link
Contributor Author

@eliperelman For example:

new Config().module
  .rule('css')
    // ...
    .use('css-loader')
      .loader('url-loader')
      .end() // <= Rule
    .end() // <= Module
    // In the above scenario, the results are in line with our expectations.

  .rule('otherStaticFiles')
    // ...
    .oneOf('default')
      // ...
      .use('url')
        .loader('url-loader')
        // ...
        .end() // <= expect OneOf, now Rule
      .end() // <= expect Rule, now Module
    .end() // <= expect Module, now Config
  .end() // <= then tsc warned `Config` have no method named `end`

  .plugin('...')

If we add a type parameter Parent to Use class:

class Use<Parent = Rule> extends ChainedMap<Parent> implements Orderable {

It mean we can specify the Parent parameter in some case, and if we didn't assigned, then Parent will be Rule (that is the current behavior)

@eliperelman
Copy link
Member

Ah, so the issue is that this particular end is vague because Use can belong to the Rule and a oneOf. 👍

@eliperelman eliperelman merged commit 66b4650 into neutrinojs:master Mar 25, 2019
@bolasblack bolasblack deleted the feature/fix-Use-interface-end-method-return-type branch March 25, 2019 16:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

3 participants