/
typescript.example.ts
33 lines (29 loc) · 1.24 KB
/
typescript.example.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
// Use --report-unused-disable-directives to validate errors
/* eslint-disable no-unused-expressions */
/* eslint-disable @typescript-eslint/no-unused-expressions */
void (async () => {
await 1; // eslint-disable-line @typescript-eslint/await-thenable
await (function () {})(); // eslint-disable-line @typescript-eslint/await-thenable, @typescript-eslint/no-empty-function
await (async function () {})(); // eslint-disable-line @typescript-eslint/no-empty-function
})();
(
str: string,
num: number,
wut: any, // eslint-disable-line @typescript-eslint/no-explicit-any
maybeStr?: string,
maybeNum?: number,
maybeObj?: Record<string, unknown>
) => {
// strict boolean checks are required for everything except strings
str ? 0 : 1; // allowed
maybeStr ? 0 : 1; // allowed
num ? 0 : 1; // eslint-disable-line @typescript-eslint/strict-boolean-expressions
num == 0 ? 0 : 1; // eslint-disable-line @foxglove/strict-equality
num === 0 ? 0 : 1; // allowed
maybeNum ? 0 : 1; // eslint-disable-line @typescript-eslint/strict-boolean-expressions
maybeObj ? 0 : 1; // allowed
wut ? 0 : 1; // eslint-disable-line @typescript-eslint/strict-boolean-expressions
wut == null ? 0 : 1; // allowed
};
// keep isolatedModules happy
export default {};