Socket
Socket
Sign inDemoInstall

@microsoft/api-extractor

Package Overview
Dependencies
Maintainers
2
Versions
486
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/api-extractor - npm Package Compare versions

Comparing version 1.1.9 to 1.1.10

lib/example2-output.ts

12

CHANGELOG.json

@@ -5,2 +5,14 @@ {

{
"version": "1.1.10",
"tag": "@microsoft/api-extractor_v1.1.10",
"date": "Fri, 10 Feb 2017 20:01:30 GMT",
"comments": {
"patch": [
{
"comment": " Added support to not throw error, instead report error if no type is declared on properties and parameters"
}
]
}
},
{
"version": "1.1.9",

@@ -7,0 +19,0 @@ "tag": "@microsoft/api-extractor_v1.1.9",

9

CHANGELOG.md
# Change Log - @microsoft/api-extractor
This log was last generated on Tue, 07 Feb 2017 20:37:06 GMT and should not be manually modified.
This log was last generated on Fri, 10 Feb 2017 20:01:30 GMT and should not be manually modified.
## 1.1.10
Fri, 10 Feb 2017 20:01:30 GMT
### Patches
- Added support to not throw error, instead report error if no type is declared on properties and parameters
## 1.1.9

@@ -6,0 +13,0 @@ Tue, 07 Feb 2017 20:37:06 GMT

4

lib/definitions/ApiDocumentation.d.ts

@@ -102,3 +102,5 @@ /// <reference types="es6-collections" />

returnsMessage: IDocElement[];
parameters: Map<string, IParam>;
parameters: {
[name: string]: IParam;
};
/**

@@ -105,0 +107,0 @@ * An "API Tag" is a custom JSDoc tag which indicates whether this definition

@@ -46,3 +46,3 @@ /* tslint:disable:no-bitwise */

this.reportError = errorLogger;
this.parameters = new Map();
this.parameters = {};
this._parseDocs();

@@ -49,0 +49,0 @@ }

@@ -29,3 +29,3 @@ "use strict";

var declarationSymbol = TypeScriptHelpers_1.default.tryGetSymbolForDeclaration(param);
_this.params.push(new ApiParameter_1.default({
var apiParameter = new ApiParameter_1.default({
extractor: _this.extractor,

@@ -35,6 +35,15 @@ declaration: param,

jsdocNode: param
}));
});
_this.innerItems.push(apiParameter);
_this.params.push(apiParameter);
}
}
_this.returnType = methodDeclaration.type ? methodDeclaration.type.getText() : '';
// Return type
if (methodDeclaration.type) {
_this.returnType = methodDeclaration.type.getText();
}
else {
_this.hasIncompleteTypes = true;
_this.returnType = 'any';
}
return _this;

@@ -41,0 +50,0 @@ }

@@ -99,2 +99,24 @@ import * as ts from 'typescript';

/**
* A superset of memberItems. Includes memberItems and also other ApiItems that
* comprise this ApiItem.
*
* Ex: if this ApiItem is an ApiFunction, then in it's innerItems would
* consist of ApiParameters.
* Ex: if this ApiItem is an ApiMember that is a type literal, then it's
* innerItems would contain ApiProperties.
*/
innerItems: ApiItem[];
/**
* True if this ApiItem either itself has missing type information or one
* of it's innerItems is missing type information.
*
* Ex: if this ApiItem is an ApiMethod and has no type on the return value, then
* we consider the ApiItem as 'itself' missing type informations and this property
* is set to true.
* Ex: If this ApiItem is an ApiMethod and one of its innerItems is an ApiParameter
* that has no type specified, then we say an innerItem of this ApiMethod is missing
* type information and this property is set to true.
*/
hasIncompleteTypes: boolean;
/**
* A list of extractor warnings that were reported using ApiItem.reportWarning().

@@ -206,3 +228,17 @@ * Whereas an "error" will break the build, a "warning" will merely be tracked in

resolveReferences(): void;
/**
* A procedure for determining if this ApiItem is missing type
* information. We first check if the ApiItem itself is missing
* any type information and if not then we check each of it's
* innerItems for missing types.
*
* Ex: On the ApiItem itself, there may be missing type information
* on the return value or missing type declaration of itself
* (const name;).
* Ex: For each innerItem, there may be an ApiParameter that is missing
* a type. Or for an ApiMember that is a type literal, there may be an
* ApiProperty that is missing type information.
*/
hasAnyIncompleteTypes(): boolean;
}
export default ApiItem;

