/
3.9.spec.ts
38 lines (33 loc) · 963 Bytes
/
3.9.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
describe('3.9', (): void => {
describe('@ts-expect-error', (): void => {
it('should expect error', (): void => {
// @ts-expect-error number & string
console.log(47 * 'octopus');
});
it('will fail if expect error and does not error', (): void => {
// @ts -expect-error note had to insert space so continue to build
console.log(1 + 1);
});
});
describe('stricter checks on intersections and optional properties', (): void => {
interface A {
a: number; // notice this is 'number'
}
interface B {
b: string;
}
interface C {
a?: boolean; // notice this is 'boolean'
b: string;
}
type X = A & B;
type Y = C;
it('should error with A & B incompatible with type C', (): void => {
const x: X = { a: 10, b: 'test' };
let y: Y = { a: false, b: 'no' };
y.a = true;
// @ts-expect-error X and Y are incompatible
y = x;
});
});
});