Skip to content

Commit

Permalink
fix: FD-94583 fix override keyword causing failures (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfangrad authored Oct 7, 2022
1 parent 3f43483 commit 49ff7a9
Show file tree
Hide file tree
Showing 4 changed files with 1,133 additions and 1,899 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16.x
- run: yarn install --frozen-lockfile
- run: yarn test:ci
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
},
"dependencies": {
"@types/lodash": "^4.14.168",
"@types/node": "^15.0.2",
"@types/node": "^15.6.0",
"@types/yargs": "^16.0.1",
"cosmiconfig": "^7.0.0",
"lodash": "^4.17.21",
"ts-morph": "^10.0.2",
"ts-morph": "^15.1.0",
"yargs": "^17.0.1"
},
"devDependencies": {
"@types/jest": "^26.0.23",
"husky": "^6.0.0",
"jest": "^26.6.3",
"jest": "^28.1.3",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"semantic-release": "^17.4.2",
"ts-jest": "^26.5.5",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"
"ts-jest": "^28.0.7",
"ts-node": "^10.3.0",
"typescript": "^4.5.5"
}
}
56 changes: 51 additions & 5 deletions src/__test__/analyze.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jest.mock("../config.ts");

describe("analyze", () => {
interface IResult {
class: string;
member: string;
reason: string;
class: string | undefined;
member: string | undefined;
reason: string | undefined;
}
const assertResults = (results: IOffendingMembers[], expected: IResult[]) => {
const received: IResult[] = results.map((entry) => ({
Expand All @@ -32,7 +32,7 @@ describe("analyze", () => {
`
class A {
x = 1,
fn() {
return this.x;
}
Expand Down Expand Up @@ -139,7 +139,7 @@ describe("analyze", () => {
y = 1;
}
console.log(new GrandParent().x, new Parent().y);
// should ignore x and y
class Child extends Parent {
x = 2;
Expand Down Expand Up @@ -278,4 +278,50 @@ describe("analyze", () => {
});
assertResults(analyze(project), []);
});

it("should not flag properties with the override keyword", () => {
const project = new Project({ useInMemoryFileSystem: true });
project.createSourceFile(
"Setting.ts",
`
export class Setting {
get value() {
return "1";
}
async assignment() {
return Promise.resolve();
}
}
`
);

project.createSourceFile(
"OverrideSetting.ts",
`
import { Setting } from "./Setting";
export class OverrideSetting extends Setting {
override get value() {
return "1";
}
override async assignment() {
return Promise.resolve();
}
}
`
);

project.createSourceFile(
"use.ts",
`
import { OverrideSetting } from "./OverrideSetting";
const s = new OverrideSetting();
console.log(s.value);
console.log(s.assignment());
`
);

assertResults(analyze(project), []);
});
});
Loading

0 comments on commit 49ff7a9

Please sign in to comment.