build: remove unnecessary stability check (#23176)
Previously, it was necessary to attach on of the three "stability" jsdoc tags (`@stable`, `@deprecated` or `@experimental`) to each public API export. To ensure that the public API was correctly tagged, the `ts-api-guardian` would check that one of these tags appeared on every public export. Now the doc-gen is able to compute that a code item is stable if it does not contain the `@experimental` nor `@deprecated` tags. Therefore there is no need to provide the `@stable` tag any more; and this tag has now been marked as deprecated - i.e. it should not be used. The ts-api-guardian has been modified in this commit so that it no longer warns/fails if the `@stable` is missing. PR Close #23176
This commit is contained in:
parent
b8053f1d4f
commit
ac316be79b
|
@ -31,7 +31,6 @@ def ts_api_guardian_test(name, golden, actual, data = [], **kwargs):
|
|||
# From there, the relative imports would point to .ts files.
|
||||
"--node_options=--preserve-symlinks",
|
||||
"--stripExportPattern", "^\(__\|ɵ\)",
|
||||
"--onStabilityMissing", "error",
|
||||
]
|
||||
for i in COMMON_MODULE_IDENTIFIERS:
|
||||
args += ["--allowModuleIdentifiers", i]
|
||||
|
|
|
@ -24,14 +24,8 @@ export function startCli() {
|
|||
const options: SerializationOptions = {
|
||||
stripExportPattern: argv['stripExportPattern'],
|
||||
allowModuleIdentifiers: [].concat(argv['allowModuleIdentifiers']),
|
||||
onStabilityMissing: argv['onStabilityMissing'] || 'none'
|
||||
};
|
||||
|
||||
if (['warn', 'error', 'none'].indexOf(options.onStabilityMissing as string) < 0) {
|
||||
throw new Error(
|
||||
'Argument for "--onStabilityMissing" option must be one of: "warn", "error", "none"');
|
||||
}
|
||||
|
||||
for (const error of errors) {
|
||||
console.warn(error);
|
||||
}
|
||||
|
@ -85,7 +79,7 @@ export function parseArguments(input: string[]):
|
|||
const argv = minimist(input, {
|
||||
string: [
|
||||
'out', 'outDir', 'verify', 'verifyDir', 'rootDir', 'stripExportPattern',
|
||||
'allowModuleIdentifiers', 'onStabilityMissing'
|
||||
'allowModuleIdentifiers'
|
||||
],
|
||||
boolean: [
|
||||
'help',
|
||||
|
@ -161,10 +155,7 @@ Options:
|
|||
|
||||
--stripExportPattern <regexp> Do not output exports matching the pattern
|
||||
--allowModuleIdentifiers <identifier>
|
||||
Whitelist identifier for "* as foo" imports
|
||||
--onStabilityMissing <warn|error|none>
|
||||
Warn or error if an export has no stability
|
||||
annotation`);
|
||||
Whitelist identifier for "* as foo" imports`);
|
||||
process.exit(error ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,6 @@ export interface SerializationOptions {
|
|||
* whitelisting angular.
|
||||
*/
|
||||
allowModuleIdentifiers?: string[];
|
||||
/**
|
||||
* Warns or errors if stability annotations are missing on an export.
|
||||
* Supports experimental, stable and deprecated.
|
||||
*/
|
||||
onStabilityMissing?: DiagnosticSeverity;
|
||||
}
|
||||
|
||||
export type DiagnosticSeverity = 'warn' | 'error' | 'none';
|
||||
|
@ -124,12 +119,6 @@ class ResolvedDeclarationEmitter {
|
|||
const match = stabilityAnnotationPattern.exec(trivia);
|
||||
if (match) {
|
||||
output += `/** @${match[1]} */\n`;
|
||||
} else if (['warn', 'error'].indexOf(this.options.onStabilityMissing as string) >= 0) {
|
||||
this.diagnostics.push({
|
||||
type: this.options.onStabilityMissing,
|
||||
message: createErrorMessage(
|
||||
decl, `No stability annotation found for symbol "${symbol.name}"`)
|
||||
});
|
||||
}
|
||||
|
||||
output += stripEmptyLines(this.emitNode(decl)) + '\n';
|
||||
|
|
|
@ -114,19 +114,6 @@ describe('cli: e2e test', () => {
|
|||
chai.assert.equal(stdout, '');
|
||||
chai.assert.equal(status, 0);
|
||||
});
|
||||
|
||||
it('should respect --onStabilityMissing', () => {
|
||||
const {stdout, stderr, status} = execute([
|
||||
'--verify', 'test/fixtures/simple_expected.d.ts', '--onStabilityMissing', 'warn',
|
||||
'test/fixtures/simple.d.ts'
|
||||
]);
|
||||
chai.assert.equal(stdout, '');
|
||||
chai.assert.equal(
|
||||
stderr,
|
||||
'test/fixtures/simple.d.ts(1,1): error: No stability annotation found for symbol "A"\n' +
|
||||
'test/fixtures/simple.d.ts(2,1): error: No stability annotation found for symbol "B"\n');
|
||||
chai.assert.equal(status, 0, stderr);
|
||||
});
|
||||
});
|
||||
|
||||
function copyFile(sourceFile: string, targetFile: string) {
|
||||
|
|
|
@ -460,22 +460,6 @@ describe('unit test', () => {
|
|||
`;
|
||||
check({'file.d.ts': input}, expected);
|
||||
});
|
||||
|
||||
it('should warn on onStabilityMissing: warn', () => {
|
||||
const input = `
|
||||
export declare class A {
|
||||
constructor();
|
||||
}
|
||||
`;
|
||||
const expected = `
|
||||
export declare class A {
|
||||
constructor();
|
||||
}
|
||||
`;
|
||||
check({'file.d.ts': input}, expected, {onStabilityMissing: 'warn'});
|
||||
chai.assert.deepEqual(
|
||||
warnings, ['file.d.ts(1,1): error: No stability annotation found for symbol "A"']);
|
||||
});
|
||||
});
|
||||
|
||||
function getMockHost(files: {[name: string]: string}): ts.CompilerHost {
|
||||
|
|
Loading…
Reference in New Issue