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
10 changes: 10 additions & 0 deletions src/parser/__tests__/__snapshots__/fullTS.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Node {
Node {
"declarations": Array [
Node {
"definite": false,
"end": 72,
"id": Node {
"decorators": Array [],
"end": 68,
"loc": SourceLocation {
"end": Position {
Expand All @@ -22,6 +24,7 @@ Node {
},
},
"name": "x",
"optional": false,
"start": 51,
"type": "Identifier",
"typeAnnotation": Node {
Expand Down Expand Up @@ -57,6 +60,7 @@ Node {
"start": 54,
"type": "TSTypeReference",
"typeName": Node {
"decorators": Array [],
"end": 68,
"loc": SourceLocation {
"end": Position {
Expand All @@ -71,8 +75,10 @@ Node {
},
},
"name": "StringOrNumber",
"optional": false,
"start": 54,
"type": "Identifier",
"typeAnnotation": undefined,
},
},
},
Expand Down Expand Up @@ -112,6 +118,7 @@ Node {
"type": "VariableDeclarator",
},
],
"declare": false,
"end": 73,
"kind": "const",
"loc": SourceLocation {
Expand All @@ -131,6 +138,9 @@ Node {
},
],
"end": 78,
"extra": Object {
"topLevelAwait": false,
},
"interpreter": null,
"loc": SourceLocation {
"end": Position {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/fullTS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class FullTSParser implements Parser<AcornOptions> {
errorRecovery: throwOnError ?? true
})

if (ast.errors.length) {
if (ast.errors?.length) {
ast.errors
.filter(error => error instanceof SyntaxError)
.forEach(error => {
Expand Down
4 changes: 2 additions & 2 deletions src/parser/source/typed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { parse as babelParse } from '@babel/parser'
import { Options as AcornOptions } from 'acorn'
import { Program } from 'estree'

import { SourceParser } from '..'
import { Context } from '../../..'
import { DEFAULT_ECMA_VERSION } from '../../../constants'
import * as TypedES from '../../../typeChecker/tsESTree'
Expand All @@ -12,7 +13,6 @@ import {
defaultBabelOptions,
positionToSourceLocation
} from '../../utils'
import { SourceParser } from '..'
import TypeParser from './typeParser'
import { transformBabelASTToESTreeCompliantAST } from './utils'

Expand Down Expand Up @@ -51,7 +51,7 @@ export class SourceTypedParser extends SourceParser {
errorRecovery: throwOnError ?? true
})

if (ast.errors.length) {
if (ast.errors?.length) {
ast.errors
.filter(error => error instanceof SyntaxError)
.forEach(error => {
Expand Down
22 changes: 22 additions & 0 deletions src/typeChecker/__tests__/__snapshots__/source1Typed.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Node {
Node {
"declarations": Array [
Node {
"definite": false,
"end": 56,
"id": Node {
"decorators": Array [],
"end": 52,
"loc": SourceLocation {
"end": Position {
Expand All @@ -22,8 +24,10 @@ Node {
},
},
"name": "x",
"optional": false,
"start": 51,
"type": "Identifier",
"typeAnnotation": undefined,
},
"init": Node {
"end": 56,
Expand Down Expand Up @@ -60,6 +64,7 @@ Node {
"type": "VariableDeclarator",
},
],
"declare": false,
"end": 57,
"kind": "const",
"loc": SourceLocation {
Expand All @@ -79,6 +84,9 @@ Node {
},
],
"end": 62,
"extra": Object {
"topLevelAwait": false,
},
"interpreter": null,
"loc": SourceLocation {
"end": Position {
Expand All @@ -104,8 +112,10 @@ Node {
Node {
"declarations": Array [
Node {
"definite": false,
"end": 29,
"id": Node {
"decorators": Array [],
"end": 25,
"loc": SourceLocation {
"end": Position {
Expand All @@ -120,6 +130,7 @@ Node {
},
},
"name": "x1",
"optional": false,
"start": 6,
"type": "Identifier",
"typeAnnotation": Node {
Expand Down Expand Up @@ -228,6 +239,7 @@ Node {
"type": "VariableDeclarator",
},
],
"declare": false,
"end": 30,
"kind": "const",
"loc": SourceLocation {
Expand All @@ -248,8 +260,10 @@ Node {
Node {
"declarations": Array [
Node {
"definite": false,
"end": 68,
"id": Node {
"decorators": Array [],
"end": 53,
"loc": SourceLocation {
"end": Position {
Expand All @@ -264,6 +278,7 @@ Node {
},
},
"name": "x2",
"optional": false,
"start": 43,
"type": "Identifier",
"typeAnnotation": Node {
Expand Down Expand Up @@ -302,6 +317,7 @@ Node {
},
},
"init": Node {
"decorators": Array [],
"end": 58,
"loc": SourceLocation {
"end": Position {
Expand All @@ -316,8 +332,10 @@ Node {
},
},
"name": "x1",
"optional": false,
"start": 56,
"type": "Identifier",
"typeAnnotation": undefined,
},
"loc": SourceLocation {
"end": Position {
Expand All @@ -335,6 +353,7 @@ Node {
"type": "VariableDeclarator",
},
],
"declare": false,
"end": 69,
"kind": "const",
"loc": SourceLocation {
Expand All @@ -354,6 +373,9 @@ Node {
},
],
"end": 74,
"extra": Object {
"topLevelAwait": false,
},
"interpreter": null,
"loc": SourceLocation {
"end": Position {
Expand Down
Loading
Loading