Skip to content

Commit 0b5777b

Browse files
BendingBenderSamVerschueren
authored andcommitted
Ignore diagnostic code 2322 in expectError statements (#22)
1 parent 47e5c17 commit 0b5777b

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

source/lib/compiler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const ignoredDiagnostics = new Set<number>([
1919
const diagnosticCodesToIgnore = new Set<DiagnosticCode>([
2020
DiagnosticCode.ArgumentTypeIsNotAssignableToParameterType,
2121
DiagnosticCode.PropertyDoesNotExistOnType,
22-
DiagnosticCode.CannotAssignToReadOnlyProperty
22+
DiagnosticCode.CannotAssignToReadOnlyProperty,
23+
DiagnosticCode.TypeIsNotAssignableToOtherType
2324
]);
2425

2526
/**

source/lib/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface Context {
2121

2222
export enum DiagnosticCode {
2323
AwaitIsOnlyAllowedInAsyncFunction = 1308,
24+
TypeIsNotAssignableToOtherType = 2322,
2425
PropertyDoesNotExistOnType = 2339,
2526
ArgumentTypeIsNotAssignableToParameterType = 2345,
2627
CannotAssignToReadOnlyProperty = 2540

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ declare const one: {
44
};
55

66
export default one;
7+
8+
export const foo: {readonly bar: string};
9+
10+
export function hasProperty(property: {name: string}): boolean;
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import {expectError} from '../../../..';
2+
import {foo, hasProperty} from '.';
23

34
expectError<string>(1);
45
expectError<string>('fo');
56

6-
const foo: {readonly bar: string} = {
7-
bar: 'baz'
8-
};
9-
107
expectError(foo.bar = 'quux');
118
expectError(foo.quux);
129

@@ -17,3 +14,5 @@ try {
1714
expectError(foo.quux);
1815
}
1916
} catch {}
17+
18+
expectError(hasProperty({name: 1}));

source/test/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ test('expectError for values', async t => {
229229
t.true(diagnostics.length === 1);
230230

231231
t.true(diagnostics[0].column === 0);
232-
t.true(diagnostics[0].line === 4);
232+
t.true(diagnostics[0].line === 5);
233233
t.true(diagnostics[0].message === 'Expected an error, but found none.');
234234
t.true(diagnostics[0].severity === 'error');
235235
});

0 commit comments

Comments
 (0)