@@ -83,2 +83,24 @@ /* tslint:disable:no-bitwise */

function ApiItem(options) {
/**
* A superset of memberItems. Includes memberItems and also other ApiItems that
* comprise this ApiItem.
*
* Ex: if this ApiItem is an ApiFunction, then in it's innerItems would
* consist of ApiParameters.
* Ex: if this ApiItem is an ApiMember that is a type literal, then it's
* innerItems would contain ApiProperties.
*/
this.innerItems = [];
/**
* True if this ApiItem either itself has missing type information or one
* of it's innerItems is missing type information.
*
* Ex: if this ApiItem is an ApiMethod and has no type on the return value, then
* we consider the ApiItem as 'itself' missing type informations and this property
* is set to true.
* Ex: If this ApiItem is an ApiMethod and one of its innerItems is an ApiParameter
* that has no type specified, then we say an innerItem of this ApiMethod is missing
* type information and this property is set to true.
*/
this.hasIncompleteTypes = false;
this.reportError = this.reportError.bind(this);

@@ -200,2 +222,6 @@ this.jsdocNode = options.jsdocNode;

this._state = ResolveState.Resolving;
for (var _i = 0, _a = this.innerItems; _i < _a.length; _i++) {
var innerItem = _a[_i];
innerItem.resolveReferences();
}
this.onResolveReferences();

@@ -211,2 +237,27 @@ this._state = ResolveState.Resolved;

};
/**
* A procedure for determining if this ApiItem is missing type
* information. We first check if the ApiItem itself is missing
* any type information and if not then we check each of it's
* innerItems for missing types.
*
* Ex: On the ApiItem itself, there may be missing type information
* on the return value or missing type declaration of itself
* (const name;).
* Ex: For each innerItem, there may be an ApiParameter that is missing
* a type. Or for an ApiMember that is a type literal, there may be an
* ApiProperty that is missing type information.
*/
ApiItem.prototype.hasAnyIncompleteTypes = function () {
if (this.hasIncompleteTypes) {
return true;
}
for (var _i = 0, _a = this.innerItems; _i < _a.length; _i++) {
var innerItem = _a[_i];
if (innerItem.hasIncompleteTypes) {
return true;
}
}
return false;
};
return ApiItem;

@@ -213,0 +264,0 @@ }());

@@ -17,7 +17,3 @@ import ApiItem, { IApiItemOptions } from './ApiItem';

protected addMemberItem(apiItem: ApiItem): void;
/**
* {@inheritdoc ApiItem.onResolveReferences }
*/
protected onResolveReferences(): void;
}
export default ApiItemContainer;

@@ -30,13 +30,10 @@ "use strict";

ApiItemContainer.prototype.addMemberItem = function (apiItem) {
this.memberItems.push(apiItem);
if (apiItem.hasAnyIncompleteTypes()) {
this.reportWarning(apiItem.name + " has incomplete type information");
}
else {
this.innerItems.push(apiItem);
this.memberItems.push(apiItem);
}
};
/**
* {@inheritdoc ApiItem.onResolveReferences }
*/
ApiItemContainer.prototype.onResolveReferences = function () {
_super.prototype.onResolveReferences.call(this);
this.memberItems.forEach(function (apiItem) {
apiItem.resolveReferences();
});
};
return ApiItemContainer;

@@ -43,0 +40,0 @@ }(ApiItem_1.default));

@@ -33,6 +33,2 @@ import ApiItem, { IApiItemOptions } from './ApiItem';

/**
* {@inheritdoc ApiItem.onResolveReferences }
*/
protected onResolveReferences(): void;
/**
* Returns a text string such as "someName?: SomeTypeName;", or in the case of a type

@@ -39,0 +35,0 @@ * literal expression, returns a text string such as "someName?:".

@@ -64,2 +64,3 @@ "use strict";

_this.typeLiteral = new ApiStructuredType_1.default(typeLiteralOptions);
_this.innerItems.push(_this.typeLiteral);
}

@@ -69,14 +70,2 @@ return _this;

/**
* {@inheritdoc ApiItem.onResolveReferences }
*/
ApiMember.prototype.onResolveReferences = function () {
_super.prototype.onResolveReferences.call(this);
if (this.typeLiteral) {
this.typeLiteral.resolveReferences();
this.typeLiteral.memberItems.forEach(function (apiItem) {
apiItem.resolveReferences();
});
}
};
/**
* Returns a text string such as "someName?: SomeTypeName;", or in the case of a type

@@ -83,0 +72,0 @@ * literal expression, returns a text string such as "someName?:".

@@ -30,3 +30,3 @@ "use strict";

var declarationSymbol = TypeScriptHelpers_1.default.tryGetSymbolForDeclaration(param);
_this.params.push(new ApiParameter_1.default({
var apiParameter = new ApiParameter_1.default({
extractor: _this.extractor,

@@ -36,6 +36,17 @@ declaration: param,

jsdocNode: param
}));
});
_this.innerItems.push(apiParameter);
_this.params.push(apiParameter);
}
}
_this.returnType = methodDeclaration.type ? methodDeclaration.type.getText() : '';
// Return type
if (!(_this.name === '__constructor')) {
if (methodDeclaration.type) {
_this.returnType = methodDeclaration.type.getText();
}
else {
_this.returnType = 'any';
_this.hasIncompleteTypes = true;
}
}
return _this;

@@ -42,0 +53,0 @@ }

@@ -18,3 +18,9 @@ "use strict";

_this.isOptional = !!parameterDeclaration.questionToken || !!parameterDeclaration.initializer;
_this.type = parameterDeclaration.type.getText();
if (parameterDeclaration.type) {
_this.type = parameterDeclaration.type.getText();
}
else {
_this.hasIncompleteTypes = true;
_this.type = 'any';
}
_this.isSpread = !!parameterDeclaration.dotDotDotToken;

@@ -21,0 +27,0 @@ return _this;

@@ -19,5 +19,9 @@ "use strict";

var declaration = options.declaration; /* tslint:disable-line:no-any */
if (declaration && declaration.type) {
if (declaration.type) {
_this.type = declaration.type.getText();
}
else {
_this.hasIncompleteTypes = true;
_this.type = 'any';
}
return _this;

@@ -24,0 +28,0 @@ }

@@ -0,1 +1,14 @@

class ___proto__ {
// (undocumented)
public propertyIsEnumerable: string;
}
// (undocumented)
class A extends __proto__, implements hasOwnProperty {
// (undocumented)
___lookupSetter__: __proto__;
// (undocumented)
public __proto__(__proto__: string): __proto__;
}
// @public

