Socket
Socket
Sign inDemoInstall

@polymer/gen-typescript-declarations

Package Overview
Dependencies
8
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

3

CHANGELOG.md

@@ -9,3 +9,6 @@ # Changelog

## [0.2.0] - 2017-12-08
- Many fixes. See https://github.com/Polymer/gen-typescript-declarations/issues/23.
## [0.1.0] - 2017-11-09
- Initial release on NPM.

2

lib/cli.js

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

const p = path.join(args.root, 'gen-tsd.json');
if (yield fsExtra.exists(p)) {
if (yield fsExtra.pathExists(p)) {
args.config = p;

@@ -79,0 +79,0 @@ }

@@ -6,3 +6,3 @@ import * as ts from './ts-ast';

*/
export declare function closureTypeToTypeScript(closureType: (string | null | undefined)): ts.Type;
export declare function closureTypeToTypeScript(closureType: (string | null | undefined), templateTypes?: string[]): ts.Type;
/**

@@ -13,3 +13,3 @@ * Convert from a parameter type annotation in Closure syntax to a TypeScript

*/
export declare function closureParamToTypeScript(closureType: (string | null | undefined)): {
export declare function closureParamToTypeScript(closureType: (string | null | undefined), templateTypes?: string[]): {
type: ts.Type;

@@ -16,0 +16,0 @@ optional: boolean;

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

*/
function closureTypeToTypeScript(closureType) {
function closureTypeToTypeScript(closureType, templateTypes = []) {
if (!closureType) {

@@ -31,3 +31,3 @@ return ts.anyType;

}
return convert(ast);
return convert(ast, templateTypes);
}

@@ -40,3 +40,3 @@ exports.closureTypeToTypeScript = closureTypeToTypeScript;

*/
function closureParamToTypeScript(closureType) {
function closureParamToTypeScript(closureType, templateTypes = []) {
if (!closureType) {

@@ -63,3 +63,3 @@ return { type: ts.anyType, optional: false, rest: false };

return {
type: convert(ast.expression),
type: convert(ast.expression, templateTypes),
optional: true,

@@ -73,3 +73,3 @@ rest: false,

// equivalent is explicitly an array, so we wrap it in one here.
type: new ts.ArrayType(convert(ast.expression)),
type: new ts.ArrayType(convert(ast.expression, templateTypes)),
optional: false,

@@ -80,3 +80,3 @@ rest: true,

return {
type: convert(ast),
type: convert(ast, templateTypes),
optional: false,

@@ -92,3 +92,3 @@ rest: false,

*/
function convert(node) {
function convert(node, templateTypes) {
let nullable;

@@ -103,2 +103,8 @@ if (isNullable(node)) {

}
else if (isName(node) && templateTypes.includes(node.name)) {
// A template type "T" looks naively like a regular name type to doctrine
// (e.g. a class called "T"), which would be nullable by default. However,
// template types are not nullable by default.
nullable = false;
}
else {

@@ -109,9 +115,9 @@ nullable = nullableByDefault(node);

if (isParameterizedArray(node)) {
t = convertArray(node);
t = convertArray(node, templateTypes);
}
else if (isUnion(node)) {
t = convertUnion(node);
t = convertUnion(node, templateTypes);
}
else if (isFunction(node)) {
t = convertFunction(node);
t = convertFunction(node, templateTypes);
}

@@ -161,15 +167,16 @@ else if (isBareArray(node)) {

}
function convertArray(node) {
function convertArray(node, templateTypes) {
const applications = node.applications;
return new ts.ArrayType(applications.length === 1 ? convert(applications[0]) : ts.anyType);
return new ts.ArrayType(applications.length === 1 ? convert(applications[0], templateTypes) :
ts.anyType);
}
function convertUnion(node) {
return new ts.UnionType(node.elements.map(convert));
function convertUnion(node, templateTypes) {
return new ts.UnionType(node.elements.map((element) => convert(element, templateTypes)));
}
function convertFunction(node) {
function convertFunction(node, templateTypes) {
return new ts.FunctionType(node.params.map((param, idx) => new ts.ParamType(
// TypeScript wants named parameters, but we don't have names.
'p' + idx, convert(param))),
'p' + idx, convert(param, templateTypes))),
// Cast because typings are wrong: `FunctionType.result` is not an array.
node.result ? convert(node.result) : ts.anyType);
node.result ? convert(node.result, templateTypes) : ts.anyType);
}

@@ -176,0 +183,0 @@ function isParameterizedArray(node) {

@@ -10,2 +10,15 @@ /**

exclude?: string[];
/**
* Remove any triple-slash references to these files, specified as paths
* relative to the analysis root directory.
*/
removeReferences?: string[];
/**
* Additional files to insert as triple-slash reference statements. Given the
* map `a: b[]`, a will get an additional reference statement for each file
* path in b. All paths are relative to the analysis root directory.
*/
addReferences?: {
[filepath: string]: string[];
};
}

@@ -12,0 +25,0 @@ /**

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

const outFiles = new Map();
for (const tsDoc of analyzerToAst(analysis, config)) {
for (const tsDoc of analyzerToAst(analysis, config, rootDir)) {
outFiles.set(tsDoc.path, tsDoc.serialize());

@@ -49,6 +49,8 @@ }

*/
function analyzerToAst(analysis, config) {
function analyzerToAst(analysis, config, rootDir) {
const exclude = config.exclude !== undefined ?
config.exclude.map((p) => new RegExp(p)) :
[/test\//, /demo\//];
const addReferences = config.addReferences || {};
const removeReferencesResolved = new Set((config.removeReferences || []).map((r) => path.resolve(rootDir, r)));
// Analyzer can produce multiple JS documents with the same URL (e.g. an

@@ -82,2 +84,11 @@ // HTML file with multiple inline scripts). We also might have multiple

}
for (const ref of tsDoc.referencePaths) {
const resolvedRef = path.resolve(rootDir, path.dirname(tsDoc.path), ref);
if (removeReferencesResolved.has(resolvedRef)) {
tsDoc.referencePaths.delete(ref);
}
}
for (const ref of addReferences[tsDoc.path] || []) {
tsDoc.referencePaths.add(path.relative(path.dirname(tsDoc.path), ref));
}
tsDoc.simplify();

@@ -117,2 +128,5 @@ // Include even documents with no members. They might be dependencies of

for (const feature of doc.getFeatures()) {
if (feature.privacy === 'private') {
continue;
}
if (feature.kinds.has('element')) {

@@ -133,2 +147,5 @@ handleElement(feature, root);

}
else if (feature.kinds.has('namespace')) {
handleNamespace(feature, root);
}
else if (feature.kinds.has('import')) {

@@ -179,3 +196,3 @@ // Sometimes an Analyzer document includes an import feature that is

name: shortName,
description: feature.description,
description: feature.description || feature.summary,
extends: (feature.extends) ||

@@ -195,3 +212,3 @@ (isPolymerElement(feature) ? 'Polymer.Element' : 'HTMLElement'),

name: shortName,
description: feature.description,
description: feature.description || feature.summary,
properties: handleProperties(feature.properties.values()),

@@ -229,3 +246,3 @@ methods: handleMethods(feature.methods.values()),

const i = new ts.Interface({ name: className });
i.description = feature.description;
i.description = feature.description || feature.summary;
i.properties = handleProperties(feature.properties.values());

@@ -240,7 +257,16 @@ i.methods = handleMethods(feature.methods.values());

const [namespacePath, name] = splitReference(feature.name);
const m = new ts.Mixin({ name });
m.description = feature.description;
m.properties = handleProperties(feature.properties.values());
m.methods = handleMethods(feature.methods.values());
findOrCreateNamespace(root, namespacePath).members.push(m);
const namespace_ = findOrCreateNamespace(root, namespacePath);
// We represent mixins in two parts: a mixin function that is called to
// augment a given class with this mixin, and an interface with the
// properties and methods that are added by this mixin. We can use the same
// name for both parts because one is in value space, and the other is in
// type space.
const function_ = new ts.Mixin({ name });
function_.description = feature.description;
function_.interfaces = [name, ...feature.mixins.map((m) => m.identifier)];
namespace_.members.push(function_);
const interface_ = new ts.Interface({ name });
interface_.properties = handleProperties(feature.properties.values());
interface_.methods = handleMethods(feature.methods.values());
namespace_.members.push(interface_);
}

@@ -269,4 +295,5 @@ /**

name,
description: feature.description,
returns: closure_types_1.closureTypeToTypeScript(feature.return && feature.return.type)
description: feature.description || feature.summary,
templateTypes: feature.templateTypes,
returns: closure_types_1.closureTypeToTypeScript(feature.return && feature.return.type, feature.templateTypes)
});

@@ -276,3 +303,3 @@ for (const param of feature.params || []) {

// which only handles this for class method parameters currently.
const { type, optional, rest } = closure_types_1.closureParamToTypeScript(param.type);
const { type, optional, rest } = closure_types_1.closureParamToTypeScript(param.type, feature.templateTypes);
f.params.push(new ts.Param({ name: param.name, type, optional, rest }));

@@ -289,3 +316,3 @@ }

for (const property of analyzerProperties) {
if (property.inheritedFrom) {
if (property.inheritedFrom || property.privacy === 'private') {
continue;

@@ -311,3 +338,3 @@ }

for (const method of analyzerMethods) {
if (method.inheritedFrom) {
if (method.inheritedFrom || method.privacy === 'private') {
continue;

@@ -368,2 +395,11 @@ }

/**
* Add the given namespace to the given TypeScript declarations document.
*/
function handleNamespace(feature, tsDoc) {
const ns = findOrCreateNamespace(tsDoc, feature.name.split('.'));
if (ns.kind === 'namespace') {
ns.description = feature.description || feature.summary || '';
}
}
/**
* Add an HTML import to a TypeScript declarations file. For a given HTML

@@ -370,0 +406,0 @@ * import, we assume there is a corresponding declarations file that was

@@ -38,5 +38,7 @@ /**

name: string;
description: string;
members: Array<Namespace | Class | Interface | Mixin | Function>;
constructor(data: {
name: string;
description?: string;
members?: Array<Namespace | Class | Interface | Mixin | Function>;

@@ -87,9 +89,7 @@ });

description: string;
properties: Property[];
methods: Method[];
interfaces: string[];
constructor(data: {
name: string;
description?: string;
properties?: Property[];
methods?: Method[];
interfaces?: string[];
});

@@ -104,2 +104,3 @@ traverse(): Iterable<Node>;

params: Param[];
templateTypes: string[];
returns: Type;

@@ -111,2 +112,3 @@ returnsDescription: string;

params?: Param[];
templateTypes?: string[];
returns?: Type;

@@ -113,0 +115,0 @@ returnsDescription?: string;

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

this.name = data.name;
this.description = data.description || '';
this.members = data.members || [];

@@ -72,2 +73,5 @@ }

let out = '';
if (this.description) {
out += formatComment(this.description, depth);
}
const i = indent(depth);

@@ -188,3 +192,3 @@ out += i;

exports.Interface = Interface;
// A class mixin using the pattern described at:
// A class mixin function using the pattern described at:
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html

@@ -196,12 +200,5 @@ class Mixin {

this.description = data.description || '';
this.properties = data.properties || [];
this.methods = data.methods || [];
this.interfaces = data.interfaces || [];
}
*traverse() {
for (const p of this.properties) {
yield* p.traverse();
}
for (const m of this.methods) {
yield* m.traverse();
}
yield this;

@@ -222,10 +219,3 @@ }

out += `<T extends new(...args: any[]) => {}>(base: T): {\n`;
out += `${i2}new(...args: any[]): {\n`;
for (const property of this.properties) {
out += property.serialize(depth + 2);
}
for (const method of this.methods) {
out += method.serialize(depth + 2);
}
out += `${i2}}\n`;
out += `${i2}new(...args: any[]): ${this.interfaces.join(' & ')}\n`;
out += `${i}} & T\n`;

@@ -242,2 +232,3 @@ return out;

this.returns = data.returns || exports.anyType;
this.templateTypes = data.templateTypes || [];
this.returnsDescription = data.returnsDescription || '';

@@ -274,3 +265,7 @@ }

}
out += `${this.name}(`;
out += this.name;
if (this.templateTypes.length > 0) {
out += `<${this.templateTypes.join(', ')}>`;
}
out += '(';
out += this.params.map((p) => p.serialize()).join(', ');

@@ -277,0 +272,0 @@ out += `): ${this.returns.serialize()};\n`;

{
"name": "@polymer/gen-typescript-declarations",
"version": "0.1.0",
"version": "0.2.0",
"description": "Generate TypeScript type declarations for Polymer components.",

@@ -22,3 +22,3 @@ "main": "lib/gen-ts.js",

"fs-extra": "^4.0.2",
"polymer-analyzer": "^2.6.0"
"polymer-analyzer": "^3.0.0-pre.3"
},

@@ -25,0 +25,0 @@ "devDependencies": {

@@ -75,3 +75,3 @@ /**

const p = path.join(args.root, 'gen-tsd.json');
if (await fsExtra.exists(p)) {
if (await fsExtra.pathExists(p)) {
args.config = p;

@@ -78,0 +78,0 @@ }

@@ -29,4 +29,5 @@ /**

*/
export function closureTypeToTypeScript(closureType: (string|null|undefined)):
ts.Type {
export function closureTypeToTypeScript(
closureType: (string|null|undefined),
templateTypes: string[] = []): ts.Type {
if (!closureType) {

@@ -41,3 +42,3 @@ return ts.anyType;

}
return convert(ast);
return convert(ast, templateTypes);
}

@@ -50,4 +51,6 @@

*/
export function closureParamToTypeScript(closureType: (string|null|undefined)):
{type: ts.Type, optional: boolean, rest: boolean} {
export function closureParamToTypeScript(
closureType: (string|null|undefined),
templateTypes: string[] = [],
): {type: ts.Type, optional: boolean, rest: boolean} {
if (!closureType) {

@@ -75,3 +78,3 @@ return {type: ts.anyType, optional: false, rest: false};

return {
type: convert(ast.expression),
type: convert(ast.expression, templateTypes),
optional: true,

@@ -85,3 +88,3 @@ rest: false,

// equivalent is explicitly an array, so we wrap it in one here.
type: new ts.ArrayType(convert(ast.expression)),
type: new ts.ArrayType(convert(ast.expression, templateTypes)),
optional: false,

@@ -92,3 +95,3 @@ rest: true,

return {
type: convert(ast),
type: convert(ast, templateTypes),
optional: false,

@@ -104,3 +107,3 @@ rest: false,

*/
function convert(node: doctrine.Type): ts.Type {
function convert(node: doctrine.Type, templateTypes: string[]): ts.Type {
let nullable;

@@ -113,2 +116,7 @@ if (isNullable(node)) { // ?foo

node = node.expression;
} else if (isName(node) && templateTypes.includes(node.name)) {
// A template type "T" looks naively like a regular name type to doctrine
// (e.g. a class called "T"), which would be nullable by default. However,
// template types are not nullable by default.
nullable = false;
} else {

@@ -121,7 +129,7 @@ nullable = nullableByDefault(node);

if (isParameterizedArray(node)) { // Array<foo>
t = convertArray(node);
t = convertArray(node, templateTypes);
} else if (isUnion(node)) { // foo|bar
t = convertUnion(node);
t = convertUnion(node, templateTypes);
} else if (isFunction(node)) { // function(foo): bar
t = convertFunction(node);
t = convertFunction(node, templateTypes);
} else if (isBareArray(node)) { // Array

@@ -168,13 +176,19 @@ t = new ts.ArrayType(ts.anyType);

function convertArray(node: doctrine.type.TypeApplication): ts.Type {
function convertArray(
node: doctrine.type.TypeApplication, templateTypes: string[]): ts.Type {
const applications = node.applications;
return new ts.ArrayType(
applications.length === 1 ? convert(applications[0]) : ts.anyType);
applications.length === 1 ? convert(applications[0], templateTypes) :
ts.anyType);
}
function convertUnion(node: doctrine.type.UnionType): ts.Type {
return new ts.UnionType(node.elements.map(convert));
function convertUnion(
node: doctrine.type.UnionType, templateTypes: string[]): ts.Type {
return new ts.UnionType(
node.elements.map((element) => convert(element, templateTypes)));
}
function convertFunction(node: doctrine.type.FunctionType): ts.FunctionType {
function convertFunction(
node: doctrine.type.FunctionType,
templateTypes: string[]): ts.FunctionType {
return new ts.FunctionType(

@@ -185,5 +199,5 @@ node.params.map(

'p' + idx,
convert(param))),
convert(param, templateTypes))),
// Cast because typings are wrong: `FunctionType.result` is not an array.
node.result ? convert(node.result as any) : ts.anyType);
node.result ? convert(node.result as any, templateTypes) : ts.anyType);
}

@@ -190,0 +204,0 @@

@@ -28,2 +28,15 @@ /**

exclude?: string[];
/**
* Remove any triple-slash references to these files, specified as paths
* relative to the analysis root directory.
*/
removeReferences?: string[];
/**
* Additional files to insert as triple-slash reference statements. Given the
* map `a: b[]`, a will get an additional reference statement for each file
* path in b. All paths are relative to the analysis root directory.
*/
addReferences?: {[filepath: string]: string[]};
}

@@ -43,3 +56,3 @@

const outFiles = new Map<string, string>();
for (const tsDoc of analyzerToAst(analysis, config)) {
for (const tsDoc of analyzerToAst(analysis, config, rootDir)) {
outFiles.set(tsDoc.path, tsDoc.serialize())

@@ -55,6 +68,10 @@ }

function analyzerToAst(
analysis: analyzer.Analysis, config: Config): ts.Document[] {
analysis: analyzer.Analysis, config: Config, rootDir: string):
ts.Document[] {
const exclude = config.exclude !== undefined ?
config.exclude.map((p) => new RegExp(p)) :
[/test\//, /demo\//];
const addReferences = config.addReferences || {};
const removeReferencesResolved = new Set(
(config.removeReferences || []).map((r) => path.resolve(rootDir, r)));

@@ -90,2 +107,11 @@ // Analyzer can produce multiple JS documents with the same URL (e.g. an

}
for (const ref of tsDoc.referencePaths) {
const resolvedRef = path.resolve(rootDir, path.dirname(tsDoc.path), ref);
if (removeReferencesResolved.has(resolvedRef)) {
tsDoc.referencePaths.delete(ref);
}
}
for (const ref of addReferences[tsDoc.path] || []) {
tsDoc.referencePaths.add(path.relative(path.dirname(tsDoc.path), ref));
}
tsDoc.simplify();

@@ -122,2 +148,6 @@ // Include even documents with no members. They might be dependencies of

interface MaybePrivate {
privacy?: 'public'|'private'|'protected'
}
/**

@@ -129,2 +159,5 @@ * Extend the given TypeScript declarations document with all of the relevant

for (const feature of doc.getFeatures()) {
if ((feature as MaybePrivate).privacy === 'private') {
continue;
}
if (feature.kinds.has('element')) {

@@ -140,2 +173,4 @@ handleElement(feature as analyzer.Element, root);

handleFunction(feature as AnalyzerFunction, root);
} else if (feature.kinds.has('namespace')) {
handleNamespace(feature as analyzer.Namespace, root);
} else if (feature.kinds.has('import')) {

@@ -190,3 +225,3 @@ // Sometimes an Analyzer document includes an import feature that is

name: shortName,
description: feature.description,
description: feature.description || feature.summary,
extends: (feature.extends) ||

@@ -206,3 +241,3 @@ (isPolymerElement(feature) ? 'Polymer.Element' : 'HTMLElement'),

name: shortName,
description: feature.description,
description: feature.description || feature.summary,
properties: handleProperties(feature.properties.values()),

@@ -245,3 +280,3 @@ methods: handleMethods(feature.methods.values()),

const i = new ts.Interface({name: className});
i.description = feature.description;
i.description = feature.description || feature.summary;
i.properties = handleProperties(feature.properties.values());

@@ -257,7 +292,19 @@ i.methods = handleMethods(feature.methods.values());

const [namespacePath, name] = splitReference(feature.name);
const m = new ts.Mixin({name});
m.description = feature.description;
m.properties = handleProperties(feature.properties.values());
m.methods = handleMethods(feature.methods.values());
findOrCreateNamespace(root, namespacePath).members.push(m);
const namespace_ = findOrCreateNamespace(root, namespacePath);
// We represent mixins in two parts: a mixin function that is called to
// augment a given class with this mixin, and an interface with the
// properties and methods that are added by this mixin. We can use the same
// name for both parts because one is in value space, and the other is in
// type space.
const function_ = new ts.Mixin({name});
function_.description = feature.description;
function_.interfaces = [name, ...feature.mixins.map((m) => m.identifier)];
namespace_.members.push(function_);
const interface_ = new ts.Interface({name});
interface_.properties = handleProperties(feature.properties.values());
interface_.methods = handleMethods(feature.methods.values());
namespace_.members.push(interface_);
}

@@ -290,4 +337,6 @@

name,
description: feature.description,
returns: closureTypeToTypeScript(feature.return && feature.return.type)
description: feature.description || feature.summary,
templateTypes: feature.templateTypes,
returns: closureTypeToTypeScript(
feature.return && feature.return.type, feature.templateTypes)
});

@@ -298,3 +347,4 @@

// which only handles this for class method parameters currently.
const {type, optional, rest} = closureParamToTypeScript(param.type);
const {type, optional, rest} =
closureParamToTypeScript(param.type, feature.templateTypes);
f.params.push(new ts.Param({name: param.name, type, optional, rest}));

@@ -314,3 +364,3 @@ }

for (const property of analyzerProperties) {
if (property.inheritedFrom) {
if (property.inheritedFrom || property.privacy === 'private') {
continue;

@@ -339,3 +389,3 @@ }

for (const method of analyzerMethods) {
if (method.inheritedFrom) {
if (method.inheritedFrom || method.privacy === 'private') {
continue;

@@ -401,2 +451,12 @@ }

/**
* Add the given namespace to the given TypeScript declarations document.
*/
function handleNamespace(feature: analyzer.Namespace, tsDoc: ts.Document) {
const ns = findOrCreateNamespace(tsDoc, feature.name.split('.'));
if (ns.kind === 'namespace') {
ns.description = feature.description || feature.summary || '';
}
}
/**
* Add an HTML import to a TypeScript declarations file. For a given HTML

@@ -403,0 +463,0 @@ * import, we assume there is a corresponding declarations file that was

@@ -78,2 +78,3 @@ /**

name: string;
description: string;
members: Array<Namespace|Class|Interface|Mixin|Function>;

@@ -83,5 +84,7 @@

name: string,
description?: string;
members?: Array<Namespace|Class|Interface|Mixin|Function>,
}) {
this.name = data.name;
this.description = data.description || '';
this.members = data.members || [];

@@ -99,2 +102,5 @@ }

let out = ''
if (this.description) {
out += formatComment(this.description, depth);
}
const i = indent(depth)

@@ -247,3 +253,3 @@ out += i

// A class mixin using the pattern described at:
// A class mixin function using the pattern described at:
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html

@@ -254,4 +260,3 @@ export class Mixin {

description: string;
properties: Property[];
methods: Method[];
interfaces: string[];

@@ -261,18 +266,10 @@ constructor(data: {

description?: string,
properties?: Property[],
methods?: Method[]
interfaces?: string[],
}) {
this.name = data.name;
this.description = data.description || '';
this.properties = data.properties || [];
this.methods = data.methods || [];
this.interfaces = data.interfaces || [];
}
* traverse(): Iterable<Node> {
for (const p of this.properties) {
yield* p.traverse();
}
for (const m of this.methods) {
yield* m.traverse();
}
yield this;

@@ -294,10 +291,3 @@ }

out += `<T extends new(...args: any[]) => {}>(base: T): {\n`;
out += `${i2}new(...args: any[]): {\n`;
for (const property of this.properties) {
out += property.serialize(depth + 2);
}
for (const method of this.methods) {
out += method.serialize(depth + 2);
}
out += `${i2}}\n`;
out += `${i2}new(...args: any[]): ${this.interfaces.join(' & ')}\n`;
out += `${i}} & T\n`;

@@ -313,2 +303,3 @@ return out;

params: Param[];
templateTypes: string[];
returns: Type;

@@ -321,2 +312,3 @@ returnsDescription: string;

params?: Param[],
templateTypes?: string[],
returns?: Type,

@@ -329,2 +321,3 @@ returnsDescription?: string

this.returns = data.returns || anyType;
this.templateTypes = data.templateTypes || [];
this.returnsDescription = data.returnsDescription || '';

@@ -365,3 +358,7 @@ }

}
out += `${this.name}(`;
out += this.name;
if (this.templateTypes.length > 0) {
out += `<${this.templateTypes.join(', ')}>`;
}
out += '(';
out += this.params.map((p) => p.serialize()).join(', ');

@@ -368,0 +365,0 @@ out += `): ${this.returns.serialize()};\n`;

@@ -28,4 +28,5 @@ {

"node_modules",
"src/test/goldens"
"src/test/goldens",
"src/test/fixtures"
]
}

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc