Skip to content

Commit e7165db

Browse files
authored
removing all typeof x === 'undefined' in favour of x === undefined (#1248)
1 parent a2f4ee3 commit e7165db

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const antlrCanAttachComment = ({ type }: { type: string }): boolean =>
5555
typeof type === 'string' && type !== 'BlockComment' && type !== 'LineComment';
5656
const canAttachComment = (node: AstNode): boolean =>
5757
typeof node !== 'string' &&
58-
typeof node !== 'undefined' &&
58+
node !== undefined &&
5959
node.kind && // Make sure it's not Location
6060
!isComment(node);
6161

src/slang-nodes/ContractSpecifiers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export class ContractSpecifiers extends SlangNode {
2828
print(path: AstPath<ContractSpecifiers>, print: PrintFunction): Doc {
2929
const [specifier1, specifier2] = path.map(print, 'items');
3030

31-
if (typeof specifier1 === 'undefined') return '';
31+
if (specifier1 === undefined) return '';
3232

33-
if (typeof specifier2 === 'undefined') return [' ', specifier1];
33+
if (specifier2 === undefined) return [' ', specifier1];
3434

3535
const groupId = Symbol('Slang.ContractSpecifiers.inheritance');
3636
return printSeparatedList(

src/slang-nodes/SlangNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class SlangNode {
126126
// calculate correct loc object
127127
if (loc.leadingOffset === 0) {
128128
for (const childNode of childNodes) {
129-
if (typeof childNode === 'undefined') continue;
129+
if (childNode === undefined) continue;
130130
const { leadingOffset, start } = childNode.loc;
131131

132132
if (start - leadingOffset === loc.start) {
@@ -139,7 +139,7 @@ export class SlangNode {
139139

140140
if (loc.trailingOffset === 0) {
141141
for (const childNode of reversedIterator(childNodes)) {
142-
if (typeof childNode === 'undefined') continue;
142+
if (childNode === undefined) continue;
143143
const { trailingOffset, end } = childNode.loc;
144144

145145
if (end + trailingOffset === loc.end) {

src/slang-printers/print-comments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function printComments(
2020
path: AstPath<StrictAstNode>,
2121
options: ParserOptions<AstNode>
2222
): Doc[] {
23-
if (typeof path.node.comments === 'undefined') return [];
23+
if (path.node.comments === undefined) return [];
2424
return joinExisting(
2525
line,
2626
path.map((commentPath, index, comments: Comment[]) => {

src/slang-utils/loc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { AstNode } from '../slang-nodes/types.d.ts';
22

33
export function locStart(node: AstNode): number {
4-
if (typeof node === 'string' || typeof node === 'undefined') return -1;
4+
if (typeof node === 'string' || node === undefined) return -1;
55
return node.loc.start;
66
}
77

88
export function locEnd(node: AstNode): number {
9-
if (typeof node === 'string' || typeof node === 'undefined') return -1;
9+
if (typeof node === 'string' || node === undefined) return -1;
1010
return node.loc.end;
1111
}

0 commit comments

Comments
 (0)