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.
|
# From there, the relative imports would point to .ts files.
|
||||||
"--node_options=--preserve-symlinks",
|
"--node_options=--preserve-symlinks",
|
||||||
"--stripExportPattern", "^\(__\|ɵ\)",
|
"--stripExportPattern", "^\(__\|ɵ\)",
|
||||||
"--onStabilityMissing", "error",
|
|
||||||
]
|
]
|
||||||
for i in COMMON_MODULE_IDENTIFIERS:
|
for i in COMMON_MODULE_IDENTIFIERS:
|
||||||
args += ["--allowModuleIdentifiers", i]
|
args += ["--allowModuleIdentifiers", i]
|
||||||
|
|
|
@ -24,14 +24,8 @@ export function startCli() {
|
||||||
const options: SerializationOptions = {
|
const options: SerializationOptions = {
|
||||||
stripExportPattern: argv['stripExportPattern'],
|
stripExportPattern: argv['stripExportPattern'],
|
||||||
allowModuleIdentifiers: [].concat(argv['allowModuleIdentifiers']),
|
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) {
|
for (const error of errors) {
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +79,7 @@ export function parseArguments(input: string[]):
|
||||||
const argv = minimist(input, {
|
const argv = minimist(input, {
|
||||||
string: [
|
string: [
|
||||||
'out', 'outDir', 'verify', 'verifyDir', 'rootDir', 'stripExportPattern',
|
'out', 'outDir', 'verify', 'verifyDir', 'rootDir', 'stripExportPattern',
|
||||||
'allowModuleIdentifiers', 'onStabilityMissing'
|
'allowModuleIdentifiers'
|
||||||
],
|
],
|
||||||
boolean: [
|
boolean: [
|
||||||
'help',
|
'help',
|
||||||
|
@ -161,10 +155,7 @@ Options:
|
||||||
|
|
||||||
--stripExportPattern <regexp> Do not output exports matching the pattern
|
--stripExportPattern <regexp> Do not output exports matching the pattern
|
||||||
--allowModuleIdentifiers <identifier>
|
--allowModuleIdentifiers <identifier>
|
||||||
Whitelist identifier for "* as foo" imports
|
Whitelist identifier for "* as foo" imports`);
|
||||||
--onStabilityMissing <warn|error|none>
|
|
||||||
Warn or error if an export has no stability
|
|
||||||
annotation`);
|
|
||||||
process.exit(error ? 1 : 0);
|
process.exit(error ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,6 @@ export interface SerializationOptions {
|
||||||
* whitelisting angular.
|
* whitelisting angular.
|
||||||
*/
|
*/
|
||||||
allowModuleIdentifiers?: string[];
|
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';
|
export type DiagnosticSeverity = 'warn' | 'error' | 'none';
|
||||||
|
@ -124,12 +119,6 @@ class ResolvedDeclarationEmitter {
|
||||||
const match = stabilityAnnotationPattern.exec(trivia);
|
const match = stabilityAnnotationPattern.exec(trivia);
|
||||||
if (match) {
|
if (match) {
|
||||||
output += `/** @${match[1]} */\n`;
|
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';
|
output += stripEmptyLines(this.emitNode(decl)) + '\n';
|
||||||
|
|
|
@ -114,19 +114,6 @@ describe('cli: e2e test', () => {
|
||||||
chai.assert.equal(stdout, '');
|
chai.assert.equal(stdout, '');
|
||||||
chai.assert.equal(status, 0);
|
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) {
|
function copyFile(sourceFile: string, targetFile: string) {
|
||||||
|
|
|
@ -460,22 +460,6 @@ describe('unit test', () => {
|
||||||
`;
|
`;
|
||||||
check({'file.d.ts': input}, expected);
|
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 {
|
function getMockHost(files: {[name: string]: string}): ts.CompilerHost {
|
||||||
|
|
Loading…
Reference in New Issue