1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | /**
|
4 | * Overrides the [`typescript.createEmitAndSemanticDiagnosticsBuilderProgram`](https://github.com/Microsoft/TypeScript/blob/89386ddda7dafc63cb35560e05412487f47cc267/src/compiler/builder.ts#L1176)
|
5 | * method to return a `ts.Program` instance that does not emit syntactic errors,
|
6 | * to prevent the [`typescript.createWatchCompilerHost`](https://github.com/Microsoft/TypeScript/blob/89386ddda7dafc63cb35560e05412487f47cc267/src/compiler/watch.ts#L333)
|
7 | * method from bailing during diagnostic collection in the [`emitFilesAndReportErrors`](https://github.com/Microsoft/TypeScript/blob/89386ddda7dafc63cb35560e05412487f47cc267/src/compiler/watch.ts#L141) callback.
|
8 | *
|
9 | * See the description of TypeScriptPatchConfig.skipGetSyntacticDiagnostics and
|
10 | * [this github discussion](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/257#issuecomment-485414182)
|
11 | * for further information on this problem & solution.
|
12 | */
|
13 | function patchSkipGetSyntacticDiagnostics(typescript) {
|
14 | var originalCreateEmitAndSemanticDiagnosticsBuilderProgram = typescript.createEmitAndSemanticDiagnosticsBuilderProgram;
|
15 | var patchedMethods = {
|
16 | // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
17 | createEmitAndSemanticDiagnosticsBuilderProgram: function () {
|
18 | var args = [];
|
19 | for (var _i = 0; _i < arguments.length; _i++) {
|
20 | args[_i] = arguments[_i];
|
21 | }
|
22 | var program = originalCreateEmitAndSemanticDiagnosticsBuilderProgram.apply(typescript,
|
23 | // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
24 | args);
|
25 | program.getSyntacticDiagnostics = function () { return []; };
|
26 | return program;
|
27 | }
|
28 | };
|
29 | // directly patch the typescript object!
|
30 | Object.assign(typescript, patchedMethods);
|
31 | }
|
32 | /**
|
33 | * While it is often possible to pass a wrapped or modified copy of `typescript` or `typescript.sys` as a function argument to override/extend some typescript-internal behavior,
|
34 | * sometimes the typescript-internal code ignores these passed objects and directly references the internal `typescript` object reference.
|
35 | * In these situations, the only way of consistently overriding some behavior is to directly replace methods on the `typescript` object.
|
36 | *
|
37 | * So beware, this method directly modifies the passed `typescript` object!
|
38 | * @param typescript TypeScript instance to patch
|
39 | * @param config
|
40 | */
|
41 | function patchTypescript(typescript, config) {
|
42 | if (config.skipGetSyntacticDiagnostics) {
|
43 | patchSkipGetSyntacticDiagnostics(typescript);
|
44 | }
|
45 | }
|
46 | exports.patchTypescript = patchTypescript;
|
47 | //# sourceMappingURL=patchTypescript.js.map |
\ | No newline at end of file |