Skip to content

Commit a85ba99

Browse files
alan-agius4filipesilva
authored andcommitted
refactor: clean up several files
Most of these changes are requires for TS 4 update
1 parent 6fb2c4b commit a85ba99

File tree

6 files changed

+11
-20
lines changed

6 files changed

+11
-20
lines changed

packages/angular/cli/lib/init.ts

-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ if (process.env['NG_CLI_PROFILING']) {
155155
try {
156156
standardInput = process.stdin;
157157
} catch (e) {
158-
delete process.stdin;
159158
process.stdin = new Duplex();
160159
standardInput = process.stdin;
161160
}

packages/angular/cli/models/analytics.ts

+3-11
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,7 @@ function _getRamSize() {
139139
* @private
140140
*/
141141
function _getNodeVersion() {
142-
// We use any here because p.release is a new Node construct in Node 10 (and our typings are the
143-
// minimal version of Node we support).
144-
const p = process as any; // tslint:disable-line:no-any
145-
const name =
146-
(typeof p.release == 'object' && typeof p.release.name == 'string' && p.release.name) ||
147-
process.argv0;
142+
const name = process.release.name || process.argv0;
148143

149144
return name + ' ' + process.version;
150145
}
@@ -590,9 +585,7 @@ export async function getWorkspaceAnalytics(): Promise<UniversalAnalytics | unde
590585
analyticsDebug('getWorkspaceAnalytics');
591586
try {
592587
const globalWorkspace = await getWorkspace('local');
593-
const analyticsConfig: string | undefined | null | { uid?: string } = globalWorkspace
594-
&& globalWorkspace.getCli()
595-
&& globalWorkspace.getCli()['analytics'];
588+
const analyticsConfig: string | undefined | null | { uid?: string } = globalWorkspace?.getCli()['analytics'];
596589
analyticsDebug('Workspace Analytics config found: %j', analyticsConfig);
597590

598591
if (analyticsConfig === false) {
@@ -645,8 +638,7 @@ export async function getSharedAnalytics(): Promise<UniversalAnalytics | undefin
645638
// If anything happens we just keep the NOOP analytics.
646639
try {
647640
const globalWorkspace = await getWorkspace('global');
648-
const analyticsConfig =
649-
globalWorkspace && globalWorkspace.getCli() && globalWorkspace.getCli()['analyticsSharing'];
641+
const analyticsConfig = globalWorkspace?.getCli()['analyticsSharing'];
650642

651643
if (!analyticsConfig || !analyticsConfig.tracking || !analyticsConfig.uuid) {
652644
return undefined;

packages/angular/cli/utilities/json-schema.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ function _getEnumFromValue<E, T extends E[keyof E]>(
3535
return defaultValue;
3636
}
3737

38-
if (Object.values(enumeration).indexOf(value) !== -1) {
39-
// TODO: this should be unknown
40-
// tslint:disable-next-line:no-any
41-
return value as any as T;
38+
if (Object.values(enumeration).includes(value)) {
39+
return value as unknown as T;
4240
}
4341

4442
return defaultValue;

packages/angular_devkit/architect_cli/bin/architect.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async function _executeTarget(
8484
const targetSpec = { project, target, configuration };
8585
8686
delete argv['help'];
87-
delete argv['_'];
87+
argv['_'] = [];
8888
8989
const logger = new logging.Logger('jobs');
9090
const logs: logging.LogEntry[] = [];

packages/angular_devkit/schematics_cli/bin/schematics.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ export async function main({
267267
return argv._;
268268
}
269269
});
270-
delete parsedArgs._;
270+
271+
parsedArgs._ = [];
271272

272273
// Add prompts.
273274
if (argv['interactive'] && isTTY()) {

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ export function makeTransform(
9999
// If TS sees an empty decorator array, it will still emit a `__decorate` call.
100100
// This seems to be a TS bug.
101101
function cleanupDecorators(node: ts.Node) {
102-
if (node.decorators && node.decorators.length === 0) {
103-
node.decorators = undefined;
102+
if (node.decorators?.length === 0) {
103+
// tslint:disable-next-line:no-any
104+
(node as any).decorators = undefined;
104105
}
105106

106107
ts.forEachChild(node, node => cleanupDecorators(node));

0 commit comments

Comments
 (0)