@@ -11,2 +24,9 @@ class AliasClass4 {

// (undocumented)
interface hasOwnProperty {
// (undocumented)
___lookupSetter__: __proto__;
}
// WARNING: propertyWithNoType has incomplete type information
// @internal

@@ -13,0 +33,0 @@ class InternalClass {

@@ -31,2 +31,17 @@ {

},
"IncompleteTypeConstructor": {
"kind": "class",
"extends": "",
"implements": "",
"typeParameters": [],
"deprecatedMessage": [],
"summary": [
{
"kind": "textDocElement",
"value": "This class tests a constructor with incomplete type information. The constructor should not appear in the API file, instead a warning comment should be printed about this class declaration. The constructor will not appear in the json file because the type information is incomplete."
}
],
"remarks": [],
"isBeta": false
},
"inheritCorrectlyButNotFound": {

@@ -147,2 +162,10 @@ "kind": "enum",

"members": {
"__constructor": {
"kind": "constructor",
"signature": "constructor();",
"parameters": {},
"deprecatedMessage": [],
"summary": [],
"remarks": []
},
"fieldWithBadTag": {

@@ -357,2 +380,18 @@ "kind": "property",

"isBeta": false
},
"propertyTypeLiteralIncompleteTypes": {
"kind": "property",
"isOptional": false,
"isReadOnly": false,
"isStatic": false,
"type": "{name, address: string}",
"deprecatedMessage": [],
"summary": [
{
"kind": "textDocElement",
"value": "This type literal has incomplete type information. It should not be printed to the API file, instead a warning comment should be printed above the class declaration."
}
],
"remarks": [],
"isBeta": false
}

@@ -359,0 +398,0 @@ }

@@ -57,2 +57,4 @@ import Extractor from '../Extractor';

private _writeJsdocSynopsis(apiItem);
private _writeWarnings(apiItem);
private _writeLinesAsComments(lines);
}

@@ -73,2 +73,7 @@ "use strict";

this._indentedWriter.indentScope(function () {
if (apiStructuredType.kind === ApiItem_1.ApiItemKind.TypeLiteral) {
// Type literals don't have normal JSDoc. Write only the warnings,
// and put them after the '{' since the declaration is nested.
_this._writeWarnings(apiStructuredType);
}
for (var _i = 0, _a = apiStructuredType.getSortedMemberItems(); _i < _a.length; _i++) {

@@ -109,3 +114,5 @@ var member = _a[_i];

ApiFileGenerator.prototype.visitApiMember = function (apiMember) {
this._writeJsdocSynopsis(apiMember);
if (apiMember.documentation) {
this._writeJsdocSynopsis(apiMember);
}
this._indentedWriter.write(apiMember.getDeclarationLine());

@@ -131,3 +138,4 @@ if (apiMember.typeLiteral) {

ApiFileGenerator.prototype._writeJsdocSynopsis = function (apiItem) {
var lines = apiItem.warnings.map(function (x) { return 'WARNING: ' + x; });
this._writeWarnings(apiItem);
var lines = [];
if (apiItem instanceof ApiPackage_1.default && !apiItem.documentation.summary.length) {

@@ -171,2 +179,9 @@ lines.push('(No packageDescription for this package)');

}
this._writeLinesAsComments(lines);
};
ApiFileGenerator.prototype._writeWarnings = function (apiItem) {
var lines = apiItem.warnings.map(function (x) { return 'WARNING: ' + x; });
this._writeLinesAsComments(lines);
};
ApiFileGenerator.prototype._writeLinesAsComments = function (lines) {
if (lines.length) {

@@ -173,0 +188,0 @@ // Write the lines prefixed by slashes. If there are multiple lines, add "//" to each line

@@ -24,2 +24,3 @@ import Extractor from '../Extractor';

private static _methodCounter;
private static _KIND_CONSTRUCTOR;
private static _KIND_CLASS;

@@ -26,0 +27,0 @@ private static _KIND_ENUM;

@@ -162,19 +162,32 @@ "use strict";

}
var returnValueNode = {
type: apiMethod.returnType,
description: apiMethod.documentation.returnsMessage
};
var newNode = {
kind: ApiJsonGenerator._KIND_METHOD,
signature: apiMethod.getDeclarationLine(),
accessModifier: apiMethod.accessModifier ? ApiMember_1.AccessModifier[apiMethod.accessModifier].toLowerCase() : '',
isOptional: !!apiMethod.isOptional,
isStatic: !!apiMethod.isStatic,
returnValue: returnValueNode,
parameters: apiMethod.documentation.parameters,
deprecatedMessage: apiMethod.documentation.deprecatedMessage || [],
summary: apiMethod.documentation.summary || [],
remarks: apiMethod.documentation.remarks || [],
isBeta: apiMethod.documentation.apiTag === ApiDocumentation_1.ApiTag.Beta
};
var newNode;
if (apiMethod.name === '__constructor') {
newNode = {
kind: ApiJsonGenerator._KIND_CONSTRUCTOR,
signature: apiMethod.getDeclarationLine(),
parameters: apiMethod.documentation.parameters,
deprecatedMessage: apiMethod.documentation.deprecatedMessage || [],
summary: apiMethod.documentation.summary || [],
remarks: apiMethod.documentation.remarks || []
};
}
else {
var returnValueNode = {
type: apiMethod.returnType,
description: apiMethod.documentation.returnsMessage
};
newNode = {
kind: ApiJsonGenerator._KIND_METHOD,
signature: apiMethod.getDeclarationLine(),
accessModifier: apiMethod.accessModifier ? ApiMember_1.AccessModifier[apiMethod.accessModifier].toLowerCase() : '',
isOptional: !!apiMethod.isOptional,
isStatic: !!apiMethod.isStatic,
returnValue: returnValueNode,
parameters: apiMethod.documentation.parameters,
deprecatedMessage: apiMethod.documentation.deprecatedMessage || [],
summary: apiMethod.documentation.summary || [],
remarks: apiMethod.documentation.remarks || [],
isBeta: apiMethod.documentation.apiTag === ApiDocumentation_1.ApiTag.Beta
};
}
refObject[apiMethod.name] = newNode;

@@ -192,2 +205,3 @@ };

ApiJsonGenerator._methodCounter = 0;
ApiJsonGenerator._KIND_CONSTRUCTOR = 'constructor';
ApiJsonGenerator._KIND_CLASS = 'class';

@@ -194,0 +208,0 @@ ApiJsonGenerator._KIND_ENUM = 'enum';

@@ -53,2 +53,24 @@ /// <reference types="mocha" />

});
it('Example 2', function () {
var inputFolder = './testInputs/example2';
var outputFile = './lib/example2-output.ts';
var expectedFile = path.join(inputFolder, 'example2-output.ts');
var compilerOptions = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder,
typeRoots: ['./'] // We need to ignore @types in these tests
};
var extractor = new Extractor_1.default({
compilerOptions: compilerOptions,
errorHandler: testErrorHandler
});
extractor.analyze({
entryPointFile: path.join(inputFolder, 'index.ts')
});
var apiFileGenerator = new ApiFileGenerator_1.default();
apiFileGenerator.writeApiFile(outputFile, extractor);
assertFileMatchesExpected(outputFile, expectedFile);
});
});

@@ -55,0 +77,0 @@ });

@@ -1,2 +0,1 @@

/// <reference types="es6-collections" />
import { IDocElement } from './IDocElement';

@@ -126,3 +125,5 @@ /**

*/
parameters: Map<string, IDocParam>;
parameters: {
[name: string]: IDocParam;
};
/**

@@ -140,3 +141,5 @@ * describes the return value of the method

*/
parameters: Map<string, IDocParam>;
parameters: {
[name: string]: IDocParam;
};
/**

@@ -155,3 +158,5 @@ * a description of the return value

*/
members: Map<string, IDocMember>;
members: {
[name: string]: IDocMember;
};
/**

@@ -183,3 +188,5 @@ * Interfaces implemented by this class

*/
members: Map<string, IDocMember>;
members: {
[name: string]: IDocMember;
};
/**

@@ -211,3 +218,5 @@ * Interfaces implemented by this interface

*/
exports: Map<string, IDocItem>;
exports: {
[name: string]: IDocItem;
};
/**

@@ -214,0 +223,0 @@ * The following are needed so that this interface and can share

@@ -119,2 +119,66 @@ {

//---------------------------------------------------------------------------------------------
"constructorApiItem": {
"description": "A constructor of a TypeScript class",
"type": "object",
"properties": {
"kind": {
"description": "The kind of documentation element",
"type": "string",
"enum": [ "constructor" ]
},
"summary": {
"$ref": "#/definitions/docElementCollection"
},
"signature": {
"description": "A text summary of the method definition",
"type": "string"
},
"parameters": {
"description": "The list of function parameters",
"type": "object",
"patternProperties": {
"^[a-zA-Z_]+[a-zA-Z_0-9]*$": {
"type": "object",
"properties": {
"name": {
"description": "The parameter name",
"type": "string"
},
"description": {
"$ref": "#/definitions/docElementCollection"
},
"isOptional": {
"description": "Whether the parameter is optional",
"type": "boolean"
},
"isSpread": {
"description": "Whether the parameter has the '...' spread suffix",
"type": "boolean"
},
"type": {
"description": "The data type of the parameter",
"type": "string"
}
}
}
},
"additionalProperties": false
},
// Optional properties:
"remarks": {
"$ref": "#/definitions/docElementCollection"
},
"deprecatedMessage": {
"$ref": "#/definitions/docElementCollection"
}
},
"additionalProperties": false,
"required": ["summary"]
},
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
"propertyApiItem": {

@@ -202,3 +266,3 @@ "description": "A property of a TypeScript class or interface",

"patternProperties": {
"^[a-zA-Z_][a-zA-Z_0-9]+$": {
"^[a-zA-Z_]+[a-zA-Z_0-9]*$": {
"type": "object",

@@ -276,3 +340,3 @@ "properties": {

"patternProperties": {
"^[a-zA-Z_][a-zA-Z_0-9]+$": {
"^[a-zA-Z_]+[a-zA-Z_0-9]*$": {
"type": "object",

@@ -357,5 +421,6 @@ "properties": {

"patternProperties": {
"^[a-zA-Z_][a-zA-Z_0-9]+$": {
"^[a-zA-Z_]+[a-zA-Z_0-9]*$": {
"oneOf": [
{ "$ref": "#/definitions/propertyApiItem" },
{ "$ref": "#/definitions/constructorApiItem" },
{ "$ref": "#/definitions/methodApiItem" }

@@ -421,3 +486,3 @@ ]

"patternProperties": {
"^[a-zA-Z_][a-zA-Z_0-9]+$": {
"^[a-zA-Z_]+[a-zA-Z_0-9]*$": {
"type": "object",

@@ -473,3 +538,3 @@ "properties": {

"patternProperties": {
"^[a-zA-Z_][a-zA-Z_0-9]+$": {
"^[a-zA-Z_]+[a-zA-Z_0-9]*$": {
"oneOf": [

@@ -542,3 +607,3 @@ { "$ref": "#/definitions/propertyApiItem" },

"patternProperties": {
"^[a-zA-Z_][a-zA-Z_0-9]+$": {
"^[a-zA-Z_]+[a-zA-Z_0-9]*$": {
"oneOf": [

@@ -545,0 +610,0 @@ { "$ref": "#/definitions/classApiItem" },

{
"name": "@microsoft/api-extractor",
"version": "1.1.9",
"version": "1.1.10",
"description": "Validatation, documentation, and auditing for the exported API of a TypeScript package",

@@ -19,3 +19,3 @@ "main": "lib/index.js",

"mocha": "~2.5.3",
"@microsoft/node-library-build": "~2.2.0"
"@microsoft/node-library-build": "~2.3.0"
},

@@ -29,5 +29,4 @@ "dependencies": {

"jju": "~1.3.0",
"typescript": "~2.1.0",
"z-schema": "~3.17.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc