• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / js-slang / 4496546924

pending completion
4496546924

push

github

GitHub
Add Full TypeScript Chapter (#1376)

3262 of 4252 branches covered (76.72%)

Branch coverage included in aggregate %.

60 of 60 new or added lines in 8 files covered. (100.0%)

10198 of 11836 relevant lines covered (86.16%)

130702.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/parser/parser.ts
1
import { Program } from 'estree'
2

3
import { Context } from '..'
4
import { Chapter, Variant } from '../types'
61✔
5
import { FullJSParser } from './fullJS'
61✔
6
import { FullTSParser } from './fullTS'
61✔
7
import { SourceParser } from './source'
61✔
8
import { SourceTypedParser } from './source/typed'
61✔
9
import { AcornOptions, Parser } from './types'
10

11
export function parse<TOptions extends AcornOptions>(
61✔
12
  programStr: string,
13
  context: Context,
14
  options?: Partial<TOptions>,
15
  throwOnError?: boolean
16
): Program | null {
17
  let parser: Parser<TOptions>
18
  switch (context.chapter) {
4,204✔
19
    case Chapter.FULL_JS:
4,204!
20
      parser = new FullJSParser()
22✔
21
      break
22✔
22
    case Chapter.FULL_TS:
23
      parser = new FullTSParser()
×
24
      break
×
25
    default:
26
      switch (context.variant) {
4,182✔
27
        case Variant.TYPED:
4,182✔
28
          parser = new SourceTypedParser(context.chapter, context.variant)
92✔
29
          break
92✔
30
        default:
31
          parser = new SourceParser(context.chapter, context.variant)
4,090✔
32
      }
33
  }
34

35
  const ast: Program | null = parser.parse(programStr, context, options, throwOnError)
4,204✔
36
  const validAst: boolean = !!ast && parser.validate(ast, context, throwOnError)
4,204✔
37

38
  return validAst ? ast : null
4,204✔
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc