From 79ccbf14e91fd9e71f7f487c4e4463b750bb8b3e Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 15 Jan 2020 18:47:12 -0800 Subject: [PATCH 1/4] build: dedupe dependencies in typings_test_ts3{6,7}/package.json we should try to reuse as many dependencies as we can from the top level node_modules. --- integration/typings_test_ts36/package.json | 2 +- integration/typings_test_ts36/yarn.lock | 6 ++---- integration/typings_test_ts37/package.json | 2 +- integration/typings_test_ts37/yarn.lock | 6 ++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/integration/typings_test_ts36/package.json b/integration/typings_test_ts36/package.json index 58d97e198ee3..4f5f64ed018e 100644 --- a/integration/typings_test_ts36/package.json +++ b/integration/typings_test_ts36/package.json @@ -19,7 +19,7 @@ "@angular/router": "file:../../dist/packages-dist/router", "@angular/service-worker": "file:../../dist/packages-dist/service-worker", "@angular/upgrade": "file:../../dist/packages-dist/upgrade", - "@types/jasmine": "2.5.41", + "@types/jasmine": "file:../../node_modules/@types/jasmine", "rxjs": "file:../../node_modules/rxjs", "typescript": "3.6.4", "zone.js": "file:../../dist/zone.js-dist/zone.js" diff --git a/integration/typings_test_ts36/yarn.lock b/integration/typings_test_ts36/yarn.lock index 6108b8b8a65f..cf27763dd7f8 100644 --- a/integration/typings_test_ts36/yarn.lock +++ b/integration/typings_test_ts36/yarn.lock @@ -61,10 +61,8 @@ "@angular/upgrade@file:../../dist/packages-dist/upgrade": version "9.0.0-rc.1" -"@types/jasmine@2.5.41": - version "2.5.41" - resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.5.41.tgz#d5e86161a0af80d52062b310a33ed65b051a0713" - integrity sha1-1ehhYaCvgNUgYrMQoz7WWwUaBxM= +"@types/jasmine@file:../../node_modules/@types/jasmine": + version "2.8.8" abbrev@1: version "1.1.1" diff --git a/integration/typings_test_ts37/package.json b/integration/typings_test_ts37/package.json index a4dd03d3e910..7e9fee12c97c 100644 --- a/integration/typings_test_ts37/package.json +++ b/integration/typings_test_ts37/package.json @@ -19,7 +19,7 @@ "@angular/router": "file:../../dist/packages-dist/router", "@angular/service-worker": "file:../../dist/packages-dist/service-worker", "@angular/upgrade": "file:../../dist/packages-dist/upgrade", - "@types/jasmine": "2.5.41", + "@types/jasmine": "file:../../node_modules/@types/jasmine", "rxjs": "file:../../node_modules/rxjs", "typescript": "3.7.4", "zone.js": "file:../../dist/zone.js-dist/zone.js" diff --git a/integration/typings_test_ts37/yarn.lock b/integration/typings_test_ts37/yarn.lock index d4b806304274..66d1842ebd01 100644 --- a/integration/typings_test_ts37/yarn.lock +++ b/integration/typings_test_ts37/yarn.lock @@ -61,10 +61,8 @@ "@angular/upgrade@file:../../dist/packages-dist/upgrade": version "9.0.0-rc.1" -"@types/jasmine@2.5.41": - version "2.5.41" - resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.5.41.tgz#d5e86161a0af80d52062b310a33ed65b051a0713" - integrity sha1-1ehhYaCvgNUgYrMQoz7WWwUaBxM= +"@types/jasmine@file:../../node_modules/@types/jasmine": + version "2.8.8" ansi-regex@^2.0.0: version "2.1.1" From 4b6731bbb952840ee3e531e81f1e5605b63209f1 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 15 Jan 2020 13:31:43 -0800 Subject: [PATCH 2/4] test: make all typings integration tests use ts strict mode previously they didn't which was a bug/oversight. --- integration/typings_test_ts36/tsconfig.json | 2 +- integration/typings_test_ts37/tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/typings_test_ts36/tsconfig.json b/integration/typings_test_ts36/tsconfig.json index c815868e5118..fadb96a081fa 100644 --- a/integration/typings_test_ts36/tsconfig.json +++ b/integration/typings_test_ts36/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "strict": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "module": "commonjs", @@ -15,7 +16,6 @@ "es2015.promise" ], "types": [], - "strictNullChecks": true }, "files": [ "include-all.ts", diff --git a/integration/typings_test_ts37/tsconfig.json b/integration/typings_test_ts37/tsconfig.json index 70c8db79e198..3edf41c42f83 100644 --- a/integration/typings_test_ts37/tsconfig.json +++ b/integration/typings_test_ts37/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "strict": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "module": "commonjs", @@ -15,7 +16,6 @@ "es2015.promise" ], "types": [], - "strictNullChecks": true }, "files": [ "include-all.ts", From a673571c35b1902d185dc0edb2882463605997e3 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 15 Jan 2020 20:40:40 -0800 Subject: [PATCH 3/4] test: explicitly turn off skipLibCheck for typings tests skipLibCheck=false is currently the default (in tsc 3.7.4) but it wouldn't be shocking if the default changed in the future because skipLibCheck=true makes more sense in almost all scenarios. So just to be defensive and explicit, I'm setting the flag to false even though it's the current default. --- integration/typings_test_ts36/tsconfig.json | 1 + integration/typings_test_ts37/tsconfig.json | 1 + 2 files changed, 2 insertions(+) diff --git a/integration/typings_test_ts36/tsconfig.json b/integration/typings_test_ts36/tsconfig.json index fadb96a081fa..a7522d1cff68 100644 --- a/integration/typings_test_ts36/tsconfig.json +++ b/integration/typings_test_ts36/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "strict": true, + "skipLibCheck": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "module": "commonjs", diff --git a/integration/typings_test_ts37/tsconfig.json b/integration/typings_test_ts37/tsconfig.json index 3edf41c42f83..b220b236d5f1 100644 --- a/integration/typings_test_ts37/tsconfig.json +++ b/integration/typings_test_ts37/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "strict": true, + "skipLibCheck": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "module": "commonjs", From 355ecdf30c67b34ba8b536921385f28b88dd9dda Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 15 Jan 2020 18:50:38 -0800 Subject: [PATCH 4/4] fix: work around 'noImplicityAny' incompatibility due to ts3.7 update 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 --- 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 ff10e36a4a34..3c809fa59016 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 595e94221c96..359e5fb07161 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 3f4b285e5725..6a749280fec0 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();