@goodbones/typescript 0.1.0-beta.1 → 0.1.0-beta.10
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/build/dts/extractor.d.ts +28 -1
- package/build/dts/extractor.d.ts.map +1 -1
- package/build/dts/index.d.ts +6 -3
- package/build/dts/index.d.ts.map +1 -1
- package/build/esm/extractor.js +353 -220
- package/build/esm/extractor.js.map +1 -1
- package/build/esm/index.js +7 -2
- package/build/esm/index.js.map +1 -1
- package/package.json +4 -4
- package/src/extractor.ts +465 -218
- package/src/index.ts +27 -3
package/src/index.ts
CHANGED
|
@@ -1,24 +1,48 @@
|
|
|
1
|
-
import type { Language } from "@goodbones/core";
|
|
1
|
+
import type { Language, SyntaxMatcher } from "@goodbones/core";
|
|
2
2
|
|
|
3
3
|
import { makeFactExtractorLive } from "./extractor.js";
|
|
4
4
|
import { makeModuleResolverLive, TYPESCRIPT } from "./resolver.js";
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export {
|
|
7
|
+
type EdgeForm,
|
|
8
|
+
factsOfText,
|
|
9
|
+
makeFactExtractorLive,
|
|
10
|
+
type ProgramBody,
|
|
11
|
+
type ReadBinding,
|
|
12
|
+
type ReadEdge,
|
|
13
|
+
type ReadExportSite,
|
|
14
|
+
type ReadFacts,
|
|
15
|
+
type ReadMemberSite,
|
|
16
|
+
readProgram,
|
|
17
|
+
sourceFactsOf,
|
|
18
|
+
type SyntaxNode,
|
|
19
|
+
} from "./extractor.js";
|
|
7
20
|
export { npmPackageOf } from "./npm-package.js";
|
|
8
21
|
export { decodeTypescriptScopeOptions, type TypescriptScopeOptions } from "./options.js";
|
|
9
22
|
export { makeModuleResolverLive, TYPESCRIPT } from "./resolver.js";
|
|
10
23
|
|
|
24
|
+
export type TypescriptLanguageOptions = {
|
|
25
|
+
// A syntax matcher for the campaigns family's `syntax` term. The pack
|
|
26
|
+
// never names one — `@goodbones/ast-grep` is what a host composes it with.
|
|
27
|
+
readonly syntax?: SyntaxMatcher | undefined;
|
|
28
|
+
};
|
|
29
|
+
|
|
11
30
|
// TypeScript, as one language pack: the parser-backed extractor and the
|
|
12
31
|
// `unrs-resolver`-backed resolver, behind the core's `Language` port. A host
|
|
13
32
|
// constructs this once, at its composition root, and hands it to `loadPolicy`;
|
|
14
33
|
// a second language is a second package shaped like this one.
|
|
15
|
-
export const typescriptLanguage = (): Language => ({
|
|
34
|
+
export const typescriptLanguage = (options: TypescriptLanguageOptions = {}): Language => ({
|
|
16
35
|
id: TYPESCRIPT,
|
|
17
36
|
extensions: [".ts", ".tsx", ".mts", ".cts"],
|
|
18
37
|
// A declaration file states types, not code; no linter visits one and no
|
|
19
38
|
// policy is written about one.
|
|
20
39
|
ignoredFiles: [/\.d\.[cm]?ts$/],
|
|
40
|
+
// A folder holding a `package.json` is a package, and its source is under
|
|
41
|
+
// `src` when it has one — the convention `infer` counts its depth from.
|
|
42
|
+
packageMarkers: ["package.json"],
|
|
43
|
+
sourceRoots: ["src"],
|
|
21
44
|
extractor: makeFactExtractorLive(),
|
|
22
45
|
fixes: ["subpath-namespace-import"],
|
|
46
|
+
...(options.syntax === undefined ? {} : { syntax: options.syntax }),
|
|
23
47
|
makeResolver: (repoRoot, scope) => makeModuleResolverLive(repoRoot, { scopes: [scope] }),
|
|
24
48
|
});
|