Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const antlrCanAttachComment = ({ type }: { type: string }): boolean =>
typeof type === 'string' && type !== 'BlockComment' && type !== 'LineComment';
const canAttachComment = (node: AstNode): boolean =>
typeof node !== 'string' &&
typeof node !== 'undefined' &&
node !== undefined &&
node.kind && // Make sure it's not Location
!isComment(node);

Expand Down
4 changes: 2 additions & 2 deletions src/slang-nodes/ContractSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export class ContractSpecifiers extends SlangNode {
print(path: AstPath<ContractSpecifiers>, print: PrintFunction): Doc {
const [specifier1, specifier2] = path.map(print, 'items');

if (typeof specifier1 === 'undefined') return '';
if (specifier1 === undefined) return '';

if (typeof specifier2 === 'undefined') return [' ', specifier1];
if (specifier2 === undefined) return [' ', specifier1];

const groupId = Symbol('Slang.ContractSpecifiers.inheritance');
return printSeparatedList(
Expand Down
4 changes: 2 additions & 2 deletions src/slang-nodes/SlangNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class SlangNode {
// calculate correct loc object
if (loc.leadingOffset === 0) {
for (const childNode of childNodes) {
if (typeof childNode === 'undefined') continue;
if (childNode === undefined) continue;
const { leadingOffset, start } = childNode.loc;

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

if (loc.trailingOffset === 0) {
for (const childNode of reversedIterator(childNodes)) {
if (typeof childNode === 'undefined') continue;
if (childNode === undefined) continue;
const { trailingOffset, end } = childNode.loc;

if (end + trailingOffset === loc.end) {
Expand Down
2 changes: 1 addition & 1 deletion src/slang-printers/print-comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function printComments(
path: AstPath<StrictAstNode>,
options: ParserOptions<AstNode>
): Doc[] {
if (typeof path.node.comments === 'undefined') return [];
if (path.node.comments === undefined) return [];
return joinExisting(
line,
path.map((commentPath, index, comments: Comment[]) => {
Expand Down
4 changes: 2 additions & 2 deletions src/slang-utils/loc.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { AstNode } from '../slang-nodes/types.d.ts';

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

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