Skip to content

Commit

Permalink
Upgrade to ts@4.3, allow expectError to detect override related e…
Browse files Browse the repository at this point in the history
…rrors (#108)
  • Loading branch information
BendingBender committed May 29, 2021
1 parent 0245f59 commit f2cfca7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -40,7 +40,7 @@
"typedefinitions"
],
"dependencies": {
"@tsd/typescript": "^4.2.4",
"@tsd/typescript": "^4.3.2",
"eslint-formatter-pretty": "^4.0.0",
"globby": "^11.0.1",
"meow": "^9.0.0",
Expand Down
2 changes: 2 additions & 0 deletions source/lib/compiler.ts
Expand Up @@ -35,6 +35,8 @@ const expectErrordiagnosticCodesToIgnore = new Set<DiagnosticCode>([
DiagnosticCode.OnlyVoidFunctionIsNewCallable,
DiagnosticCode.ExpressionNotConstructable,
DiagnosticCode.NewExpressionTargetLackingConstructSignatureHasAnyType,
DiagnosticCode.MemberCannotHaveOverrideModifierBecauseItIsNotDeclaredInBaseClass,
DiagnosticCode.MemberMustHaveOverrideModifier,
]);

type IgnoreDiagnosticResult = 'preserve' | 'ignore' | Location;
Expand Down
2 changes: 2 additions & 0 deletions source/lib/interfaces.ts
Expand Up @@ -39,6 +39,8 @@ export enum DiagnosticCode {
PropertyMissingInType1ButRequiredInType2 = 2741,
NoOverloadExpectsCountOfTypeArguments = 2743,
NoOverloadMatches = 2769,
MemberCannotHaveOverrideModifierBecauseItIsNotDeclaredInBaseClass = 4113,
MemberMustHaveOverrideModifier = 4114,
NewExpressionTargetLackingConstructSignatureHasAnyType = 7009,
}

Expand Down
8 changes: 8 additions & 0 deletions source/test/fixtures/expect-error/classes/index.test-d.ts
Expand Up @@ -4,3 +4,11 @@ import {Foo} from '.';
const numberFoo = new Foo<number>();

expectError(numberFoo.bar());

expectError(class extends Foo<string> {
bar(): void {}
});

expectError(class extends Foo<string> {
override foo(): void {}
});
7 changes: 6 additions & 1 deletion source/test/fixtures/expect-error/classes/package.json
@@ -1,3 +1,8 @@
{
"name": "foo"
"name": "foo",
"tsd": {
"compilerOptions": {
"noImplicitOverride": true
}
}
}

0 comments on commit f2cfca7

Please sign in to comment.