-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is the TypeScript type definition wrong? #1005
Comments
Just to emphasize, if you move this to a lint rule where you can express yourself more dynamically you will keep your type definitions small and much more maintainable. |
Agreed. In hindsight, it was not worth all the bloat, but it wasn't clear at the time how verbose it would turn out. I don't think anyone would do
I think we should wait on typescript-eslint-parser. We don't want to recreate all of our rules in another linter. |
IMO we should change the runtime so you can't do these silly combinations. Having a stricter TS definition in anticipation of that change seems fine to me. |
@novemberborn I'm having trouble imagining how the logic for that would work in Since you define chainable methods like this: const chainableMethods = {
foo: {foo: true},
notFoo: {foo: false},
bar: {bar: true},
both: {foo: true, bar: true}
} I think it's totally reasonable to have a scenario like: const fn = optionChain({
broadOption: { foo: true, bar: true, baz: true },
refinement: { bar: false }
}, ...);
fn.broadOption.refinement(...); Anything else you'd be looking up which options are set by which method chains and eliminate them based on that which could just be a really confusing result. The API that exists today makes a ton of sense. I wouldn't change it because you want to enforce a particular code style that people are going to naturally follow regardless. It places a maintenance burden on the type definitions which just makes them impossible to contribute to. |
@thejameskyle if I'm not mistaken, currently our |
Yeah it does allow that, but you're suggesting a change that impacts more than just that scenario which probably never happens in the real world anyways– and even if it did happen it would work fine. |
There's also a few things missing, in test.beforeEach/afterEach the param "implementation" (callback) should be as far as I understand a ContextualTest so it provides you with a 'context'; this is preventing me from upgrading to 0.16. Also something that would be nice to have is a before/after[Each] 'always' which is completely missing from the picture and which I guess would have to be added to every namespace that allows it. Is anyone still working on this? Is there any way I can contribute? |
On mobile now so hard to check, but And what is missing from the definition? |
I see that the following questions have been discussed:
The only reason against 1 was that it could break other usages of I think that everyone agrees that if the answer for 1 is yes, then it is also yes for question 2. Otherwise, the TS definitions block constructs that are 'valid' at runtime. Though one could argue that My ideal solution would be that AVA disallowed these silly combinations. If the validation logic could be exposed somehow to the TS generation script, then the TS definition will be automatically up to date (most times). The generation script already gets the list of all modifiers from the AVA source code, so when a new modifier is added it will automatically be added to the type definitions. |
I think I'll respond to all of that by saying please don't add complexity for complexity's sake when there is no noticeable positive impact to anyone. Enforcing this means: Cons:
Pros:
|
I assume we're using @avajs/core? |
@novemberborn I agree. Would be nice to limit it at runtime too. Maybe something that could be added to |
That, or use something else. Though I suspect @jamestalmage wrote |
Opened #1182 to continue the conversation of which combinations are actually supported by AVA. |
As follow-up of a discussion started in #986, is the TypeScript definition wrong?
The definition is quite huge, ~1200 lines. The main reason for this is because it prevents TS users to do things like
test.serial.serial
ortest.before.after
, etc. But as noted by @thejameskyle, this isn't really representing the runtime structure of AVA.So although it looks weird and nobody should do it, it's perfectly possible and maybe shouldn't be restricted by the type definition?
These things should/can be prevented by the AVA ESLint rule. This means off course, we should create a AVA TSLint rule as well.
Just wanted to start the discussion over here. Everybody that has useful insights, feedback or whatever, feel free to chime in.
// @ivogabe @sindresorhus @novemberborn @jamestalmage
The text was updated successfully, but these errors were encountered: