From 63c9c2d2be910edb3058272acbe96e68e0d67b87 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 15 Jan 2020 18:50:38 -0800 Subject: [PATCH] fix: work around 'noImplicityAny' incompatibility due to ts3.7 update (#34798) Typescript 3.7 now emits d.ts files for getters differently than prior versions, and there seems to be a bug in how it strips private types without replacing them with explicit 'any' type. This then leads to compilation failures in projects compiled against our packages that don't have skipLibCheck turned on but do have strict or noImplicitAny check on. I'm working around this by marking the affected getters as @internal and adding a test to prevent future regressions. I believe this is a TypeScript bug, and I filed a bug report: https://github.com/microsoft/TypeScript/issues/36216 PR Close #34798 --- packages/compiler/src/output/abstract_emitter.ts | 8 ++++++++ packages/compiler/src/output/source_map.ts | 4 ++++ packages/core/testing/src/r3_test_bed.ts | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/packages/compiler/src/output/abstract_emitter.ts b/packages/compiler/src/output/abstract_emitter.ts index ff10e36a4a..3c809fa590 100644 --- a/packages/compiler/src/output/abstract_emitter.ts +++ b/packages/compiler/src/output/abstract_emitter.ts @@ -36,6 +36,10 @@ export class EmitterVisitorContext { constructor(private _indent: number) { this._lines = [new _EmittedLine(_indent)]; } + /** + * @internal strip this from published d.ts files due to + * https://github.com/microsoft/TypeScript/issues/36216 + */ private get _currentLine(): _EmittedLine { return this._lines[this._lines.length - 1]; } println(from?: {sourceSpan: ParseSourceSpan | null}|null, lastPart: string = ''): void { @@ -169,6 +173,10 @@ export class EmitterVisitorContext { return null; } + /** + * @internal strip this from published d.ts files due to + * https://github.com/microsoft/TypeScript/issues/36216 + */ private get sourceLines(): _EmittedLine[] { if (this._lines.length && this._lines[this._lines.length - 1].parts.length === 0) { return this._lines.slice(0, -1); diff --git a/packages/compiler/src/output/source_map.ts b/packages/compiler/src/output/source_map.ts index 595e94221c..359e5fb071 100644 --- a/packages/compiler/src/output/source_map.ts +++ b/packages/compiler/src/output/source_map.ts @@ -74,6 +74,10 @@ export class SourceMapGenerator { return this; } + /** + * @internal strip this from published d.ts files due to + * https://github.com/microsoft/TypeScript/issues/36216 + */ private get currentLine(): Segment[]|null { return this.lines.slice(-1)[0]; } toJSON(): SourceMap|null { diff --git a/packages/core/testing/src/r3_test_bed.ts b/packages/core/testing/src/r3_test_bed.ts index 3f4b285e57..6a749280fe 100644 --- a/packages/core/testing/src/r3_test_bed.ts +++ b/packages/core/testing/src/r3_test_bed.ts @@ -351,6 +351,10 @@ export class TestBedRender3 implements TestBed { return fixture; } + /** + * @internal strip this from published d.ts files due to + * https://github.com/microsoft/TypeScript/issues/36216 + */ private get compiler(): R3TestBedCompiler { if (this._compiler === null) { throw new Error(`Need to call TestBed.initTestEnvironment() first`); @@ -358,6 +362,10 @@ export class TestBedRender3 implements TestBed { return this._compiler; } + /** + * @internal strip this from published d.ts files due to + * https://github.com/microsoft/TypeScript/issues/36216 + */ private get testModuleRef(): NgModuleRef { if (this._testModuleRef === null) { this._testModuleRef = this.compiler.finalize();