Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: remove unnecessary stability check #23176

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion tools/ts-api-guardian/index.bzl
Expand Up @@ -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]
Expand Down
13 changes: 2 additions & 11 deletions tools/ts-api-guardian/lib/cli.ts
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
}

Expand Down
11 changes: 0 additions & 11 deletions tools/ts-api-guardian/lib/serializer.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
13 changes: 0 additions & 13 deletions tools/ts-api-guardian/test/cli_e2e_test.ts
Expand Up @@ -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) {
Expand Down
16 changes: 0 additions & 16 deletions tools/ts-api-guardian/test/unit_test.ts
Expand Up @@ -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 {
Expand Down