Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

dgeni-packages

Package Overview
Dependencies
118
Maintainers
2
Versions
147
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.21.3 to 0.21.4

typescript/api-doc-types/ParameterizedExportDoc.d.ts

12

CHANGELOG.md
# Changelog
# 0.21.4 28 September 2017
## Features
* **typescript**:
- add isReadonly flag to member docs 62bc5333
- include typeParameters in type-alias docs 51d81496
## Fixes
* **typescript**: show both type and initializer on parameters d677e72a
# 0.21.3 22 September 2017

@@ -4,0 +16,0 @@

2

package.json
{
"name": "dgeni-packages",
"version": "0.21.3",
"version": "0.21.4",
"description": "A collection of dgeni packages for generating documentation from source code",

@@ -5,0 +5,0 @@ "scripts": {

import { Symbol, TypeChecker } from 'typescript';
import { ExportDoc } from './ExportDoc';
import { ModuleDoc } from './ModuleDoc';
import { OverloadInfo } from './OverloadInfo';
export declare class FunctionExportDoc extends ExportDoc {
import { ParameterizedExportDoc } from './ParameterizedExportDoc';
export declare class FunctionExportDoc extends ParameterizedExportDoc {
docType: string;
overloads: OverloadInfo[];
typeParameters: string;
parameters: string[];

@@ -10,0 +9,0 @@ type: string;

@@ -15,5 +15,4 @@ "use strict";

var getParameters_1 = require("../services/TsParser/getParameters");
var getTypeParametersText_1 = require("../services/TsParser/getTypeParametersText");
var ExportDoc_1 = require("./ExportDoc");
var OverloadInfo_1 = require("./OverloadInfo");
var ParameterizedExportDoc_1 = require("./ParameterizedExportDoc");
var FunctionExportDoc = (function (_super) {

@@ -27,3 +26,2 @@ __extends(FunctionExportDoc, _super);

.map(function (declaration) { return new OverloadInfo_1.OverloadInfo(_this, declaration, _this.typeChecker); });
_this.typeParameters = getTypeParametersText_1.getTypeParametersText(_this.declaration, _this.namespacesToInclude);
_this.parameters = getParameters_1.getParameters(_this.declaration, _this.namespacesToInclude);

@@ -34,3 +32,3 @@ _this.type = getDeclarationTypeText_1.getDeclarationTypeText(_this.declaration, _this.namespacesToInclude);

return FunctionExportDoc;
}(ExportDoc_1.ExportDoc));
}(ParameterizedExportDoc_1.ParameterizedExportDoc));
exports.FunctionExportDoc = FunctionExportDoc;

@@ -37,0 +35,0 @@ function findRealDeclaration(declarations) {

@@ -35,3 +35,4 @@ import { Declaration, Symbol } from 'typescript';

isNewMember: boolean;
isReadonly: boolean | undefined;
constructor(containerDoc: ContainerExportDoc, symbol: Symbol, declaration: Declaration, basePath: string, namespacesToInclude: string[], isStatic: boolean);
}

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

this.isNewMember = !!(this.symbol.flags & typescript_1.SymbolFlags.Signature && this.symbol.name === '__new');
this.isReadonly = this.declaration.modifiers && this.declaration.modifiers.some(function (modifier) { return modifier.kind === typescript_1.SyntaxKind.ReadonlyKeyword; });
}

@@ -36,0 +37,0 @@ return MemberDoc;

import { Symbol, TypeChecker } from 'typescript';
import { ExportDoc } from './ExportDoc';
import { ModuleDoc } from './ModuleDoc';
export declare class TypeAliasExportDoc extends ExportDoc {
import { ParameterizedExportDoc } from './ParameterizedExportDoc';
export declare class TypeAliasExportDoc extends ParameterizedExportDoc {
docType: string;

@@ -6,0 +6,0 @@ typeDefinition: string;

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

var getDeclarationTypeText_1 = require("../services/TsParser/getDeclarationTypeText");
var ExportDoc_1 = require("./ExportDoc");
var ParameterizedExportDoc_1 = require("./ParameterizedExportDoc");
var TypeAliasExportDoc = (function (_super) {

@@ -26,3 +26,3 @@ __extends(TypeAliasExportDoc, _super);

return TypeAliasExportDoc;
}(ExportDoc_1.ExportDoc));
}(ParameterizedExportDoc_1.ParameterizedExportDoc));
exports.TypeAliasExportDoc = TypeAliasExportDoc;

@@ -29,0 +29,0 @@ function getTypeAliasDeclaration(declarations) {

@@ -6,2 +6,4 @@ export class X<T> {

export const X2 = X;
export type X2 = X<any>;
export type X2 = X<any>;
export type Parameterized<T, R> = X<T>;

@@ -6,4 +6,5 @@ export function testFunction(

d = 45,
e: string = 'moo',
...args: string[]) {
//
}

@@ -167,2 +167,10 @@ "use strict";

});
it('should include type parameters', function () {
processor.sourceFiles = ['type-aliases.ts'];
var docs = [];
processor.$process(docs);
var typeAliasDoc = docs.find(function (doc) { return doc.name === 'Parameterized'; });
expect(typeAliasDoc.docType).toEqual('type-alias');
expect(typeAliasDoc.typeParameters).toEqual('<T, R>');
});
});

@@ -179,64 +187,96 @@ describe('exported functions', function () {

});
describe('overloaded members', function () {
it('should create a member doc for the "real" member, which includes an overloads property', function () {
processor.sourceFiles = ['overloadedMembers.ts'];
var docs = [];
processor.$process(docs);
var foo = docs.find(function (doc) { return doc.name === 'foo'; });
expect(foo.parameters).toEqual(['num1: number|string', 'num2?: number']);
var overloads = foo.overloads;
expect(overloads.map(function (overload) { return overload.parameters; })).toEqual([
['str: string'],
['num1: number', 'num2: number'],
]);
describe('members', function () {
describe('overloaded members', function () {
it('should create a member doc for the "real" member, which includes an overloads property', function () {
processor.sourceFiles = ['overloadedMembers.ts'];
var docs = [];
processor.$process(docs);
var foo = docs.find(function (doc) { return doc.name === 'foo'; });
expect(foo.parameters).toEqual(['num1: number|string', 'num2?: number']);
var overloads = foo.overloads;
expect(overloads.map(function (overload) { return overload.parameters; })).toEqual([
['str: string'],
['num1: number', 'num2: number'],
]);
});
it('should use the first declaration as the member doc if no overload has a body', function () {
processor.sourceFiles = ['overloadedMembers.ts'];
var docs = [];
processor.$process(docs);
var bar = docs.find(function (doc) { return doc.name === 'bar'; });
expect(bar.overloads.length).toEqual(1);
expect(bar.parameters).toEqual(['str: string']);
expect(bar.overloads[0].parameters).toEqual([]);
});
});
it('should use the first declaration as the member doc if no overload has a body', function () {
processor.sourceFiles = ['overloadedMembers.ts'];
var docs = [];
processor.$process(docs);
var bar = docs.find(function (doc) { return doc.name === 'bar'; });
expect(bar.overloads.length).toEqual(1);
expect(bar.parameters).toEqual(['str: string']);
expect(bar.overloads[0].parameters).toEqual([]);
describe('overloaded constructors', function () {
it('should create a member doc for the "real" constructor, which includes an overloads property', function () {
processor.sourceFiles = ['overloadedMembers.ts'];
var docs = [];
processor.$process(docs);
var foo = docs.find(function (doc) { return doc.name === 'constructor'; });
expect(foo.parameters).toEqual(['x: string', 'y: number|string', 'z?: number']);
var overloads = foo.overloads;
expect(overloads.map(function (overload) { return overload.parameters; })).toEqual([
['x: string', 'y: number'],
['x: string', 'y: string', 'z: number'],
]);
});
});
});
describe('overloaded constructors', function () {
it('should create a member doc for the "real" constructor, which includes an overloads property', function () {
processor.sourceFiles = ['overloadedMembers.ts'];
var docs = [];
processor.$process(docs);
var foo = docs.find(function (doc) { return doc.name === 'constructor'; });
expect(foo.parameters).toEqual(['x: string', 'y: number|string', 'z?: number']);
var overloads = foo.overloads;
expect(overloads.map(function (overload) { return overload.parameters; })).toEqual([
['x: string', 'y: number'],
['x: string', 'y: string', 'z: number'],
]);
describe('ordering of members', function () {
it('should order class members in order of appearance (by default)', function () {
processor.sourceFiles = ['orderingOfMembers.ts'];
var docs = [];
processor.$process(docs);
var classDoc = docs.find(function (doc) { return doc.docType === 'class'; });
expect(classDoc.docType).toEqual('class');
expect(getNames(classDoc.members)).toEqual([
'firstItem',
'otherMethod',
'doStuff',
]);
});
it('should not order class members if not sortClassMembers is false', function () {
processor.sourceFiles = ['orderingOfMembers.ts'];
processor.sortClassMembers = false;
var docs = [];
processor.$process(docs);
var classDoc = docs.find(function (doc) { return doc.docType === 'class'; });
expect(classDoc.docType).toEqual('class');
expect(getNames(classDoc.members)).toEqual([
'firstItem',
'otherMethod',
'doStuff',
]);
});
});
});
describe('ordering of members', function () {
it('should order class members in order of appearance (by default)', function () {
processor.sourceFiles = ['orderingOfMembers.ts'];
var docs = [];
processor.$process(docs);
var classDoc = docs.find(function (doc) { return doc.docType === 'class'; });
expect(classDoc.docType).toEqual('class');
expect(getNames(classDoc.members)).toEqual([
'firstItem',
'otherMethod',
'doStuff',
]);
describe('return types', function () {
it('should not throw if "declaration.initializer.expression.text" is undefined', function () {
processor.sourceFiles = ['returnTypes.ts'];
var docs = [];
expect(function () { processor.$process(docs); }).not.toThrow();
});
it('should return the text of the type if initialized', function () {
processor.sourceFiles = ['returnTypes.ts'];
var docs = [];
processor.$process(docs);
var propDocs = docs.filter(function (doc) { return doc.name === 'someProp'; });
expect(propDocs[0].type).toEqual('{\n' +
' foo: \'bar\',\n' +
' }');
expect(propDocs[1].type).toEqual('Object.assign(this.someProp, {\n' +
' bar: \'baz\'\n' +
' })');
});
});
it('should not order class members if not sortClassMembers is false', function () {
processor.sourceFiles = ['orderingOfMembers.ts'];
processor.sortClassMembers = false;
var docs = [];
processor.$process(docs);
var classDoc = docs.find(function (doc) { return doc.docType === 'class'; });
expect(classDoc.docType).toEqual('class');
expect(getNames(classDoc.members)).toEqual([
'firstItem',
'otherMethod',
'doStuff',
]);
describe('member modifiers', function () {
it('should set the readOnly flag on readonly members', function () {
processor.sourceFiles = ['memberModifiers.ts'];
var docs = [];
processor.$process(docs);
var simpleProp = docs.filter(function (doc) { return doc.name === 'foo'; })[0];
expect(simpleProp.isReadonly).toBeFalsy();
var readonlyProp = docs.filter(function (doc) { return doc.name === 'bar'; })[0];
expect(readonlyProp.isReadonly).toBeTruthy();
});
});

@@ -304,21 +344,2 @@ });

});
describe('return types', function () {
it('should not throw if "declaration.initializer.expression.text" is undefined', function () {
processor.sourceFiles = ['returnTypes.ts'];
var docs = [];
expect(function () { processor.$process(docs); }).not.toThrow();
});
it('should return the text of the type if initialized', function () {
processor.sourceFiles = ['returnTypes.ts'];
var docs = [];
processor.$process(docs);
var propDocs = docs.filter(function (doc) { return doc.name === 'someProp'; });
expect(propDocs[0].type).toEqual('{\n' +
' foo: \'bar\',\n' +
' }');
expect(propDocs[1].type).toEqual('Object.assign(this.someProp, {\n' +
' bar: \'baz\'\n' +
' })');
});
});
});

@@ -325,0 +346,0 @@ function getNames(collection) {

import { Declaration } from 'typescript';
export declare function getDeclarationTypeText(declaration: Declaration, namespacesToInclude: string[]): string;
export declare function getInitializerText(declaration: Declaration): string;

@@ -15,6 +15,3 @@ "use strict";

// if the declaration is being initialized then use the initialization value
var initializer = getInitializer(declaration);
if (initializer)
return initializer.getText();
return '';
return getInitializerText(declaration);
}

@@ -25,5 +22,7 @@ exports.getDeclarationTypeText = getDeclarationTypeText;

}
function getInitializer(declaration) {
return declaration.initializer;
function getInitializerText(declaration) {
var initializer = declaration.initializer;
return initializer ? initializer.getText() : '';
}
exports.getInitializerText = getInitializerText;
//# sourceMappingURL=getDeclarationTypeText.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var getDeclarationTypeText_1 = require("./getDeclarationTypeText");
var getTypeText_1 = require("./getTypeText");
function getParameters(declaration, namespacesToInclude) {

@@ -17,4 +18,10 @@ var parameters = getParameterDeclarations(declaration);

paramText += '?';
paramText += (!parameter.type && parameter.initializer) ? ' = ' : ': ';
paramText += getDeclarationTypeText_1.getDeclarationTypeText(parameter, namespacesToInclude);
var type = parameter.type;
if (type) {
paramText += ': ' + getTypeText_1.getTypeText(type, namespacesToInclude);
}
var initializer = getDeclarationTypeText_1.getInitializerText(parameter);
if (initializer) {
paramText += ' = ' + initializer;
}
return paramText.trim();

@@ -21,0 +28,0 @@ });

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

'd = 45',
'e: string = \'moo\'',
'...args: string[]',

@@ -24,0 +25,0 @@ ]);

import { Declaration, SignatureDeclaration, Symbol, TypeChecker } from 'typescript';
import { getDeclarationTypeText } from '../services/TsParser/getDeclarationTypeText';
import { getParameters } from '../services/TsParser/getParameters';
import { getTypeParametersText } from '../services/TsParser/getTypeParametersText';
import { ExportDoc } from './ExportDoc';
import { ModuleDoc } from './ModuleDoc';
import { OverloadInfo } from './OverloadInfo';
import { ParameterizedExportDoc } from './ParameterizedExportDoc';
export class FunctionExportDoc extends ExportDoc {
export class FunctionExportDoc extends ParameterizedExportDoc {
docType = 'function';

@@ -14,3 +13,2 @@ overloads = this.symbol.getDeclarations()!

.map(declaration => new OverloadInfo(this, declaration, this.typeChecker));
typeParameters = getTypeParametersText(this.declaration, this.namespacesToInclude);
parameters = getParameters(this.declaration as SignatureDeclaration, this.namespacesToInclude);

@@ -17,0 +15,0 @@ type = getDeclarationTypeText(this.declaration, this.namespacesToInclude);

/* tslint:disable:no-bitwise */
import { Declaration, Decorator, Symbol, SymbolFlags } from 'typescript';
import { Declaration, Decorator, Symbol, SymbolFlags, SyntaxKind } from 'typescript';
import { FileInfo } from '../services/TsParser/FileInfo';

@@ -36,2 +36,3 @@ import { getAccessibility } from "../services/TsParser/getAccessibility";

isNewMember = !!(this.symbol.flags & SymbolFlags.Signature && this.symbol.name === '__new');
isReadonly = this.declaration.modifiers && this.declaration.modifiers.some(modifier => modifier.kind === SyntaxKind.ReadonlyKeyword);

@@ -38,0 +39,0 @@ constructor(

@@ -1,7 +0,7 @@

import { Declaration, Symbol, SyntaxKind, TypeChecker } from 'typescript';
import { Declaration, Symbol, SyntaxKind, TypeAliasDeclaration, TypeChecker } from 'typescript';
import { getDeclarationTypeText } from '../services/TsParser/getDeclarationTypeText';
import { ExportDoc } from './ExportDoc';
import { ModuleDoc } from './ModuleDoc';
import { ParameterizedExportDoc } from './ParameterizedExportDoc';
export class TypeAliasExportDoc extends ExportDoc {
export class TypeAliasExportDoc extends ParameterizedExportDoc {
docType = 'type-alias';

@@ -11,7 +11,7 @@ typeDefinition = getDeclarationTypeText(this.declaration, this.namespacesToInclude);

constructor(
moduleDoc: ModuleDoc,
exportSymbol: Symbol,
basePath: string,
typeChecker: TypeChecker,
namespacesToInclude: string[]) {
moduleDoc: ModuleDoc,
exportSymbol: Symbol,
basePath: string,
typeChecker: TypeChecker,
namespacesToInclude: string[]) {
super(moduleDoc, exportSymbol, getTypeAliasDeclaration(exportSymbol.getDeclarations()!), basePath, typeChecker, namespacesToInclude);

@@ -18,0 +18,0 @@ }

@@ -210,2 +210,11 @@ import {Dgeni, DocCollection} from 'dgeni';

});
it('should include type parameters', () => {
processor.sourceFiles = [ 'type-aliases.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const typeAliasDoc = docs.find(doc => doc.name === 'Parameterized');
expect(typeAliasDoc.docType).toEqual('type-alias');
expect(typeAliasDoc.typeParameters).toEqual('<T, R>');
});
});

@@ -224,73 +233,109 @@

describe('overloaded members', () => {
it('should create a member doc for the "real" member, which includes an overloads property', () => {
processor.sourceFiles = [ 'overloadedMembers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
describe('members', () => {
describe('overloaded members', () => {
it('should create a member doc for the "real" member, which includes an overloads property', () => {
processor.sourceFiles = [ 'overloadedMembers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const foo: MethodMemberDoc = docs.find(doc => doc.name === 'foo');
expect(foo.parameters).toEqual(['num1: number|string', 'num2?: number']);
const overloads = foo.overloads;
expect(overloads.map(overload => overload.parameters)).toEqual([
['str: string'],
['num1: number', 'num2: number'],
]);
});
const foo: MethodMemberDoc = docs.find(doc => doc.name === 'foo');
expect(foo.parameters).toEqual(['num1: number|string', 'num2?: number']);
const overloads = foo.overloads;
expect(overloads.map(overload => overload.parameters)).toEqual([
['str: string'],
['num1: number', 'num2: number'],
]);
});
it('should use the first declaration as the member doc if no overload has a body', () => {
processor.sourceFiles = [ 'overloadedMembers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
it('should use the first declaration as the member doc if no overload has a body', () => {
processor.sourceFiles = [ 'overloadedMembers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const bar: MethodMemberDoc = docs.find(doc => doc.name === 'bar');
expect(bar.overloads.length).toEqual(1);
const bar: MethodMemberDoc = docs.find(doc => doc.name === 'bar');
expect(bar.overloads.length).toEqual(1);
expect(bar.parameters).toEqual(['str: string']);
expect(bar.overloads[0].parameters).toEqual([]);
expect(bar.parameters).toEqual(['str: string']);
expect(bar.overloads[0].parameters).toEqual([]);
});
});
});
describe('overloaded constructors', () => {
it('should create a member doc for the "real" constructor, which includes an overloads property', () => {
processor.sourceFiles = [ 'overloadedMembers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
describe('overloaded constructors', () => {
it('should create a member doc for the "real" constructor, which includes an overloads property', () => {
processor.sourceFiles = [ 'overloadedMembers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const foo: MethodMemberDoc = docs.find(doc => doc.name === 'constructor');
expect(foo.parameters).toEqual(['x: string', 'y: number|string', 'z?: number']);
const overloads = foo.overloads;
expect(overloads.map(overload => overload.parameters)).toEqual([
['x: string', 'y: number'],
['x: string', 'y: string', 'z: number'],
]);
const foo: MethodMemberDoc = docs.find(doc => doc.name === 'constructor');
expect(foo.parameters).toEqual(['x: string', 'y: number|string', 'z?: number']);
const overloads = foo.overloads;
expect(overloads.map(overload => overload.parameters)).toEqual([
['x: string', 'y: number'],
['x: string', 'y: string', 'z: number'],
]);
});
});
});
describe('ordering of members', () => {
it('should order class members in order of appearance (by default)', () => {
processor.sourceFiles = ['orderingOfMembers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const classDoc = docs.find(doc => doc.docType === 'class');
expect(classDoc.docType).toEqual('class');
expect(getNames(classDoc.members)).toEqual([
'firstItem',
'otherMethod',
'doStuff',
]);
describe('ordering of members', () => {
it('should order class members in order of appearance (by default)', () => {
processor.sourceFiles = ['orderingOfMembers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const classDoc = docs.find(doc => doc.docType === 'class');
expect(classDoc.docType).toEqual('class');
expect(getNames(classDoc.members)).toEqual([
'firstItem',
'otherMethod',
'doStuff',
]);
});
it('should not order class members if not sortClassMembers is false', () => {
processor.sourceFiles = ['orderingOfMembers.ts'];
processor.sortClassMembers = false;
const docs: DocCollection = [];
processor.$process(docs);
const classDoc = docs.find(doc => doc.docType === 'class');
expect(classDoc.docType).toEqual('class');
expect(getNames(classDoc.members)).toEqual([
'firstItem',
'otherMethod',
'doStuff',
]);
});
});
it('should not order class members if not sortClassMembers is false', () => {
processor.sourceFiles = ['orderingOfMembers.ts'];
processor.sortClassMembers = false;
const docs: DocCollection = [];
processor.$process(docs);
const classDoc = docs.find(doc => doc.docType === 'class');
expect(classDoc.docType).toEqual('class');
expect(getNames(classDoc.members)).toEqual([
'firstItem',
'otherMethod',
'doStuff',
]);
describe('return types', () => {
it('should not throw if "declaration.initializer.expression.text" is undefined', () => {
processor.sourceFiles = ['returnTypes.ts'];
const docs: DocCollection = [];
expect(() => { processor.$process(docs); }).not.toThrow();
});
it('should return the text of the type if initialized', () => {
processor.sourceFiles = ['returnTypes.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const propDocs = docs.filter(doc => doc.name === 'someProp');
expect(propDocs[0].type).toEqual('{\n' +
' foo: \'bar\',\n' +
' }');
expect(propDocs[1].type).toEqual('Object.assign(this.someProp, {\n' +
' bar: \'baz\'\n' +
' })');
});
});
describe('member modifiers', () => {
it('should set the readOnly flag on readonly members', () => {
processor.sourceFiles = ['memberModifiers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const simpleProp = docs.filter(doc => doc.name === 'foo')[0];
expect(simpleProp.isReadonly).toBeFalsy();
const readonlyProp = docs.filter(doc => doc.name === 'bar')[0];
expect(readonlyProp.isReadonly).toBeTruthy();
});
});
});

@@ -365,24 +410,2 @@

});
describe('return types', () => {
it('should not throw if "declaration.initializer.expression.text" is undefined', () => {
processor.sourceFiles = ['returnTypes.ts'];
const docs: DocCollection = [];
expect(() => { processor.$process(docs); }).not.toThrow();
});
it('should return the text of the type if initialized', () => {
processor.sourceFiles = ['returnTypes.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const propDocs = docs.filter(doc => doc.name === 'someProp');
expect(propDocs[0].type).toEqual('{\n' +
' foo: \'bar\',\n' +
' }');
expect(propDocs[1].type).toEqual('Object.assign(this.someProp, {\n' +
' bar: \'baz\'\n' +
' })');
});
});
});

@@ -389,0 +412,0 @@

@@ -15,6 +15,3 @@ import { Declaration, Expression, SyntaxKind, TypeNode, TypeParameterDeclaration } from 'typescript';

// if the declaration is being initialized then use the initialization value
const initializer = getInitializer(declaration);
if (initializer) return initializer.getText();
return '';
return getInitializerText(declaration);
}

@@ -26,4 +23,5 @@

function getInitializer(declaration: Declaration) {
return (declaration as any).initializer as Expression;
export function getInitializerText(declaration: Declaration) {
const initializer = (declaration as any).initializer as Expression;
return initializer ? initializer.getText() : '';
}

@@ -23,2 +23,3 @@ import { SignatureDeclaration } from 'typescript';

'd = 45',
'e: string = \'moo\'',
'...args: string[]',

@@ -25,0 +26,0 @@ ]);

import { Declaration, ParameterDeclaration, SignatureDeclaration } from 'typescript';
import { getDeclarationTypeText } from './getDeclarationTypeText';
import { getInitializerText } from './getDeclarationTypeText';
import { getTypeText } from './getTypeText';

@@ -20,5 +21,11 @@ export function getParameters(declaration: SignatureDeclaration, namespacesToInclude: string[]) {

paramText += (!parameter.type && parameter.initializer) ? ' = ' : ': ';
const type = parameter.type;
if (type) {
paramText += ': ' + getTypeText(type, namespacesToInclude);
}
paramText += getDeclarationTypeText(parameter, namespacesToInclude);
const initializer = getInitializerText(parameter);
if (initializer) {
paramText += ' = ' + initializer;
}

@@ -25,0 +32,0 @@ return paramText.trim();

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc