@noldova/context.parsers.typescript 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# noldova.context.parsers.typescript
|
|
2
|
+
|
|
3
|
+
A TypeScript parser. It turns TypeScript source, or declaration files, into a
|
|
4
|
+
syntax tree with source spans and reports syntax and grammar errors as
|
|
5
|
+
diagnostics, with TypeScript's codes and messages where TypeScript has them. It
|
|
6
|
+
recovers from errors, so a broken file still yields a tree. Name binding and
|
|
7
|
+
type checking are not part of it.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @noldova/context.parsers.typescript
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { TypeScriptParser } from "@noldova/context.parsers.typescript";
|
|
19
|
+
|
|
20
|
+
const result = TypeScriptParser.parse("value + 1;", "example.ts");
|
|
21
|
+
result.rootNode.children.length; // 1
|
|
22
|
+
result.diagnostics.length; // 0
|
|
23
|
+
|
|
24
|
+
const broken = TypeScriptParser.parse("let x = ;", "broken.ts");
|
|
25
|
+
broken.diagnostics.map(t => `${t.code.displayText}: ${t.message.text}`); // Its syntax errors.
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Regular-expression literals are parsed with `@noldova/context.parsers.regex`,
|
|
29
|
+
and their diagnostics appear among the file's. The declaration file
|
|
30
|
+
`api/index.d.ts` documents every member with its contract and examples.
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT; see `LICENSE`. The diagnostic messages come from the TypeScript compiler,
|
|
35
|
+
under the Apache License 2.0 in `THIRD-PARTY-NOTICES.txt`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/context.parsers.typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "api/index.js",
|
|
6
6
|
"types": "api/index.d.ts",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"registry": "https://registry.npmjs.org/"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@noldova/context.core": "0.0.
|
|
23
|
-
"@noldova/context.diagnostics": "0.0.
|
|
24
|
-
"@noldova/context.parsers": "0.0.
|
|
25
|
-
"@noldova/context.parsers.regex": "0.0.
|
|
26
|
-
"@noldova/context.text": "0.0.
|
|
22
|
+
"@noldova/context.core": "0.0.3",
|
|
23
|
+
"@noldova/context.diagnostics": "0.0.3",
|
|
24
|
+
"@noldova/context.parsers": "0.0.3",
|
|
25
|
+
"@noldova/context.parsers.regex": "0.0.3",
|
|
26
|
+
"@noldova/context.text": "0.0.3"
|
|
27
27
|
}
|
|
28
28
|
}
|