-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.mjs
More file actions
30 lines (26 loc) · 903 Bytes
/
index.mjs
File metadata and controls
30 lines (26 loc) · 903 Bytes
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
import { parser, parserV2, parserV3 } from "./compiler/parser.mjs";
import { checker } from "./compiler/checker.mjs";
const sourceCode = `
fn("craig-string"); // throw with string vs number
function fn(a: number) {}
`;
const sourceAst = parser(sourceCode);
const errors = checker(sourceAst);
console.log("Errors for `Scenarios 1`: ", errors);
const sourceCodeV2 = `
fn("craig-string"); // throw with string vs ?
function fn(a: made_up_type) {} // throw with bad type
`;
const sourceAstV2 = parserV2(sourceCodeV2);
const errorsV2 = checker(sourceAstV2);
console.log("Errors for `Scenarios 2`: ", errorsV2);
const sourceCodeV3 = `
interface Person {
name: string;
}
fn({nam: "craig"}); // throw with "nam" vs "name"
function fn(a: Person) {}
`;
const sourceAstV3 = parserV3(sourceCodeV3);
const errorsV3 = checker(sourceAstV3);
console.log("Errors for `Scenarios 3`: ", errorsV3);