Skip to content

Commit 163649a

Browse files
committed
Relax AstNamespace validation to allow type references
1 parent 2c92b1d commit 163649a

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎apps/api-extractor/src/ast/AstNamespace.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,17 @@ export class AstNamespace extends AstModule {
8686
}
8787

8888
const propertySignature: ts.PropertySignature = declaration as ts.PropertySignature;
89-
if (!propertySignature.type || allowedTypes.indexOf(propertySignature.type.getText()) < 0) {
90-
this.reportWarning(`Export "${exportSymbol.name}" must specify and be of type` +
91-
'"string", "number" or "boolean"');
89+
90+
if (!propertySignature.type) {
91+
this.reportWarning(`Export "${exportSymbol.name}" must specify a type`);
92+
continue;
93+
}
94+
95+
// Note that we also allow type references that refer to one of the supported primitive types
96+
if (propertySignature.type.kind !== ts.SyntaxKind.TypeReference
97+
&& allowedTypes.indexOf(propertySignature.type.getText()) < 0) {
98+
this.reportWarning(`Export "${exportSymbol.name}" must be of type` +
99+
' "string", "number" or "boolean" when API Extractor is configured for conservative namespaces');
92100
continue;
93101
}
94102

0 commit comments

Comments
 (0)