Skip to content

Commit 282899a

Browse files
BendingBenderSamVerschueren
authored andcommitted
Ignore required parameter count errors with expectError (#27)
1 parent 17e3eb2 commit 282899a

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

source/lib/compiler.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const diagnosticCodesToIgnore = new Set<DiagnosticCode>([
2020
DiagnosticCode.ArgumentTypeIsNotAssignableToParameterType,
2121
DiagnosticCode.PropertyDoesNotExistOnType,
2222
DiagnosticCode.CannotAssignToReadOnlyProperty,
23-
DiagnosticCode.TypeIsNotAssignableToOtherType
23+
DiagnosticCode.TypeIsNotAssignableToOtherType,
24+
DiagnosticCode.GenericTypeRequiresTypeArguments,
25+
DiagnosticCode.ExpectedArgumentsButGotOther
2426
]);
2527

2628
/**

source/lib/interfaces.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ export interface Context {
2121

2222
export enum DiagnosticCode {
2323
AwaitIsOnlyAllowedInAsyncFunction = 1308,
24+
GenericTypeRequiresTypeArguments = 2314,
2425
TypeIsNotAssignableToOtherType = 2322,
2526
PropertyDoesNotExistOnType = 2339,
2627
ArgumentTypeIsNotAssignableToParameterType = 2345,
27-
CannotAssignToReadOnlyProperty = 2540
28+
CannotAssignToReadOnlyProperty = 2540,
29+
ExpectedArgumentsButGotOther = 2554
2830
}
2931

3032
export interface Diagnostic {

source/test/fixtures/expect-error/values/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ export default one;
88
export const foo: {readonly bar: string};
99

1010
export function hasProperty(property: {name: string}): boolean;
11+
12+
export interface Options<T> {}

source/test/fixtures/expect-error/values/index.test-d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {expectError} from '../../../..';
2-
import {foo, hasProperty} from '.';
2+
import {default as one, foo, hasProperty, Options} from '.';
33

44
expectError<string>(1);
55
expectError<string>('fo');
@@ -16,3 +16,7 @@ try {
1616
} catch {}
1717

1818
expectError(hasProperty({name: 1}));
19+
20+
expectError(one(1));
21+
expectError(one(1, 2, 3));
22+
expectError({} as Options);

0 commit comments

Comments
 (0)