@teambit/typescript 1.0.228 → 1.0.230

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.
Files changed (89) hide show
  1. package/artifacts/__bit_junit.xml +11 -11
  2. package/artifacts/preview/teambit_typescript_typescript-preview.js +1 -1
  3. package/artifacts/schema.json +911 -231
  4. package/dist/cmds/check-types.cmd.d.ts +26 -0
  5. package/dist/cmds/init.cmd.d.ts +0 -0
  6. package/dist/cmds/write-tsconfig.cmd.d.ts +26 -0
  7. package/dist/compiler-options.d.ts +22 -0
  8. package/dist/dedupe-path.spec.d.ts +1 -0
  9. package/dist/exceptions/index.d.ts +1 -0
  10. package/dist/exceptions/transformer-not-found.d.ts +8 -0
  11. package/dist/export-identifier.d.ts +6 -0
  12. package/dist/extractor-options.d.ts +26 -0
  13. package/dist/identifier-list.d.ts +7 -0
  14. package/dist/identifier.d.ts +9 -0
  15. package/dist/index.d.ts +9 -0
  16. package/dist/{preview-1712805335812.js → preview-1712891953391.js} +2 -2
  17. package/dist/remove-types-task.d.ts +8 -0
  18. package/dist/schema-extractor-context.d.ts +119 -0
  19. package/dist/schema-transformer.d.ts +19 -0
  20. package/dist/schema-transformer.plugin.d.ts +9 -0
  21. package/dist/sourceFileTransformers/class.d.ts +2 -0
  22. package/dist/sourceFileTransformers/empty-line-encoder.d.ts +14 -0
  23. package/dist/sourceFileTransformers/export.d.ts +2 -0
  24. package/dist/sourceFileTransformers/expression-statement.d.ts +2 -0
  25. package/dist/sourceFileTransformers/function.d.ts +2 -0
  26. package/dist/sourceFileTransformers/import.d.ts +2 -0
  27. package/dist/sourceFileTransformers/index.d.ts +12 -0
  28. package/dist/sourceFileTransformers/interface.d.ts +2 -0
  29. package/dist/sourceFileTransformers/replaceName.d.ts +1 -0
  30. package/dist/sourceFileTransformers/transform.d.ts +12 -0
  31. package/dist/sourceFileTransformers/type-reference.d.ts +2 -0
  32. package/dist/sourceFileTransformers/typeAlias.d.ts +2 -0
  33. package/dist/sourceFileTransformers/variable.d.ts +2 -0
  34. package/dist/transform-source-file.spec.d.ts +1 -0
  35. package/dist/transformers/array-literal-expression.d.ts +10 -0
  36. package/dist/transformers/array-type.d.ts +10 -0
  37. package/dist/transformers/binding-element.d.ts +17 -0
  38. package/dist/transformers/class-declaration.d.ts +12 -0
  39. package/dist/transformers/conditional-type.d.ts +10 -0
  40. package/dist/transformers/constructor.d.ts +10 -0
  41. package/dist/transformers/decorator.d.ts +10 -0
  42. package/dist/transformers/enum-declaration.d.ts +10 -0
  43. package/dist/transformers/export-assignment.d.ts +14 -0
  44. package/dist/transformers/export-declaration.d.ts +9 -0
  45. package/dist/transformers/expression-statement.d.ts +10 -0
  46. package/dist/transformers/function-like.d.ts +11 -0
  47. package/dist/transformers/get-accessor.d.ts +10 -0
  48. package/dist/transformers/import-declaration.d.ts +10 -0
  49. package/dist/transformers/index-signature.d.ts +10 -0
  50. package/dist/transformers/index.d.ts +43 -0
  51. package/dist/transformers/indexed-access-type.d.ts +10 -0
  52. package/dist/transformers/interface-declaration.d.ts +11 -0
  53. package/dist/transformers/intersection-type.d.ts +10 -0
  54. package/dist/transformers/keyword-type.d.ts +13 -0
  55. package/dist/transformers/literal-type.d.ts +13 -0
  56. package/dist/transformers/literal-value.d.ts +11 -0
  57. package/dist/transformers/module-declaration.d.ts +10 -0
  58. package/dist/transformers/named-tuple.d.ts +10 -0
  59. package/dist/transformers/object-literal-expression.d.ts +9 -0
  60. package/dist/transformers/parameter.d.ts +13 -0
  61. package/dist/transformers/parenthesized-type.d.ts +10 -0
  62. package/dist/transformers/property-assignment.d.ts +9 -0
  63. package/dist/transformers/property-declaration.d.ts +11 -0
  64. package/dist/transformers/set-accessor.d.ts +10 -0
  65. package/dist/transformers/source-file-transformer.d.ts +15 -0
  66. package/dist/transformers/template-literal-type-span.d.ts +10 -0
  67. package/dist/transformers/template-literal-type.d.ts +10 -0
  68. package/dist/transformers/this-type.d.ts +10 -0
  69. package/dist/transformers/tuple-type.d.ts +10 -0
  70. package/dist/transformers/type-alias.d.ts +11 -0
  71. package/dist/transformers/type-literal.d.ts +14 -0
  72. package/dist/transformers/type-operator.d.ts +14 -0
  73. package/dist/transformers/type-predicate.d.ts +10 -0
  74. package/dist/transformers/type-query.d.ts +13 -0
  75. package/dist/transformers/type-reference.d.ts +17 -0
  76. package/dist/transformers/union-type.d.ts +10 -0
  77. package/dist/transformers/utils/jsdoc-to-doc-schema.d.ts +5 -0
  78. package/dist/transformers/utils/parse-type-from-quick-info.d.ts +36 -0
  79. package/dist/transformers/variable-declaration.d.ts +11 -0
  80. package/dist/transformers/variable-statement.d.ts +14 -0
  81. package/dist/tsconfig-writer.d.ts +49 -0
  82. package/dist/typescript.aspect.d.ts +2 -0
  83. package/dist/typescript.composition.d.ts +1 -0
  84. package/dist/typescript.extractor.d.ts +51 -0
  85. package/dist/typescript.main.runtime.d.ts +135 -0
  86. package/dist/typescript.parser.d.ts +12 -0
  87. package/dist/typescript.parser.spec.d.ts +1 -0
  88. package/package.json +18 -18
  89. package/tsconfig.json +1 -46
@@ -0,0 +1,26 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { Logger } from '@teambit/logger';
3
+ import { Workspace } from '@teambit/workspace';
4
+ import { TypescriptMain } from '../typescript.main.runtime';
5
+ export declare class CheckTypesCmd implements Command {
6
+ private typescript;
7
+ private workspace;
8
+ private logger;
9
+ name: string;
10
+ description: string;
11
+ arguments: {
12
+ name: string;
13
+ description: string;
14
+ }[];
15
+ alias: string;
16
+ group: string;
17
+ options: CommandOptions;
18
+ constructor(typescript: TypescriptMain, workspace: Workspace, logger: Logger);
19
+ report([pattern]: [string], { all, strict }: {
20
+ all: boolean;
21
+ strict: boolean;
22
+ }): Promise<{
23
+ code: number;
24
+ data: string;
25
+ }>;
26
+ }
File without changes
@@ -0,0 +1,26 @@
1
+ /// <reference types="lodash" />
2
+ import { Command, CommandOptions } from '@teambit/cli';
3
+ import { TypescriptMain } from '../typescript.main.runtime';
4
+ type Flags = {
5
+ dryRun?: boolean;
6
+ noDedupe?: boolean;
7
+ dryRunWithTsconfig?: boolean;
8
+ clean?: boolean;
9
+ silent?: boolean;
10
+ };
11
+ export default class WriteTsconfigCmd implements Command {
12
+ private tsMain;
13
+ name: string;
14
+ description: string;
15
+ alias: string;
16
+ group: string;
17
+ private: boolean;
18
+ options: CommandOptions;
19
+ constructor(tsMain: TypescriptMain);
20
+ report(_args: any, flags: Flags): Promise<string>;
21
+ json(_args: any, flags: Flags): Promise<{
22
+ cleanResults: string[] | undefined;
23
+ writeResults: import("lodash").Omit<import("../tsconfig-writer").TsconfigPathsPerEnv, "tsconfig">[];
24
+ }>;
25
+ }
26
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { CompilerOptions } from '@teambit/compiler';
2
+ export type TypeScriptCompilerOptions = {
3
+ /**
4
+ * tsconfig to use during compilation.
5
+ */
6
+ tsconfig: Record<string, any>;
7
+ /**
8
+ * path for .d.ts files to include during build.
9
+ */
10
+ types: string[];
11
+ /**
12
+ * Run the compiler for .js files. this will only affect whether to run the compiler on the files
13
+ * or not. It won't change the tsconfig to support or not support js files.
14
+ */
15
+ compileJs?: boolean;
16
+ /**
17
+ * Run the compiler for .js files. this will only affect whether to run the compiler on the files
18
+ * or not. It won't change the tsconfig to support or not support jsx files.
19
+ */
20
+ compileJsx?: boolean;
21
+ } & Partial<CompilerOptions>;
22
+ export type TsCompilerOptionsWithoutTsConfig = Omit<TypeScriptCompilerOptions, 'tsconfig'>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { TransformerNotFound } from './transformer-not-found';
@@ -0,0 +1,8 @@
1
+ import { Node } from 'typescript';
2
+ import { Component } from '@teambit/component';
3
+ import { Location } from '@teambit/semantics.entities.semantic-schema';
4
+ export declare class TransformerNotFound extends Error {
5
+ readonly node: Node;
6
+ readonly component: Component;
7
+ constructor(node: Node, component: Component, location: Location);
8
+ }
@@ -0,0 +1,6 @@
1
+ import { Identifier } from './identifier';
2
+ export declare class ExportIdentifier extends Identifier {
3
+ exported: true;
4
+ constructor(id: string, filePath: string, aliasId?: string, sourceFilePath?: string);
5
+ static isExportIdentifier(identifier: Identifier): identifier is ExportIdentifier;
6
+ }
@@ -0,0 +1,26 @@
1
+ import { SchemaNodeTransformer, SchemaTransformer } from './schema-transformer';
2
+ export type ExtractorOptions = {
3
+ /**
4
+ * name of the string.
5
+ */
6
+ name?: string;
7
+ /**
8
+ * tsconfig string path.
9
+ */
10
+ tsconfig?: string;
11
+ /**
12
+ * TODO: support typescript module path.
13
+ */
14
+ /**
15
+ * typescript compiler options. always overrides all.
16
+ */
17
+ compilerOptions?: string;
18
+ /**
19
+ * schema transformers.
20
+ */
21
+ schemaTransformers?: SchemaTransformer[];
22
+ /**
23
+ * api transformers.
24
+ */
25
+ apiTransformers?: SchemaNodeTransformer[];
26
+ };
@@ -0,0 +1,7 @@
1
+ import { Identifier } from './identifier';
2
+ export declare class IdentifierList {
3
+ readonly identifiers: Identifier[];
4
+ constructor(identifiers: Identifier[]);
5
+ find(identifier: Identifier): Identifier | undefined;
6
+ includes(identifier: Identifier): boolean;
7
+ }
@@ -0,0 +1,9 @@
1
+ export declare class Identifier {
2
+ readonly id: string;
3
+ readonly filePath: string;
4
+ readonly aliasId?: string | undefined;
5
+ readonly sourceFilePath?: string | undefined;
6
+ constructor(id: string, filePath: string, aliasId?: string | undefined, sourceFilePath?: string | undefined);
7
+ isEqual(identifier: Identifier): boolean;
8
+ static isDefault(identifier: Identifier): boolean;
9
+ }
@@ -0,0 +1,9 @@
1
+ export { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';
2
+ export { TypeScriptExtractor } from './typescript.extractor';
3
+ export { TypescriptCompiler } from '@teambit/typescript.typescript-compiler';
4
+ export type { TypescriptMain, TsConfigTransformer, SchemaTransformerSlot, APITransformerSlot, } from './typescript.main.runtime';
5
+ export type { TypeScriptCompilerOptions, TsCompilerOptionsWithoutTsConfig } from './compiler-options';
6
+ export { TypescriptAspect } from './typescript.aspect';
7
+ export * from './sourceFileTransformers';
8
+ export type { SchemaNodeTransformer, SchemaTransformer } from './schema-transformer';
9
+ export { SchemaExtractorContext } from './schema-extractor-context';
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@1.0.228/dist/typescript.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@1.0.228/dist/typescript.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@1.0.230/dist/typescript.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@1.0.230/dist/typescript.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -0,0 +1,8 @@
1
+ import { BuildContext, BuildTask, BuiltTaskResult } from '@teambit/builder';
2
+ export declare class RemoveTypesTask implements BuildTask {
3
+ readonly aspectId: string;
4
+ readonly name = "RemoveTypesProp";
5
+ readonly description = "remove the types prop from package.json";
6
+ execute(context: BuildContext): Promise<BuiltTaskResult>;
7
+ private removeTypesFromPkgJson;
8
+ }
@@ -0,0 +1,119 @@
1
+ import { TsserverClient } from '@teambit/ts-server';
2
+ import ts, { ExportAssignment, ExportDeclaration, Node, TypeNode } from 'typescript';
3
+ import protocol from 'typescript/lib/protocol';
4
+ import { Component } from '@teambit/component';
5
+ import { TypeRefSchema, SchemaNode, Location, DocSchema } from '@teambit/semantics.entities.semantic-schema';
6
+ import { ComponentDependency } from '@teambit/dependency-resolver';
7
+ import { Formatter } from '@teambit/formatter';
8
+ import { TypeScriptExtractor } from './typescript.extractor';
9
+ import { IdentifierList } from './identifier-list';
10
+ import { Identifier } from './identifier';
11
+ export declare class SchemaExtractorContext {
12
+ readonly tsserver: TsserverClient;
13
+ readonly component: Component;
14
+ readonly extractor: TypeScriptExtractor;
15
+ readonly componentDeps: ComponentDependency[];
16
+ readonly componentRootPath: string;
17
+ readonly hostRootPath: string;
18
+ readonly formatter?: Formatter | undefined;
19
+ /**
20
+ * list of all declared identifiers (exported and internal) by filename
21
+ */
22
+ private _identifiers;
23
+ private _internalIdentifiers;
24
+ /**
25
+ * computed nodes by filename and (position (line:character))
26
+ */
27
+ private _computed;
28
+ get mainFile(): string;
29
+ get identifiers(): Map<string, IdentifierList>;
30
+ get internalIdentifiers(): Map<string, IdentifierList>;
31
+ get computed(): Map<string, SchemaNode>;
32
+ get mainFileIdentifierKey(): string;
33
+ get mainModuleIdentifiers(): IdentifierList | undefined;
34
+ constructor(tsserver: TsserverClient, component: Component, extractor: TypeScriptExtractor, componentDeps: ComponentDependency[], componentRootPath: string, hostRootPath: string, formatter?: Formatter | undefined);
35
+ getComputedNodeKey({ filePath, line, character }: Location, schema: string): string;
36
+ getIdentifierKeyForNode(node: Node): string;
37
+ getIdentifierKey(filePath: string): string;
38
+ setComputed(node: SchemaNode): void;
39
+ setIdentifiers(filePath: string, identifiers: IdentifierList): void;
40
+ setInternalIdentifiers(filePath: string, identifiers: IdentifierList): void;
41
+ findComputedSchemaByName(name: string): SchemaNode[];
42
+ computeSchema(node: Node): Promise<SchemaNode>;
43
+ transformSchemaNode(schema: SchemaNode): Promise<SchemaNode>;
44
+ /**
45
+ * returns the location of a node in a source file.
46
+ */
47
+ getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath?: boolean): Location;
48
+ getLocationAsString(node: Node): string;
49
+ getPathRelativeToComponent(filePath: string): string;
50
+ /**
51
+ * returns a signature for a node.
52
+ */
53
+ getSignature(node: Node): Promise<ts.server.protocol.SignatureHelpResponse | undefined>;
54
+ /**
55
+ * get the position for the tsserver.
56
+ */
57
+ getPosition(sourceFile: ts.SourceFile, line: number, offset: number): number;
58
+ /**
59
+ * get the path for a source file.
60
+ */
61
+ getPath(node: Node): string;
62
+ getQuickInfo(node: Node): Promise<ts.server.protocol.QuickInfoResponse | undefined>;
63
+ getQuickInfoDisplayString(node: Node): Promise<string>;
64
+ /**
65
+ * returns the type definition for a type.
66
+ */
67
+ typeDefinition(node: Node): Promise<ts.server.protocol.TypeDefinitionResponse | undefined>;
68
+ visitTypeDefinition(): void;
69
+ private getPathWithoutExtension;
70
+ private isIndexFile;
71
+ findFileInComponent(filePath: string): import("@teambit/legacy/dist/consumer/component/sources").AbstractVinyl | undefined;
72
+ private parsePackageNameFromPath;
73
+ /**
74
+ * return the file if part of the component.
75
+ * otherwise, a reference to the target package and the type name.
76
+ */
77
+ getSourceFileInsideComponent(filePath: string): ts.SourceFile | undefined;
78
+ getSourceFileFromNode(node: Node): Promise<ts.SourceFile | undefined>;
79
+ getFilePathByNode(node: Node): Promise<string | undefined>;
80
+ definitionInfo(node: Node): Promise<protocol.DefinitionInfo | undefined>;
81
+ /**
82
+ * get a definition for a given node.
83
+ */
84
+ definition(definition: protocol.DefinitionInfo): Promise<Node | undefined>;
85
+ /**
86
+ * visit a definition for node - e.g. return it's schema.
87
+ */
88
+ visitDefinition(node: Node): Promise<SchemaNode | undefined>;
89
+ visit(node: Node): Promise<SchemaNode>;
90
+ references(): void;
91
+ isExported(): void;
92
+ isFromComponent(): void;
93
+ getFileIdentifiers(exportDec: ExportDeclaration | ExportAssignment): Promise<Identifier[]>;
94
+ getFileExports(exportDec: ExportDeclaration | ExportAssignment): Promise<Identifier[]>;
95
+ getFileInternals(exportDec: ExportDeclaration | ExportAssignment): Promise<Identifier[]>;
96
+ getIdentifiers(node: Node): Promise<Identifier[]>;
97
+ /**
98
+ * tsserver has two different calls: "definition" and "typeDefinition".
99
+ * normally, we need the "typeDefinition" to get the type data of a node.
100
+ * sometimes, it has no data, for example when the node is of type TypeReference, and then using "definition" is
101
+ * helpful. (couldn't find a rule when to use each one. e.g. "VariableDeclaration" sometimes has data only in
102
+ * "definition" but it's not clear when/why).
103
+ */
104
+ getDefinition(node: Node): Promise<ts.server.protocol.FileSpanWithContext | undefined>;
105
+ private unknownExactType;
106
+ private isDefInSameLocation;
107
+ /**
108
+ * resolve a type by a node and its identifier.
109
+ */
110
+ resolveType(node: Node & {
111
+ type?: TypeNode;
112
+ }, typeStr: string, isTypeStrFromQuickInfo?: boolean): Promise<SchemaNode>;
113
+ private getCompIdByPkgName;
114
+ getTypeRef(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema | undefined>;
115
+ resolveTypeRef(identifier: Identifier, location: Location, isExportedFromMain?: boolean): Promise<TypeRefSchema>;
116
+ getTypeRefForExternalNode(node: Node): Promise<TypeRefSchema>;
117
+ getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema>;
118
+ jsDocToDocSchema(node: Node): Promise<DocSchema | undefined>;
119
+ }
@@ -0,0 +1,19 @@
1
+ import { Node } from 'typescript';
2
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaExtractorContext } from './schema-extractor-context';
4
+ import { Identifier } from './identifier';
5
+ export type SchemaTransformer = {
6
+ /**
7
+ * determine whether to apply schema on given node.
8
+ */
9
+ predicate(node: Node): boolean;
10
+ getIdentifiers(node: Node, context: SchemaExtractorContext): Promise<Identifier[]>;
11
+ /**
12
+ * transform the node into JSONSchema.
13
+ */
14
+ transform(node: Node, context: SchemaExtractorContext): Promise<SchemaNode>;
15
+ };
16
+ export type SchemaNodeTransformer = {
17
+ predicate(node: SchemaNode): boolean;
18
+ transform(node: SchemaNode, context: SchemaExtractorContext): Promise<SchemaNode | null>;
19
+ };
@@ -0,0 +1,9 @@
1
+ import { PluginDefinition } from '@teambit/aspect-loader';
2
+ import { SchemaTransformerSlot } from './typescript.main.runtime';
3
+ export declare class SchemaTransformerPlugin implements PluginDefinition {
4
+ private schemaTransformerSlot;
5
+ constructor(schemaTransformerSlot: SchemaTransformerSlot);
6
+ pattern: string;
7
+ runtimes: string[];
8
+ register(object: any): void;
9
+ }
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare function classNamesTransformer(nameMapping: Record<string, string>): ts.TransformerFactory<ts.SourceFile>;
@@ -0,0 +1,14 @@
1
+ import ts from 'typescript';
2
+ export declare class EmptyLineEncoder {
3
+ static readonly defaultEmptyLineMarker: string;
4
+ static readonly defaultNewLine: string;
5
+ constructor(emptyLineMarker?: string, newLine?: string);
6
+ emptyLineMarker: string;
7
+ newLine: string;
8
+ encode(text: string): string;
9
+ decode(text: string): string;
10
+ addLeadingEmptyLineMarker<T extends ts.Node>(node: T): T;
11
+ }
12
+ export declare function encodeEmptyLines(text: string, emptyLineMarker?: string, newLine?: string): string;
13
+ export declare function decodeEmptyLines(text: string, emptyLineMarker?: string, newLine?: string): string;
14
+ export declare function addLeadingEmptyLineMarker<T extends ts.Node>(node: T, emptyLineMarker?: string): T;
@@ -0,0 +1,2 @@
1
+ import { SourceFileTransformer } from '.';
2
+ export declare const exportTransformer: SourceFileTransformer;
@@ -0,0 +1,2 @@
1
+ import { SourceFileTransformer } from '.';
2
+ export declare const expressionStatementTransformer: SourceFileTransformer;
@@ -0,0 +1,2 @@
1
+ import { SourceFileTransformer } from '.';
2
+ export declare const functionNamesTransformer: SourceFileTransformer;
@@ -0,0 +1,2 @@
1
+ import { SourceFileTransformer } from '.';
2
+ export declare const importTransformer: SourceFileTransformer;
@@ -0,0 +1,12 @@
1
+ import ts from 'typescript';
2
+ export type SourceFileTransformer = (mapping: Record<string, string>) => ts.TransformerFactory<ts.SourceFile>;
3
+ export { classNamesTransformer } from './class';
4
+ export { interfaceNamesTransformer } from './interface';
5
+ export { variableNamesTransformer } from './variable';
6
+ export { functionNamesTransformer } from './function';
7
+ export { typeAliasNamesTransformer } from './typeAlias';
8
+ export { importTransformer } from './import';
9
+ export { expressionStatementTransformer } from './expression-statement';
10
+ export { exportTransformer } from './export';
11
+ export { transformSourceFile } from './transform';
12
+ export { typeReferenceTransformer } from './type-reference';
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare function interfaceNamesTransformer(nameMapping: Record<string, string>): ts.TransformerFactory<ts.SourceFile>;
@@ -0,0 +1 @@
1
+ export declare function replaceName(oldName: string, nameMapping: Record<string, string>): string | undefined;
@@ -0,0 +1,12 @@
1
+ import { Formatter } from '@teambit/formatter';
2
+ import ts from 'typescript';
3
+ /**
4
+ * Transforms a TypeScript source file using the provided transformer.
5
+ *
6
+ * @param sourceFilePath Path to the TypeScript source file.
7
+ * @param sourceFileContent The content of the source file.
8
+ * @param transformers The transformers to be applied on the source file.
9
+ * @param formatter (Optional) An optional formatter to format the transformed code. If no formatter is provided, the function returns the transformed source file as a string without any formatting.
10
+ * @returns A promise that resolves to the transformed source file as a string.
11
+ */
12
+ export declare function transformSourceFile(sourceFilePath: string, sourceFileContent: string, transformers: ts.TransformerFactory<ts.SourceFile>[], formatter?: Formatter, updates?: Record<string, string>): Promise<string>;
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare function typeReferenceTransformer(mapping: Record<string, string>): ts.TransformerFactory<ts.SourceFile>;
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare function typeAliasNamesTransformer(nameMapping: Record<string, string>): ts.TransformerFactory<ts.SourceFile>;
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare function variableNamesTransformer(nameMapping: Record<string, string>): ts.TransformerFactory<ts.SourceFile>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
+ import { ArrayLiteralExpression, Node } from 'typescript';
3
+ import type { SchemaExtractorContext } from '../schema-extractor-context';
4
+ import { SchemaTransformer } from '../schema-transformer';
5
+ import { Identifier } from '../identifier';
6
+ export declare class ArrayLiteralExpressionTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(): Promise<Identifier[]>;
9
+ transform(node: ArrayLiteralExpression, context: SchemaExtractorContext): Promise<SchemaNode>;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { ArrayTypeNode, Node } from 'typescript';
2
+ import { TypeArraySchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class ArrayTypeTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(): Promise<Identifier[]>;
9
+ transform(node: ArrayTypeNode, context: SchemaExtractorContext): Promise<TypeArraySchema>;
10
+ }
@@ -0,0 +1,17 @@
1
+ import { BindingElement, Node } from 'typescript';
2
+ import { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ /**
7
+ * for example:
8
+ *
9
+ * const objBindingElem = { elem1: 1, elem2: 2 };
10
+ * const { elem1 } = objBindingElem;
11
+ * export { elem1 };
12
+ */
13
+ export declare class BindingElementTransformer implements SchemaTransformer {
14
+ predicate(node: Node): boolean;
15
+ getIdentifiers(node: BindingElement): Promise<Identifier[]>;
16
+ transform(node: BindingElement, context: SchemaExtractorContext): Promise<VariableLikeSchema>;
17
+ }
@@ -0,0 +1,12 @@
1
+ import { ClassSchema } from '@teambit/semantics.entities.semantic-schema';
2
+ import { Node, ClassDeclaration } from 'typescript';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class ClassDeclarationTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ private getName;
9
+ getIdentifiers(node: ClassDeclaration): Promise<Identifier[]>;
10
+ private getExpressionWithTypeArgs;
11
+ transform(node: ClassDeclaration, context: SchemaExtractorContext): Promise<ClassSchema>;
12
+ }
@@ -0,0 +1,10 @@
1
+ import { Node, ConditionalTypeNode } from 'typescript';
2
+ import { ConditionalTypeSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class ConditionalTypeTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(): Promise<Identifier[]>;
9
+ transform(node: ConditionalTypeNode, context: SchemaExtractorContext): Promise<ConditionalTypeSchema>;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { Node, ConstructorDeclaration } from 'typescript';
2
+ import { ConstructorSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class ConstructorTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(): Promise<Identifier[]>;
9
+ transform(node: ConstructorDeclaration, context: SchemaExtractorContext): Promise<ConstructorSchema>;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
+ import { Decorator, Node } from 'typescript';
3
+ import { SchemaExtractorContext } from '../schema-extractor-context';
4
+ import { SchemaTransformer } from '../schema-transformer';
5
+ import { Identifier } from '../identifier';
6
+ export declare class DecoratorTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(decorator: Decorator): Promise<Identifier[]>;
9
+ transform(node: Decorator, context: SchemaExtractorContext): Promise<SchemaNode>;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { Node, EnumDeclaration } from 'typescript';
2
+ import { EnumSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class EnumDeclarationTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(node: EnumDeclaration): Promise<Identifier[]>;
9
+ transform(enumDec: EnumDeclaration, context: SchemaExtractorContext): Promise<EnumSchema>;
10
+ }
@@ -0,0 +1,14 @@
1
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
+ import { Node, ExportAssignment as ExportAssignmentNode } from 'typescript';
3
+ import { ExportIdentifier } from '../export-identifier';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { SchemaTransformer } from '../schema-transformer';
6
+ /**
7
+ * This is either an export = or an export default declaration.
8
+ * Unless isExportEquals is set, this node was parsed as an export default
9
+ */
10
+ export declare class ExportAssignmentTransformer implements SchemaTransformer {
11
+ predicate(node: Node): boolean;
12
+ getIdentifiers(exportDec: ExportAssignmentNode): Promise<ExportIdentifier[]>;
13
+ transform(exportDec: ExportAssignmentNode, context: SchemaExtractorContext): Promise<SchemaNode>;
14
+ }
@@ -0,0 +1,9 @@
1
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
+ import { Node, ExportDeclaration as ExportDeclarationNode } from 'typescript';
3
+ import { SchemaExtractorContext } from '../schema-extractor-context';
4
+ import { SchemaTransformer } from '../schema-transformer';
5
+ export declare class ExportDeclarationTransformer implements SchemaTransformer {
6
+ predicate(node: Node): boolean;
7
+ getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<import("../identifier").Identifier[]>;
8
+ transform(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode>;
9
+ }
@@ -0,0 +1,10 @@
1
+ import { Node, ExpressionStatement } from 'typescript';
2
+ import { UnImplementedSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class ExpressionStatementTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(): Promise<Identifier[]>;
9
+ transform(node: ExpressionStatement, context: SchemaExtractorContext): Promise<UnImplementedSchema>;
10
+ }
@@ -0,0 +1,11 @@
1
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
+ import { Node, SignatureDeclaration } from 'typescript';
3
+ import { SchemaExtractorContext } from '../schema-extractor-context';
4
+ import { SchemaTransformer } from '../schema-transformer';
5
+ import { Identifier } from '../identifier';
6
+ export declare class FunctionLikeTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(funcDec: SignatureDeclaration): Promise<Identifier[]>;
9
+ private getName;
10
+ transform(node: SignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode>;
11
+ }
@@ -0,0 +1,10 @@
1
+ import { Node, GetAccessorDeclaration } from 'typescript';
2
+ import { GetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class GetAccessorTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(): Promise<Identifier[]>;
9
+ transform(node: GetAccessorDeclaration, context: SchemaExtractorContext): Promise<GetAccessorSchema>;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { ImportDeclaration, Node } from 'typescript';
2
+ import { UnImplementedSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class ImportDeclarationTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(importDec: ImportDeclaration): Promise<Identifier[]>;
9
+ transform(node: ImportDeclaration, context: SchemaExtractorContext): Promise<UnImplementedSchema>;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { Node, IndexSignatureDeclaration } from 'typescript';
2
+ import { IndexSignatureSchema, UnresolvedSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class IndexSignatureTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(): Promise<Identifier[]>;
9
+ transform(node: IndexSignatureDeclaration, context: SchemaExtractorContext): Promise<IndexSignatureSchema | UnresolvedSchema>;
10
+ }