1 | import type { Assembly } from '@jsii/spec';
|
2 | import * as ts from 'typescript';
|
3 | /**
|
4 | * Additional options that may be provided to the symbolIdentifier.
|
5 | */
|
6 | interface SymbolIdOptions {
|
7 | /**
|
8 | * The assembly that the symbol is found in.
|
9 | * This is used to provide the correct root directory
|
10 | * as specified in the assembly metadata. In turn,
|
11 | * the root directory is used to ensure that the
|
12 | * symbolId comes from source code and not compiled code.
|
13 | */
|
14 | readonly assembly?: Assembly;
|
15 | }
|
16 | /**
|
17 | * Return a symbol identifier for the given symbol
|
18 | *
|
19 | * The symbol identifier identifies a TypeScript symbol in a source file inside
|
20 | * a package. We can use this to map between jsii entries in the manifest, and
|
21 | * entities in the TypeScript source code.
|
22 | *
|
23 | * Going via symbol id is the only way to identify symbols in submodules. Otherwise,
|
24 | * all the TypeScript compiler sees is:
|
25 | *
|
26 | * ```
|
27 | * /my/package/lib/source/directory/dist.js <containing> MyClass
|
28 | * ```
|
29 | *
|
30 | * And there's no way to figure out what submodule name
|
31 | * `lib/source/directory/dist` is exported as.
|
32 | *
|
33 | * The format of a symbol id is:
|
34 | *
|
35 | * ```
|
36 | * relative/source/file:Name.space.Class[#member]
|
37 | * ```
|
38 | *
|
39 | * We used to build this identifier ourselves. Turns out there was a built-in
|
40 | * way to get pretty much the same, by calling `typeChecker.getFullyQualifiedName()`.
|
41 | * Whoops ^_^ (this historical accident is why the format is similar to but
|
42 | * different from what the TS checker returns).
|
43 | */
|
44 | export declare function symbolIdentifier(typeChecker: ts.TypeChecker, sym: ts.Symbol, options?: SymbolIdOptions): string | undefined;
|
45 | /**
|
46 | * Ensures that the sourcePath is pointing to the source code
|
47 | * and not compiled code. This can happen if the root directory
|
48 | * and/or out directory is set for the project. We check to see
|
49 | * if the out directory is present in the sourcePath, and if so,
|
50 | * we replace it with the root directory.
|
51 | */
|
52 | export declare function normalizePath(sourcePath: string, rootDir?: string, outDir?: string): string;
|
53 | export {};
|
54 | //# sourceMappingURL=symbol-id.d.ts.map |
\ | No newline at end of file |