jsii 6.0.21 → 7.1.0-dev.1

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 (107) hide show
  1. package/lib/assembler.d.ts +254 -196
  2. package/lib/assembler.js +2105 -2327
  3. package/lib/assembler.js.map +1 -1
  4. package/lib/case.js.map +1 -1
  5. package/lib/common/find-utils.js.map +1 -1
  6. package/lib/common/index.d.ts +1 -1
  7. package/lib/common/index.js +2 -1
  8. package/lib/common/index.js.map +1 -1
  9. package/lib/common/symbol-id.d.ts +23 -4
  10. package/lib/common/symbol-id.js +13 -9
  11. package/lib/common/symbol-id.js.map +1 -1
  12. package/lib/compiler-host.d.ts +60 -0
  13. package/lib/compiler-host.js +201 -0
  14. package/lib/compiler-host.js.map +1 -0
  15. package/lib/compiler.d.ts +74 -62
  16. package/lib/compiler.js +332 -254
  17. package/lib/compiler.js.map +1 -1
  18. package/lib/diagnostic.d.ts +34 -0
  19. package/lib/diagnostic.js +141 -0
  20. package/lib/diagnostic.js.map +1 -0
  21. package/lib/emitter.d.ts +40 -10
  22. package/lib/emitter.js +188 -0
  23. package/lib/emitter.js.map +1 -1
  24. package/lib/helpers.d.ts +1 -1
  25. package/lib/helpers.js +2 -2
  26. package/lib/helpers.js.map +1 -1
  27. package/lib/index.js.map +1 -1
  28. package/lib/jsii-diagnostic.d.ts +27 -22
  29. package/lib/jsii-diagnostic.js +22 -38
  30. package/lib/jsii-diagnostic.js.map +1 -1
  31. package/lib/literate.js.map +1 -1
  32. package/lib/main.js +3 -2
  33. package/lib/main.js.map +1 -1
  34. package/lib/project-info.d.ts +23 -4
  35. package/lib/project-info.js +5 -5
  36. package/lib/project-info.js.map +1 -1
  37. package/lib/support-types.d.ts +2 -0
  38. package/lib/support-types.js +3 -0
  39. package/lib/support-types.js.map +1 -0
  40. package/lib/support.js.map +1 -1
  41. package/lib/tsconfig/compiler-options.d.ts +12 -46
  42. package/lib/tsconfig/compiler-options.js +45 -87
  43. package/lib/tsconfig/compiler-options.js.map +1 -1
  44. package/lib/tsconfig/index.d.ts +24 -5
  45. package/lib/tsconfig/index.js.map +1 -1
  46. package/lib/tsconfig/read.d.ts +15 -0
  47. package/lib/tsconfig/read.js +196 -0
  48. package/lib/tsconfig/read.js.map +1 -0
  49. package/lib/tsconfig/rule-set-format.js.map +1 -1
  50. package/lib/tsconfig/rulesets/configurable-options.js.map +1 -1
  51. package/lib/tsconfig/rulesets/deprecated-options.js.map +1 -1
  52. package/lib/tsconfig/rulesets/generated.public.js.map +1 -1
  53. package/lib/tsconfig/rulesets/incompatible-options.js.map +1 -1
  54. package/lib/tsconfig/rulesets/jsii-configured-options.js.map +1 -1
  55. package/lib/tsconfig/rulesets/minimal.public.js.map +1 -1
  56. package/lib/tsconfig/rulesets/strict-family-options.js.map +1 -1
  57. package/lib/tsconfig/rulesets/strict.public.js.map +1 -1
  58. package/lib/tsconfig/tsconfig-validator.js +2 -50
  59. package/lib/tsconfig/tsconfig-validator.js.map +1 -1
  60. package/lib/tsconfig/validator.js.map +1 -1
  61. package/lib/type-analysis.js.map +1 -1
  62. package/lib/type-reference.js.map +1 -1
  63. package/lib/type-visitor.js.map +1 -1
  64. package/lib/utils.d.ts +6 -6
  65. package/lib/utils.js +8 -13
  66. package/lib/utils.js.map +1 -1
  67. package/lib/version.d.ts +3 -3
  68. package/lib/version.js +4 -4
  69. package/lib/version.js.map +1 -1
  70. package/lib/warnings.d.ts +2 -2
  71. package/lib/warnings.js +3 -77
  72. package/lib/warnings.js.map +1 -1
  73. package/package.json +15 -10
  74. package/scripts/ts7-compare-jsii.mjs +101 -0
  75. package/lib/directives.d.ts +0 -24
  76. package/lib/directives.js +0 -139
  77. package/lib/directives.js.map +0 -1
  78. package/lib/docs.d.ts +0 -64
  79. package/lib/docs.js +0 -293
  80. package/lib/docs.js.map +0 -1
  81. package/lib/node-bindings.d.ts +0 -19
  82. package/lib/node-bindings.js +0 -49
  83. package/lib/node-bindings.js.map +0 -1
  84. package/lib/reserved-words.d.ts +0 -6
  85. package/lib/reserved-words.js +0 -258
  86. package/lib/reserved-words.js.map +0 -1
  87. package/lib/sets.d.ts +0 -16
  88. package/lib/sets.js +0 -41
  89. package/lib/sets.js.map +0 -1
  90. package/lib/transforms/deprecated-remover.d.ts +0 -44
  91. package/lib/transforms/deprecated-remover.js +0 -545
  92. package/lib/transforms/deprecated-remover.js.map +0 -1
  93. package/lib/transforms/deprecation-warnings.d.ts +0 -37
  94. package/lib/transforms/deprecation-warnings.js +0 -616
  95. package/lib/transforms/deprecation-warnings.js.map +0 -1
  96. package/lib/transforms/runtime-info.d.ts +0 -39
  97. package/lib/transforms/runtime-info.js +0 -128
  98. package/lib/transforms/runtime-info.js.map +0 -1
  99. package/lib/transforms/utils.d.ts +0 -11
  100. package/lib/transforms/utils.js +0 -31
  101. package/lib/transforms/utils.js.map +0 -1
  102. package/lib/type-tracker.d.ts +0 -13
  103. package/lib/type-tracker.js +0 -67
  104. package/lib/type-tracker.js.map +0 -1
  105. package/lib/validator.d.ts +0 -19
  106. package/lib/validator.js +0 -602
  107. package/lib/validator.js.map +0 -1
package/lib/compiler.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import * as ts from 'typescript';
2
- import { Emitter } from './emitter';
1
+ import * as spec from '@jsii/spec';
2
+ import { Diagnostic } from './diagnostic';
3
3
  import { ProjectInfo } from './project-info';
4
4
  import { TypeScriptConfigValidationRuleSet } from './tsconfig';
5
5
  export declare const DIAGNOSTICS = "diagnostics";
@@ -7,7 +7,12 @@ export declare const JSII_DIAGNOSTICS_CODE = 9999;
7
7
  export interface CompilerOptions {
8
8
  /** The information about the project to be built */
9
9
  projectInfo: ProjectInfo;
10
- /** Whether the compiler should watch for changes or just compile once */
10
+ /**
11
+ * Whether the compiler should watch for changes or just compile once.
12
+ *
13
+ * Watch mode is not available on the TypeScript 7 backend; setting this to
14
+ * `true` makes `emit()` fail with an explicit error.
15
+ */
11
16
  watch?: boolean;
12
17
  /** Whether to detect and generate TypeScript project references */
13
18
  projectReferences?: boolean;
@@ -17,7 +22,13 @@ export interface CompilerOptions {
17
22
  stripDeprecated?: boolean;
18
23
  /** The path to an allowlist of FQNs to strip if stripDeprecated is set */
19
24
  stripDeprecatedAllowListFile?: string;
20
- /** Whether to add warnings for deprecated elements */
25
+ /**
26
+ * Whether to add warnings for deprecated elements.
27
+ *
28
+ * Not implemented on the TypeScript 7 backend yet; requesting it fails with
29
+ * an explicit error instead of silently producing an assembly without the
30
+ * `.warnings.jsii.js` module.
31
+ */
21
32
  addDeprecationWarnings?: boolean;
22
33
  /**
23
34
  * The name of the tsconfig file to generate.
@@ -43,64 +54,50 @@ export interface CompilerOptions {
43
54
  */
44
55
  compressAssembly?: boolean;
45
56
  }
46
- export declare class Compiler implements Emitter {
57
+ export interface EmitResult {
58
+ readonly emitSkipped: boolean;
59
+ readonly diagnostics: readonly Diagnostic[];
60
+ /** The files written by the compiler (absolute paths). */
61
+ readonly emittedFiles?: readonly string[];
62
+ }
63
+ /**
64
+ * Compiles a jsii project with the TypeScript 7 programmatic API.
65
+ *
66
+ * The compiler owns the `tsconfig.json` handling (generating one from the
67
+ * project's `package.json`, or validating a user-provided one) and delegates the
68
+ * type analysis, assembly generation and emit to `buildProject`, which drives the
69
+ * out-of-process TypeScript 7 compiler.
70
+ */
71
+ export declare class Compiler {
47
72
  private readonly options;
48
- private readonly system;
49
- private readonly compilerHost;
50
73
  private readonly userProvidedTypeScriptConfig;
51
74
  private readonly tsconfig;
52
- private rootFiles;
53
75
  private readonly configPath;
54
76
  private readonly projectRoot;
55
77
  constructor(options: CompilerOptions);
78
+ /** The name of the tsconfig file this compiler builds from (relative to the project root). */
79
+ get configFileName(): string;
56
80
  /**
57
- * Compiles the configured program.
58
- *
59
- * @param files can be specified to override the standard source code location logic. Useful for example when testing "negatives".
60
- */
61
- emit(...files: string[]): ts.EmitResult;
62
- /**
63
- * Watches for file-system changes and dynamically recompiles the project as needed. In blocking mode, this results
64
- * in a never-resolving promise.
81
+ * Compiles the configured project once.
65
82
  */
66
- watch(): Promise<never>;
67
83
  /**
68
- * Prepares the project for build, by creating the necessary configuration
69
- * file(s), and assigning the relevant root file(s).
84
+ * Compiles the configured project once.
70
85
  *
71
- * @param files the files that were specified as input in the CLI invocation.
86
+ * @param files can be specified to override the standard source code location
87
+ * logic (the generated tsconfig then lists exactly these files).
88
+ * Useful for example when testing "negatives".
72
89
  */
90
+ emit(...files: string[]): EmitResult;
73
91
  private configureTypeScript;
74
92
  /**
75
- * Final preparations of the project for build.
76
- *
77
- * These are preparations that either
78
- * - must happen immediately before the build, or
79
- * - can be different for every build like assigning the relevant root file(s).
80
- *
81
- * @param files the files that were specified as input in the CLI invocation.
82
- */
83
- private prepareForBuild;
84
- /**
85
- * Do a single build
86
- */
87
- private buildOnce;
88
- private consumeProgram;
89
- /**
90
- * Build the TypeScript config object from jsii config
93
+ * Builds the TypeScript config object from jsii config.
91
94
  *
92
- * This is the object that will be written to disk
93
- * unless an existing tsconfig was provided.
95
+ * This is the object that will be written to disk unless an existing tsconfig
96
+ * is passed in.
94
97
  */
95
98
  private buildTypeScriptConfig;
96
- /**
97
- * Load the TypeScript config object from a provided file
98
- */
99
- private readTypeScriptConfig;
100
99
  /**
101
100
  * Creates a `tsconfig.json` file to improve the IDE experience.
102
- *
103
- * @return the fully qualified path to the `tsconfig.json` file
104
101
  */
105
102
  private writeTypeScriptConfig;
106
103
  /**
@@ -115,27 +112,42 @@ export declare class Compiler implements Emitter {
115
112
  */
116
113
  private findProjectReferences;
117
114
  /**
118
- * Find source files using the same mechanism that the TypeScript compiler itself uses.
119
- *
120
- * Respects includes/excludes/etc.
115
+ * Find source files for a dependency that is also a sibling in a monorepo.
121
116
  *
122
- * This makes it so that running 'typescript' and running 'jsii' has the same behavior.
117
+ * This method is used to find project references.
123
118
  */
124
- private determineSources;
119
+ private findMonorepoPeerTsconfig;
120
+ }
121
+ export interface BuildProjectOptions {
122
+ readonly projectRoot: string;
123
+ readonly projectInfo: ProjectInfo;
124
+ /** The tsconfig file to open, relative to `projectRoot` (default `tsconfig.json`). */
125
+ readonly tsconfigFileName?: string;
125
126
  /**
126
- * Resolve the given dependency name from the current package, and find the associated tsconfig.json location
127
- *
128
- * Because we have the following potential directory layout:
129
- *
130
- * package/node_modules/some_dependency
131
- * package/tsconfig.json
132
- *
133
- * We resolve symlinks and only find a "TypeScript" dependency if doesn't have 'node_modules' in
134
- * the path after resolving symlinks (i.e., if it's a peer package in the same monorepo).
135
- *
136
- * Returns undefined if no such tsconfig could be found.
127
+ * Whether the tsconfig was generated by jsii (as opposed to user-provided).
128
+ * A generated config may be amended with an inferred `rootDir`.
137
129
  */
138
- private findMonorepoPeerTsconfig;
139
- private diagsHaveAbortableErrors;
130
+ readonly generatedTsconfig?: boolean;
131
+ readonly stripDeprecated?: boolean;
132
+ readonly stripDeprecatedAllowListFile?: string;
133
+ readonly compressAssembly?: boolean;
134
+ }
135
+ export interface BuildProjectResult {
136
+ readonly assembly?: spec.Assembly;
137
+ readonly typeCount: number;
138
+ readonly emittedFiles: string[];
139
+ readonly emitSkipped: boolean;
140
+ readonly diagnostics: readonly Diagnostic[];
140
141
  }
142
+ /**
143
+ * Run the ts backend for a package: produce and write the `.jsii` assembly.
144
+ */
145
+ export declare function buildProject(options: BuildProjectOptions): BuildProjectResult;
146
+ /**
147
+ * Map one TypeScript 7 API diagnostic (`{ fileName, pos, end, code, category, text }`)
148
+ * to jsii's `Diagnostic`. The file text is attached so the formatter renders the
149
+ * same `file:line:col - error TSxxxx:` layout, with source context, that the
150
+ * classic compiler produced. Exported for unit tests.
151
+ */
152
+ export declare function toDiagnostic(d: any, readSource: (fileName: string) => string | undefined): Diagnostic;
141
153
  //# sourceMappingURL=compiler.d.ts.map