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
This commit is contained in:
Igor Minar 2020-01-15 18:50:38 -08:00 committed by Matias Niemelä
parent f2a545479d
commit 63c9c2d2be
3 changed files with 20 additions and 0 deletions

View File

@ -36,6 +36,10 @@ export class EmitterVisitorContext {
constructor(private _indent: number) { this._lines = [new _EmittedLine(_indent)]; } 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]; } private get _currentLine(): _EmittedLine { return this._lines[this._lines.length - 1]; }
println(from?: {sourceSpan: ParseSourceSpan | null}|null, lastPart: string = ''): void { println(from?: {sourceSpan: ParseSourceSpan | null}|null, lastPart: string = ''): void {
@ -169,6 +173,10 @@ export class EmitterVisitorContext {
return null; return null;
} }
/**
* @internal strip this from published d.ts files due to
* https://github.com/microsoft/TypeScript/issues/36216
*/
private get sourceLines(): _EmittedLine[] { private get sourceLines(): _EmittedLine[] {
if (this._lines.length && this._lines[this._lines.length - 1].parts.length === 0) { if (this._lines.length && this._lines[this._lines.length - 1].parts.length === 0) {
return this._lines.slice(0, -1); return this._lines.slice(0, -1);

View File

@ -74,6 +74,10 @@ export class SourceMapGenerator {
return this; 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]; } private get currentLine(): Segment[]|null { return this.lines.slice(-1)[0]; }
toJSON(): SourceMap|null { toJSON(): SourceMap|null {

View File

@ -351,6 +351,10 @@ export class TestBedRender3 implements TestBed {
return fixture; return fixture;
} }
/**
* @internal strip this from published d.ts files due to
* https://github.com/microsoft/TypeScript/issues/36216
*/
private get compiler(): R3TestBedCompiler { private get compiler(): R3TestBedCompiler {
if (this._compiler === null) { if (this._compiler === null) {
throw new Error(`Need to call TestBed.initTestEnvironment() first`); throw new Error(`Need to call TestBed.initTestEnvironment() first`);
@ -358,6 +362,10 @@ export class TestBedRender3 implements TestBed {
return this._compiler; return this._compiler;
} }
/**
* @internal strip this from published d.ts files due to
* https://github.com/microsoft/TypeScript/issues/36216
*/
private get testModuleRef(): NgModuleRef<any> { private get testModuleRef(): NgModuleRef<any> {
if (this._testModuleRef === null) { if (this._testModuleRef === null) {
this._testModuleRef = this.compiler.finalize(); this._testModuleRef = this.compiler.finalize();