Skip to content

Commit

Permalink
feat: Hide "Specific" structures in declaration file.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: "Specific" structures are no longer exported from the declaration file.

This helps reduce the noise when looking at code completion for a named export from the library.
  • Loading branch information
dsherret committed Sep 15, 2018
1 parent 3d71641 commit db55c33
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
51 changes: 27 additions & 24 deletions lib/ts-simple-ast.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9244,6 +9244,9 @@ export declare class TypeParameterDeclaration extends TypeParameterDeclarationBa
* Removes this type parameter.
*/
remove(): void;
/**
* Gets the structure equivalent to this node.
*/
getStructure(): TypeParameterDeclarationStructure;
}

Expand Down Expand Up @@ -9621,7 +9624,7 @@ export interface ClassDeclarationStructure extends NameableNodeStructure, ClassD
name?: string;
}

export interface ClassDeclarationSpecificStructure {
interface ClassDeclarationSpecificStructure {
extends?: string;
ctors?: ConstructorDeclarationStructure[];
properties?: PropertyDeclarationStructure[];
Expand All @@ -9633,7 +9636,7 @@ export interface ClassDeclarationSpecificStructure {
export interface ConstructorDeclarationStructure extends ConstructorDeclarationSpecificStructure, ScopedNodeStructure, FunctionLikeDeclarationStructure, BodyableNodeStructure {
}

export interface ConstructorDeclarationSpecificStructure {
interface ConstructorDeclarationSpecificStructure {
overloads?: ConstructorDeclarationOverloadStructure[];
}

Expand All @@ -9643,13 +9646,13 @@ export interface ConstructorDeclarationOverloadStructure extends ScopedNodeStruc
export interface GetAccessorDeclarationStructure extends GetAccessorDeclarationSpecificStructure, PropertyNamedNodeStructure, StaticableNodeStructure, DecoratableNodeStructure, AbstractableNodeStructure, ScopedNodeStructure, FunctionLikeDeclarationStructure, BodiedNodeStructure {
}

export interface GetAccessorDeclarationSpecificStructure {
interface GetAccessorDeclarationSpecificStructure {
}

export interface MethodDeclarationStructure extends MethodDeclarationSpecificStructure, PropertyNamedNodeStructure, StaticableNodeStructure, DecoratableNodeStructure, AbstractableNodeStructure, ScopedNodeStructure, AsyncableNodeStructure, GeneratorableNodeStructure, FunctionLikeDeclarationStructure, BodyableNodeStructure {
}

export interface MethodDeclarationSpecificStructure {
interface MethodDeclarationSpecificStructure {
overloads?: MethodDeclarationOverloadStructure[];
}

Expand All @@ -9659,26 +9662,26 @@ export interface MethodDeclarationOverloadStructure extends StaticableNodeStruct
export interface PropertyDeclarationStructure extends PropertyDeclarationSpecificStructure, PropertyNamedNodeStructure, TypedNodeStructure, QuestionTokenableNodeStructure, ExclamationTokenableNodeStructure, StaticableNodeStructure, ScopedNodeStructure, JSDocableNodeStructure, ReadonlyableNodeStructure, InitializerExpressionableNodeStructure, DecoratableNodeStructure, AbstractableNodeStructure {
}

export interface PropertyDeclarationSpecificStructure {
interface PropertyDeclarationSpecificStructure {
}

export interface SetAccessorDeclarationStructure extends SetAccessorDeclarationSpecificStructure, PropertyNamedNodeStructure, StaticableNodeStructure, DecoratableNodeStructure, AbstractableNodeStructure, ScopedNodeStructure, FunctionLikeDeclarationStructure, BodiedNodeStructure {
}

export interface SetAccessorDeclarationSpecificStructure {
interface SetAccessorDeclarationSpecificStructure {
}

export interface PropertyAssignmentStructure extends PropertyAssignmentSpecificStructure, PropertyNamedNodeStructure {
}

export interface PropertyAssignmentSpecificStructure {
interface PropertyAssignmentSpecificStructure {
initializer: string | WriterFunction;
}

export interface ShorthandPropertyAssignmentStructure extends ShorthandPropertyAssignmentSpecificStructure, NamedNodeStructure {
}

export interface ShorthandPropertyAssignmentSpecificStructure {
interface ShorthandPropertyAssignmentSpecificStructure {
}

export interface SpreadAssignmentStructure {
Expand All @@ -9697,15 +9700,15 @@ export interface JSDocStructure {
export interface EnumDeclarationStructure extends NamedNodeStructure, EnumDeclarationSpecificStructure, JSDocableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure {
}

export interface EnumDeclarationSpecificStructure {
interface EnumDeclarationSpecificStructure {
isConst?: boolean;
members?: EnumMemberStructure[];
}

export interface EnumMemberStructure extends EnumMemberSpecificStructure, PropertyNamedNodeStructure, JSDocableNodeStructure, InitializerExpressionableNodeStructure {
}

export interface EnumMemberSpecificStructure {
interface EnumMemberSpecificStructure {
value?: number | string;
}

Expand Down Expand Up @@ -9738,15 +9741,15 @@ export interface SourceFileStructure extends SourceFileSpecificStructure, Statem
bodyText?: string | WriterFunction;
}

export interface SourceFileSpecificStructure {
interface SourceFileSpecificStructure {
imports?: ImportDeclarationStructure[];
exports?: ExportDeclarationStructure[];
}

export interface FunctionDeclarationStructure extends FunctionDeclarationSpecificStructure, NameableNodeStructure, FunctionLikeDeclarationStructure, StatementedNodeStructure, AsyncableNodeStructure, GeneratorableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure, BodyableNodeStructure {
}

export interface FunctionDeclarationSpecificStructure {
interface FunctionDeclarationSpecificStructure {
overloads?: FunctionDeclarationOverloadStructure[];
}

Expand All @@ -9759,26 +9762,26 @@ export interface FunctionLikeDeclarationStructure extends SignaturedDeclarationS
export interface ParameterDeclarationStructure extends DeclarationNamedNodeStructure, TypedNodeStructure, ReadonlyableNodeStructure, DecoratableNodeStructure, QuestionTokenableNodeStructure, ScopeableNodeStructure, InitializerExpressionableNodeStructure, ParameterDeclarationSpecificStructure {
}

export interface ParameterDeclarationSpecificStructure {
interface ParameterDeclarationSpecificStructure {
isRestParameter?: boolean;
}

export interface CallSignatureDeclarationStructure extends CallSignatureDeclarationSpecificStructure, JSDocableNodeStructure, SignaturedDeclarationStructure, TypeParameteredNodeStructure {
}

export interface CallSignatureDeclarationSpecificStructure {
interface CallSignatureDeclarationSpecificStructure {
}

export interface ConstructSignatureDeclarationStructure extends ConstructSignatureDeclarationSpecificStructure, JSDocableNodeStructure, SignaturedDeclarationStructure, TypeParameteredNodeStructure {
}

export interface ConstructSignatureDeclarationSpecificStructure {
interface ConstructSignatureDeclarationSpecificStructure {
}

export interface IndexSignatureDeclarationStructure extends IndexSignatureDeclarationSpecificStructure, JSDocableNodeStructure, ReadonlyableNodeStructure {
}

export interface IndexSignatureDeclarationSpecificStructure {
interface IndexSignatureDeclarationSpecificStructure {
keyName?: string;
keyType?: string;
returnType: string | WriterFunction;
Expand All @@ -9787,19 +9790,19 @@ export interface IndexSignatureDeclarationSpecificStructure {
export interface InterfaceDeclarationStructure extends NamedNodeStructure, InterfaceDeclarationSpecificStructure, ExtendsClauseableNodeStructure, TypeParameteredNodeStructure, JSDocableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure, TypeElementMemberedNodeStructure {
}

export interface InterfaceDeclarationSpecificStructure {
interface InterfaceDeclarationSpecificStructure {
}

export interface MethodSignatureStructure extends PropertyNamedNodeStructure, MethodSignatureSpecificStructure, QuestionTokenableNodeStructure, JSDocableNodeStructure, SignaturedDeclarationStructure, TypeParameteredNodeStructure {
}

export interface MethodSignatureSpecificStructure {
interface MethodSignatureSpecificStructure {
}

export interface PropertySignatureStructure extends PropertySignatureSpecificStructure, PropertyNamedNodeStructure, TypedNodeStructure, QuestionTokenableNodeStructure, JSDocableNodeStructure, ReadonlyableNodeStructure, InitializerExpressionableNodeStructure {
}

export interface PropertySignatureSpecificStructure {
interface PropertySignatureSpecificStructure {
}

export interface JsxAttributeStructure extends JsxAttributeStructureSpecific, NamedNodeStructure {
Expand All @@ -9825,7 +9828,7 @@ export interface JsxSpreadAttributeStructure {
export interface NamespaceDeclarationStructure extends NamedNodeStructure, NamespaceDeclarationSpecificStructure, JSDocableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure, StatementedNodeStructure, BodiedNodeStructure {
}

export interface NamespaceDeclarationSpecificStructure {
interface NamespaceDeclarationSpecificStructure {
/**
* If the namespace has the module keyword.
*/
Expand All @@ -9844,21 +9847,21 @@ export interface StatementedNodeStructure {
export interface VariableDeclarationListStructure extends VariableDeclarationListSpecificStructure {
}

export interface VariableDeclarationListSpecificStructure {
interface VariableDeclarationListSpecificStructure {
declarationKind?: VariableDeclarationKind;
declarations: VariableDeclarationStructure[];
}

export interface VariableDeclarationStructure extends VariableDeclarationSpecificStructure, BindingNamedNodeStructure, InitializerExpressionableNodeStructure, TypedNodeStructure, ExclamationTokenableNodeStructure {
}

export interface VariableDeclarationSpecificStructure {
interface VariableDeclarationSpecificStructure {
}

export interface VariableStatementStructure extends VariableStatementSpecificStructure, JSDocableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure {
}

export interface VariableStatementSpecificStructure {
interface VariableStatementSpecificStructure {
declarationKind?: VariableDeclarationKind;
declarations: VariableDeclarationStructure[];
}
Expand All @@ -9867,7 +9870,7 @@ export interface TypeAliasDeclarationStructure extends TypeAliasDeclarationSpeci
type: string | WriterFunction;
}

export interface TypeAliasDeclarationSpecificStructure {
interface TypeAliasDeclarationSpecificStructure {
type: string | WriterFunction;
}

Expand Down
7 changes: 7 additions & 0 deletions scripts/generation/createDeclarationFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const mainFile = project.getSourceFileOrThrow("main.d.ts");
flattenDeclarationFiles(project, mainFile);
removeImportTypes(mainFile);
hideBaseDeclarations();
hideSpecificStructures();
removeSkipOrThrowCheck();

project.save();
Expand All @@ -33,6 +34,12 @@ function hideBaseDeclarations() {
}
}

function hideSpecificStructures() {
const specificStructures = mainFile.getInterfaces().filter(s => StringUtils.endsWith(s.getName(), "SpecificStructure"));
for (const structure of specificStructures)
structure.setIsExported(false);
}

function removeSkipOrThrowCheck() {
// no real good support for jsdocs yet so doing this regex solution that I know will work
mainFile.replaceWithText(mainFile.getFullText().replace(/\n\s+\*\s+@skipOrThrowCheck\r?\n/g, "\n"));
Expand Down

1 comment on commit db55c33

@dsherret
Copy link
Owner Author

Choose a reason for hiding this comment

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

For #419.

Please sign in to comment.