From 5fda66a260309605b3c084c3e77aa785b3e7f16c Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Wed, 4 Apr 2018 21:31:34 +0100 Subject: [PATCH] build: remove unnecessary stability check 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. --- tools/ts-api-guardian/index.bzl | 1 - tools/ts-api-guardian/lib/cli.ts | 13 ++----------- tools/ts-api-guardian/lib/serializer.ts | 11 ----------- tools/ts-api-guardian/test/cli_e2e_test.ts | 13 ------------- tools/ts-api-guardian/test/unit_test.ts | 16 ---------------- 5 files changed, 2 insertions(+), 52 deletions(-) diff --git a/tools/ts-api-guardian/index.bzl b/tools/ts-api-guardian/index.bzl index cbb3551c71240..702b210e5ae9e 100644 --- a/tools/ts-api-guardian/index.bzl +++ b/tools/ts-api-guardian/index.bzl @@ -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] diff --git a/tools/ts-api-guardian/lib/cli.ts b/tools/ts-api-guardian/lib/cli.ts index ff35a70d16389..6bed270678009 100644 --- a/tools/ts-api-guardian/lib/cli.ts +++ b/tools/ts-api-guardian/lib/cli.ts @@ -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 Do not output exports matching the pattern --allowModuleIdentifiers - Whitelist identifier for "* as foo" imports - --onStabilityMissing - Warn or error if an export has no stability - annotation`); + Whitelist identifier for "* as foo" imports`); process.exit(error ? 1 : 0); } diff --git a/tools/ts-api-guardian/lib/serializer.ts b/tools/ts-api-guardian/lib/serializer.ts index 222568b118a69..5e442b2e45a00 100644 --- a/tools/ts-api-guardian/lib/serializer.ts +++ b/tools/ts-api-guardian/lib/serializer.ts @@ -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'; diff --git a/tools/ts-api-guardian/test/cli_e2e_test.ts b/tools/ts-api-guardian/test/cli_e2e_test.ts index 292bc6e6d4286..7e102ac8783d0 100644 --- a/tools/ts-api-guardian/test/cli_e2e_test.ts +++ b/tools/ts-api-guardian/test/cli_e2e_test.ts @@ -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) { diff --git a/tools/ts-api-guardian/test/unit_test.ts b/tools/ts-api-guardian/test/unit_test.ts index b968eda3297ff..faa1ab903afad 100644 --- a/tools/ts-api-guardian/test/unit_test.ts +++ b/tools/ts-api-guardian/test/unit_test.ts @@ -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 {