Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@angular/cli): support TypeScript 4.2 #20303

Merged
merged 1 commit into from Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
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
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
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
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
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"
}
}
@@ -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