Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration/bazel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@bazel/typescript": "0.38.3",
"@types/jasmine": "2.8.8",
"http-server": "^0.11.1",
"typescript": "3.6.4"
"typescript": "3.7.0-beta"
},
"scripts": {
"test": "bazel build ... --noshow_progress && bazel test ...",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@angular/upgrade": "file:../../dist/packages-dist/upgrade",
"@types/jasmine": "2.5.41",
"rxjs": "file:../../node_modules/rxjs",
"typescript": "3.6.4",
"typescript": "3.7.0-beta",
"zone.js": "file:../../node_modules/zone.js"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../../dist/typings_test_ts36/",
"outDir": "../../dist/typings_test_ts37/",
"rootDir": ".",
"target": "es5",
"lib": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"tsickle": "0.37.0",
"tslib": "^1.10.0",
"tslint": "5.7.0",
"typescript": "~3.6.4",
"typescript": "3.7.0-beta",
"xhr2": "0.1.4",
"yargs": "13.1.0",
"zone.js": "^0.10.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/bazel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"peerDependencies": {
"@angular/compiler-cli": "0.0.0-PLACEHOLDER",
"@bazel/typescript": "0.*",
"typescript": ">=3.6 <3.7"
"typescript": ">=3.7 <3.8"
},
"devDependencies": {

Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"peerDependencies": {
"@angular/compiler": "0.0.0-PLACEHOLDER",
"tslib": "^1.10.0",
"typescript": ">=3.6 <3.7"
"typescript": ">=3.7 <3.8"
},
"engines": {
"node": ">=8.0"
Expand Down
5 changes: 3 additions & 2 deletions packages/compiler-cli/src/diagnostics/typescript_symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ class TypeScriptSymbolQuery implements SymbolQuery {
const type = this.checker.getTypeAtLocation(parameter.type !);
if (type.symbol !.name == 'TemplateRef' && isReferenceType(type)) {
const typeReference = type as ts.TypeReference;
if (typeReference.typeArguments && typeReference.typeArguments.length === 1) {
return typeReference.typeArguments[0].symbol;
const typeArguments = this.checker.getTypeArguments(typeReference);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (typeArguments.length === 1) {
return typeArguments[0].symbol;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-cli/src/transformers/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ const defaultEmitCallback: TsEmitCallback =
* Minimum supported TypeScript version
* ∀ supported typescript version v, v >= MIN_TS_VERSION
*/
const MIN_TS_VERSION = '3.6.4';
const MIN_TS_VERSION = '3.7.0-beta';

/**
* Supremum of supported TypeScript versions
* ∀ supported typescript version v, v < MAX_TS_VERSION
* MAX_TS_VERSION is not considered as a supported TypeScript version
*/
const MAX_TS_VERSION = '3.7.0';
const MAX_TS_VERSION = '3.8.0';

class AngularCompilerProgram implements Program {
private rootNames: string[];
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/di/injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import {Type} from '../interface/type';
import {TypeDecorator, makeDecorator} from '../util/decorators';

import {InjectableType, getInjectableDef, ɵɵInjectableDef, ɵɵdefineInjectable} from './interface/defs';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for

packages/core/src/di/injectable.ts(12,9): error TS2440: Import declaration conflicts with local declaration of 'InjectableType'.

Listed under breaking changes in https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/.

import {getInjectableDef, ɵɵInjectableDef, ɵɵdefineInjectable} from './interface/defs';
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueSansProvider} from './interface/provider';
import {compileInjectable as render3CompileInjectable} from './jit/injectable';
import {convertInjectableProviderToFactory} from './util';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/render3/instructions/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ function saveNameToExportMap(
exportsMap[def.exportAs[i]] = index;
}
}
if ((def as ComponentDef<any>).template) exportsMap[''] = index;
exportsMap[''] = index;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for

packages/core/src/render3/instructions/shared.ts(1272,9): error TS2774: This condition will always return true since the function is always defined. Did 
you mean to call it instead?

Listed under breaking changes in https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/.

@JoostK JoostK Oct 7, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if guard is there to differentiate between DirectiveDef and ComponentDef, by testing to see if def has a template property. This is probably still relevant, so a better fix might be

Suggested change
exportsMap[''] = index;
if ((def as ComponentDef<any>).template !== undefined) exportsMap[''] = index;

or

Suggested change
exportsMap[''] = index;
if (!!(def as ComponentDef<any>).template) exportsMap[''] = index;

(which is the alternative workaround in the notes)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast to ComponentDef<any> looks odd to me since ComponentDef always has a template. It's means "say that def is a ComponentDef, is the template property defined?" to which it makes sense that TS would complain.

Shouldn't the cast be something different then?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that pattern is a bit misleading. In this case, the cast is there as an assumption of it indeed being a ComponentDef, then checking if template actually exists to confirm.

This pattern is often used in functions with type predicates:

export function isComponentDef<T>(def: DirectiveDef<T>|ComponentDef<T>): def is ComponentDef<T> {
  return (def as ComponentDef<T>).template !== undefined;
}

In this case however, the compiler requires the return type to be boolean, so the original guard as written before you changed it would not have compiled in the type guard. I guess the extra function is omitted for code size (although I'm not sure on that one).

The benefit of the "assumed cast" is that there's proper reference tracking, i.e. IDEs know that the template property read does in fact correspond with ComponentDef.template, so e.g. renaming template will correctly update the isComponentDef function.

}
}

Expand Down
4 changes: 2 additions & 2 deletions tools/ts-api-guardian/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "test"
},
"peerDependencies": {
"typescript": "~3.6.4"
"typescript": "~3.7.0"
},
"dependencies": {
"chalk": "^2.3.1",
Expand All @@ -33,7 +33,7 @@
"chai": "^4.1.2",
"jasmine": "^3.1.0",
"source-map-support": "^0.5.9",
"typescript": "~3.6.4"
"typescript": "3.7.0-beta"
},
"repository": {},
"keywords": [
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11738,16 +11738,16 @@ typescript@3.4.3:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.3.tgz#0eb320e4ace9b10eadf5bc6103286b0f8b7c224f"
integrity sha512-FFgHdPt4T/duxx6Ndf7hwgMZZjZpB+U0nMNGVCYPq0rEzWKjEDobm4J6yb3CS7naZ0yURFqdw9Gwc7UOh/P9oQ==

typescript@3.7.0-beta:
version "3.7.0-beta"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.0-beta.tgz#4ad556e0eee14b90ecc39261001690e16e5eeba9"
integrity sha512-4jyCX+IQamrPJxgkABPq9xf+hUN+GWHVxoj+oey1TadCPa4snQl1RKwUba+1dyzYCamwlCxKvZQ3TjyWLhMGBA==

typescript@~3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==

typescript@~3.6.4:
version "3.6.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.4.tgz#b18752bb3792bc1a0281335f7f6ebf1bbfc5b91d"
integrity sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==

uglify-js@1.2.6, uglify-js@~1.2.5:
version "1.2.6"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-1.2.6.tgz#d354b2d3c1cf10ebc18fa78c11a28bdd9ce1580d"
Expand Down