Skip to content

Commit

Permalink
feat(@angular/cli): support TypeScript 4.2
Browse files Browse the repository at this point in the history
BREAKING CHANGE

Drop support for TypeScript versions prior to 4.2.3
  • Loading branch information
alan-agius4 committed Mar 17, 2021
1 parent b1fa5bd commit 7985664
Show file tree
Hide file tree
Showing 13 changed files with 5,483 additions and 2,940 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"tslint": "^6.1.3",
"tslint-no-circular-imports": "^0.7.0",
"tslint-sonarts": "1.9.0",
"typescript": "4.1.5",
"typescript": "4.2.3",
"verdaccio": "4.12.0",
"verdaccio-auth-memory": "^9.7.2",
"webpack": "4.44.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"protractor": "^7.0.0",
"tailwindcss": "^2.0.0",
"tslint": "^6.1.0",
"typescript": "~4.0.0 || ~4.1.0"
"typescript": "~4.2.3"
},
"peerDependenciesMeta": {
"@angular/localize": {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"loader-utils": "2.0.0",
"source-map": "0.7.3",
"tslib": "2.1.0",
"typescript": "4.1.5",
"typescript": "4.2.3",
"webpack-sources": "2.2.0"
},
"peerDependencies": {
Expand Down
28 changes: 16 additions & 12 deletions packages/angular_devkit/core/src/workspace/json/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ type ChangeReporter = (
current?: JsonValue,
) => void;

// lib.es5 PropertyKey is string | number | symbol which doesn't overlap ProxyHandler PropertyKey which is string | symbol.
// See https://github.com/microsoft/TypeScript/issues/42894
type ProxyPropertyKey = string | symbol;

function findNode(
parent: JsonAstArray | JsonAstObject,
p: PropertyKey,
p: ProxyPropertyKey,
): { node?: JsonAstNode; parent: JsonAstArray | JsonAstKeyValue | JsonAstObject } {
if (parent.kind === 'object') {
const entry = parent.properties.find(entry => entry.key.value === p);
Expand Down Expand Up @@ -120,8 +124,8 @@ function create(
ast: JsonAstObject | JsonAstArray,
path: string,
reporter: ChangeReporter,
excluded = new Set<PropertyKey>(),
included?: Set<PropertyKey>,
excluded = new Set<ProxyPropertyKey>(),
included?: Set<ProxyPropertyKey>,
base?: object,
) {
const cache = new Map<string, CacheEntry>();
Expand All @@ -137,7 +141,7 @@ function create(
}

return new Proxy(base, {
getOwnPropertyDescriptor(target: {}, p: PropertyKey): PropertyDescriptor | undefined {
getOwnPropertyDescriptor(target: {}, p: ProxyPropertyKey): PropertyDescriptor | undefined {
const descriptor = Reflect.getOwnPropertyDescriptor(target, p);
if (descriptor || typeof p === 'symbol') {
return descriptor;
Expand All @@ -162,7 +166,7 @@ function create(

return undefined;
},
has(target: {}, p: PropertyKey): boolean {
has(target: {}, p: ProxyPropertyKey): boolean {
if (Reflect.has(target, p)) {
return true;
} else if (typeof p === 'symbol' || excluded.has(p)) {
Expand All @@ -171,7 +175,7 @@ function create(

return cache.has(path + '/' + escapeKey(p)) || findNode(ast, p) !== undefined;
},
get(target: {}, p: PropertyKey): unknown {
get(target: {}, p: ProxyPropertyKey): unknown {
if (typeof p === 'symbol' || Reflect.has(target, p)) {
return Reflect.get(target, p);
} else if (excluded.has(p) || (included && !included.has(p))) {
Expand Down Expand Up @@ -206,7 +210,7 @@ function create(

return value;
},
set(target: {}, p: PropertyKey, value: unknown): boolean {
set(target: {}, p: ProxyPropertyKey, value: unknown): boolean {
if (value === undefined) {
// setting to undefined is equivalent to a delete
// tslint:disable-next-line: no-non-null-assertion
Expand Down Expand Up @@ -242,7 +246,7 @@ function create(

return true;
},
deleteProperty(target: {}, p: PropertyKey): boolean {
deleteProperty(target: {}, p: ProxyPropertyKey): boolean {
if (typeof p === 'symbol' || Reflect.has(target, p)) {
return Reflect.deleteProperty(target, p);
} else if (excluded.has(p) || (included && !included.has(p))) {
Expand Down Expand Up @@ -279,15 +283,15 @@ function create(

return true;
},
defineProperty(target: {}, p: PropertyKey, attributes: PropertyDescriptor): boolean {
defineProperty(target: {}, p: ProxyPropertyKey, attributes: PropertyDescriptor): boolean {
if (typeof p === 'symbol') {
return Reflect.defineProperty(target, p, attributes);
}

return false;
},
ownKeys(target: {}): PropertyKey[] {
let keys: PropertyKey[];
ownKeys(target: {}): ProxyPropertyKey[] {
let keys: ProxyPropertyKey[];
if (ast.kind === 'object') {
keys = ast.properties
.map(entry => entry.key.value)
Expand All @@ -299,7 +303,7 @@ function create(
for (const key of cache.keys()) {
const relativeKey = key.substr(path.length + 1);
if (relativeKey.length > 0 && !relativeKey.includes('/')) {
keys.push(unescapeKey(relativeKey));
keys.push(`${unescapeKey(relativeKey)}`);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ngtools/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
},
"peerDependencies": {
"@angular/compiler-cli": "^12.0.0-next",
"typescript": "~4.0.0 || ~4.1.0",
"typescript": "~4.2.3",
"webpack": "^4.0.0 || ^5.20.0"
},
"devDependencies": {
"@angular/compiler": "12.0.0-next.4",
"@angular/compiler-cli": "12.0.0-next.4",
"typescript": "4.1.5",
"typescript": "4.2.3",
"webpack": "5.21.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//tools:defaults.bzl", "ts_library")

# files fetched on 2020-08-24 from
# https://github.com/microsoft/TypeScript/releases/tag/v4.0.2
# files fetched on 2021-03-17 from
# https://github.com/microsoft/TypeScript/releases/tag/v4.2.3
licenses(["notice"]) # Apache 2.0

ts_library(
Expand Down
Loading

0 comments on commit 7985664

Please sign in to comment.