Skip to content

Commit f1119ff

Browse files
alan-agius4mgechev
authored andcommitted
build: fix typescript 3.9 compilation
1 parent 1b2847e commit f1119ff

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

packages/angular_devkit/core/src/utils/object.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
export function mapObject<T, V>(obj: {[k: string]: T},
10-
mapper: (k: string, v: T) => V): {[k: string]: V} {
11-
return Object.keys(obj).reduce((acc: {[k: string]: V}, k: string) => {
9+
export function mapObject<T, V>(obj: { [k: string]: T },
10+
mapper: (k: string, v: T) => V): { [k: string]: V } {
11+
return Object.keys(obj).reduce((acc: { [k: string]: V }, k: string) => {
1212
acc[k] = mapper(k, obj[k]);
1313

1414
return acc;
@@ -19,24 +19,33 @@ export function mapObject<T, V>(obj: {[k: string]: T},
1919
const copySymbol = Symbol();
2020

2121
// tslint:disable-next-line:no-any
22-
export function deepCopy<T extends any> (value: T): T {
22+
export function deepCopy<T extends any>(value: T): T {
2323
if (Array.isArray(value)) {
24-
return value.map((o: T) => deepCopy(o));
24+
// tslint:disable-next-line:no-any
25+
return value.map((o: any) => deepCopy(o)) as unknown as T;
2526
} else if (value && typeof value === 'object') {
26-
if (value[copySymbol]) {
27+
const valueCasted = value as {
28+
[copySymbol]?: T,
29+
toJSON?: () => string,
30+
// tslint:disable-next-line:no-any
31+
[key: string]: any,
32+
};
33+
34+
if (valueCasted[copySymbol]) {
2735
// This is a circular dependency. Just return the cloned value.
28-
return value[copySymbol];
36+
return valueCasted[copySymbol] as T;
2937
}
30-
if (value['toJSON']) {
31-
return JSON.parse((value['toJSON'] as () => string)());
38+
39+
if (valueCasted['toJSON']) {
40+
return JSON.parse(valueCasted['toJSON']());
3241
}
3342

34-
const copy = new (Object.getPrototypeOf(value).constructor)();
35-
value[copySymbol] = copy;
36-
for (const key of Object.getOwnPropertyNames(value)) {
37-
copy[key] = deepCopy(value[key]);
43+
const copy = new (Object.getPrototypeOf(valueCasted).constructor)();
44+
valueCasted[copySymbol] = copy;
45+
for (const key of Object.getOwnPropertyNames(valueCasted)) {
46+
copy[key] = deepCopy(valueCasted[key]);
3847
}
39-
value[copySymbol] = undefined;
48+
valueCasted[copySymbol] = undefined;
4049

4150
return copy;
4251
} else {

packages/ngtools/webpack/src/compiler_host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
361361
getCanonicalFileName(fileName: string): string {
362362
const path = this.resolve(fileName);
363363

364-
return this.useCaseSensitiveFileNames ? path : path.toLowerCase();
364+
return this.useCaseSensitiveFileNames() ? path : path.toLowerCase();
365365
}
366366

367367
useCaseSensitiveFileNames(): boolean {

packages/ngtools/webpack/src/transformers/replace_resources.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function replaceResources(
1717
return (context: ts.TransformationContext) => {
1818
const typeChecker = getTypeChecker();
1919

20-
const visitNode: ts.Visitor = (node: ts.Decorator) => {
20+
const visitNode: ts.Visitor = (node: ts.Node) => {
2121
if (ts.isClassDeclaration(node)) {
2222
const decorators = ts.visitNodes(
2323
node.decorators,

0 commit comments

Comments
 (0)