Skip to content

Commit

Permalink
Ignore "cannot assign to read-only property" errors with expectError
Browse files Browse the repository at this point in the history
  • Loading branch information
BendingBender committed Mar 17, 2019
1 parent f552237 commit 2f5ea25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion source/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ const extractExpectErrorRanges = (sourceFile: SourceFile) => {

const diagnosticCodesToIgnore = [
DiagnosticCode.ArgumentTypeIsNotAssignableToParameterType,
DiagnosticCode.PropertyDoesNotExistOnType
DiagnosticCode.PropertyDoesNotExistOnType,
DiagnosticCode.CannotAssignToReadOnlyProperty
];

/**
Expand Down
3 changes: 2 additions & 1 deletion source/lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export interface Context {
export enum DiagnosticCode {
AwaitIsOnlyAllowedInAsyncFunction = 1308,
PropertyDoesNotExistOnType = 2339,
ArgumentTypeIsNotAssignableToParameterType = 2345
ArgumentTypeIsNotAssignableToParameterType = 2345,
CannotAssignToReadOnlyProperty = 2540
}

export interface Diagnostic {
Expand Down
3 changes: 2 additions & 1 deletion source/test/fixtures/expect-error/values/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import {expectError} from '../../../..';
expectError<string>(1);
expectError<string>('fo');

const foo = {
const foo: {readonly bar: string} = {
bar: 'baz'
};

expectError(foo.bar = 'quux');
expectError(foo.quux);

0 comments on commit 2f5ea25

Please sign in to comment.