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

[api-extractor] Implement "ae-internal-missing-underscore" warning #1170

Merged
merged 6 commits into from
Mar 21, 2019

Conversation

octogonz
Copy link
Collaborator

This PR reintroduces the warning for API items that are marked as @internal, but whose name does not start with an underscore. The tricky part of the work involves tagging the warning message so that the ReviewFileGenerator can print the warning next to the export statement.

Consider this example:

/**
 * @internal
 */
class _MyClass {
}

// The class declaration uses the name "_MyClass".  But the name that needs the underscore prefix
// is the **exported** name.  So when we emit the ae-internal-missing-underscore warning 
// in the .api.md file, it should go next to the line below, NOT next to the class declaration.
export { _MyClass as MyClass };

// The same class can be exported more than once.  "OtherName" also needs a warning,
// and that warning should be printed next to the line below.
export { _MyClass as OtherName };

- Introduce ExtractorMessage.properties to track the affected name
…portName is present, then the warning messages are written next to the associated export statement, rather than next to the declaration
class A {
}

// Warning: (ae-internal-missing-underscore) The name B should be prefixed with an underscore because the declaration is marked as "@internal"
export { A as B }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example where the warning is associated with the export statement.

@@ -60,11 +60,15 @@ export namespace EntangledNamespace {
// @alpha
export type ExportedAlias = AlphaClass;

// Warning: (ae-internal-missing-underscore) The name InternalClass should be prefixed with an underscore because the declaration is marked as "@internal"
//
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the warning is associated with the class declaration, since it uses an inline export.

Copy link
Member

@iclanton iclanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants