-
Notifications
You must be signed in to change notification settings - Fork 251
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
Don't mutate declare
types
#656
Comments
@JoshuaKGoldberg thanks for reporting this issue. Just to be sure: you do want to mutate |
That's a great point - I should have done that. |
Yeah, but you're point still is valid. It doesn't make sense to mutate declare statements 👍 |
We decided we will not fix this for now due to the fact that it can be fixed in your case by removing the If someone in the future has this same issue, but with regular ts files. Please ask us to reopen this issue! |
Just tried to set up Stryker again and hit this issue 😄. The default |
Possibly related (type decl-s are mutated): stryker mutates boolean constants in type decls, which produces false-negatives:
Haven't tested, but have suspicion, that string literal typedefs would be also mutated ( config:
Possible solutions: |
@ankhzet we're thinking behind the scenes about a "TypeCheckerPlugin". That way, we'd be able to validate mutants better. I.e. class A {
methodB(): SomeType | false { // 'false' here is mutated to 'true'
}
} When mutating Could this solve your issue? |
@nicojs checked mutations with some variations of interfaces/implementations. It seems, like:
// src
// 'false' here is mutated (also, '' isn't, for some reason), and causes false-negative ('true' argument is considered in 'should accept Truthy arguments' spec)
export const isFalsy = (param?: any): param is never | null | undefined | false | '' => {
return !param;
};
// spec
describe('TypeDecl mutation', () => {
describe('isFalsy', () => {
it('should accept Falsy arguments and return "true"', () => {
expect(isFalsy('')).toBeTruthy();
expect(isFalsy(false)).toBeTruthy();
expect(isFalsy(null)).toBeTruthy();
expect(isFalsy(undefined)).toBeTruthy();
expect(isFalsy()).toBeTruthy();
});
it('should accept Truthy arguments and return "false"', () => {
expect(isFalsy('str')).toBeFalsy();
expect(isFalsy(true)).toBeFalsy();
expect(isFalsy({})).toBeFalsy();
expect(isFalsy(1)).toBeFalsy();
});
});
}); If this is indeed a false-positive situation, I have no idea if it could be handled automatically though. Is there a way in stryker to disable mutations on certain lines/statements? |
Indeed, I understand what you're saying. This test will kill the mutant, but I don't think we should force people to write it: const foo = true;
if (isFalsy(foo)) {
(function (foo: never) { })(foo);
} We might need to skip
No not a.t.m. |
I don't think we should change type definitions directly. 👍 |
Ok, I'm reopening the issue. Anyone up for the task? I think the best way is to filter out the |
👋 I can probably take a look this week! Any tips would be appreciated 😀 |
I do believe it can be closed :) |
Ha, good catch @kmdrGroch. Thanks 😄 |
Summary
If you have a
.d.ts
file that includes adeclare module "foo" { }
, the module name ("foo"
) will be mutated during tests.Stryker config
Stryker environment
Your Environment
The text was updated successfully, but these errors were encountered: