Skip to content

Commit 10f2449

Browse files
alan-agius4dgp1130
authored andcommitted
fix(@angular/cli): remove deprecation warning of no prefixed schema options
Prefixing options with `no` in schema definitions appears to be used more widely than initially thought. The `noOption` can also be provided in the `angular.json` which makes this property definition less ambiguous, since boolean options don't get prefixed with `no` in the JSON config. Therefore, in order to reduce the community changes we remove the deprecation warning for such options and change the interim solution to permanent one. None-the-less, it's still recommended that options are defined without the `no` prefix. (cherry picked from commit 6693459)
1 parent d396eba commit 10f2449

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

packages/angular/cli/src/command-builder/command-module.ts

+3-10
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,12 @@ export abstract class CommandModule<T extends {} = {}> implements CommandModuleI
226226
...(this.context.args.options.help ? { default: defaultVal } : {}),
227227
};
228228

229-
// TODO(alanagius4): remove in a major version.
230-
// the below is an interim workaround to handle options which have been defined in the schema with `no` prefix.
231229
let dashedName = strings.dasherize(name);
230+
231+
// Handle options which have been defined in the schema with `no` prefix.
232232
if (type === 'boolean' && dashedName.startsWith('no-')) {
233233
dashedName = dashedName.slice(3);
234234
booleanOptionsWithNoPrefix.add(dashedName);
235-
236-
// eslint-disable-next-line no-console
237-
console.warn(
238-
`Warning: '${name}' option has been declared with a 'no' prefix in the schema.` +
239-
'Please file an issue with the author of this package.',
240-
);
241235
}
242236

243237
if (positional === undefined) {
@@ -258,8 +252,7 @@ export abstract class CommandModule<T extends {} = {}> implements CommandModuleI
258252
}
259253
}
260254

261-
// TODO(alanagius4): remove in a major version.
262-
// the below is an interim workaround to handle options which have been defined in the schema with `no` prefix.
255+
// Handle options which have been defined in the schema with `no` prefix.
263256
if (booleanOptionsWithNoPrefix.size) {
264257
localYargs.middleware((options: Arguments) => {
265258
for (const key of booleanOptionsWithNoPrefix) {

tests/legacy-cli/e2e/tests/misc/negated-boolean-options.ts

-6
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,4 @@ export default async function () {
1515
['generate', './schematic-boolean-option-negated:test', '--watch'],
1616
/noWatch: false/,
1717
);
18-
19-
await execAndWaitForOutputToMatch(
20-
'ng',
21-
['generate', './schematic-boolean-option-negated:test'],
22-
/'noWatch' option has been declared with a 'no' prefix in the schema/,
23-
);
2418
}

0 commit comments

Comments
 (0)