Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dts-dom

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dts-dom - npm Package Compare versions

Comparing version 0.1.13 to 0.1.14

12

bin/index.d.ts

@@ -27,2 +27,7 @@ export interface DeclarationBase {

}
export interface TypeParameter {
kind: "type-parameter";
name: string;
baseType?: ObjectTypeReference | TypeParameter;
}
export interface MethodDeclaration extends DeclarationBase {

@@ -33,2 +38,3 @@ kind: "method";

returnType: Type;
typeParameters: TypeParameter[];
}

@@ -40,2 +46,3 @@ export interface FunctionDeclaration extends DeclarationBase {

returnType: Type;
typeParameters: TypeParameter[];
}

@@ -51,2 +58,3 @@ export interface ConstructorDeclaration extends DeclarationBase {

implements: InterfaceDeclaration[];
typeParameters: TypeParameter[];
baseType?: ObjectTypeReference;

@@ -128,3 +136,3 @@ }

export declare type ClassMember = ObjectTypeMember | ConstructorDeclaration;
export declare type Type = TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType;
export declare type Type = TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType | TypeParameter;
export declare type Import = ImportAllDeclaration | ImportDefaultDeclaration;

@@ -143,2 +151,3 @@ export declare type NamespaceMember = InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | NamespaceDeclaration | ConstDeclaration | FunctionDeclaration;

ExportDefault = 64,
ReadOnly = 128,
}

@@ -157,2 +166,3 @@ export declare enum ParameterFlags {

class(name: string): ClassDeclaration;
typeParameter(name: string, baseType?: InterfaceDeclaration | ClassDeclaration | TypeParameter | undefined): TypeParameter;
enum(name: string, constant?: boolean): EnumDeclaration;

@@ -159,0 +169,0 @@ enumValue(name: string): EnumMemberDeclaration;

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

DeclarationFlags[DeclarationFlags["ExportDefault"] = 64] = "ExportDefault";
DeclarationFlags[DeclarationFlags["ReadOnly"] = 128] = "ReadOnly";
})(DeclarationFlags = exports.DeclarationFlags || (exports.DeclarationFlags = {}));

@@ -38,5 +39,12 @@ var ParameterFlags;

members: [],
implements: []
implements: [],
typeParameters: []
};
},
typeParameter: function (name, baseType) {
return {
kind: 'type-parameter',
name: name, baseType: baseType
};
},
enum: function (name, constant) {

@@ -67,2 +75,3 @@ if (constant === void 0) { constant = false; }

kind: "method",
typeParameters: [],
name: name, parameters: parameters, returnType: returnType, flags: flags

@@ -74,2 +83,3 @@ };

kind: "function",
typeParameters: [],
name: name, parameters: parameters, returnType: returnType

@@ -261,2 +271,5 @@ };

}
if (flags & DeclarationFlags.ReadOnly) {
out += 'readonly ';
}
return out;

@@ -356,2 +369,4 @@ }

tab();
if (member.flags & DeclarationFlags.ReadOnly)
print('readonly ');
print(quoteIfNeeded(member.name));

@@ -376,3 +391,7 @@ if (member.flags & DeclarationFlags.Optional)

switch (e.kind) {
case "type-parameter":
case "class":
case "interface":
case "name":
case "alias":
print(e.name);

@@ -388,6 +407,2 @@ break;

break;
case "class":
case "interface":
print(e.name);
break;
case "object":

@@ -411,2 +426,23 @@ printObjectTypeMembers(e.members);

}
function writeTypeParameters(params) {
if (params.length === 0)
return;
print('<');
var first = true;
for (var _i = 0, params_1 = params; _i < params_1.length; _i++) {
var p = params_1[_i];
if (!first)
print(', ');
print(p.name);
if (p.baseType) {
print(' extends ');
if (p.baseType.kind === 'type-parameter')
print(p.baseType.name);
else
writeReference(p.baseType);
}
first = false;
}
print('>');
}
function writeInterface(d) {

@@ -442,3 +478,5 @@ printDeclarationComments(d);

}
startWithDeclareOrExport("function " + f.name + "(", f.flags);
startWithDeclareOrExport("function " + f.name, f.flags);
writeTypeParameters(f.typeParameters);
print('(');
writeDelimited(f.parameters, ', ', writeParameter);

@@ -472,2 +510,3 @@ print('): ');

startWithDeclareOrExport(classFlagsToString(c.flags) + "class " + c.name, c.flags);
writeTypeParameters(c.typeParameters);
if (c.baseType) {

@@ -526,3 +565,5 @@ print(' extends ');

printDeclarationComments(m);
start("" + memberFlagsToString(m.flags) + quoteIfNeeded(m.name) + "(");
start("" + memberFlagsToString(m.flags) + quoteIfNeeded(m.name));
writeTypeParameters(m.typeParameters);
print('(');
writeDelimited(m.parameters, ', ', writeParameter);

@@ -529,0 +570,0 @@ print('): ');

@@ -32,2 +32,8 @@ export interface DeclarationBase {

export interface TypeParameter {
kind: "type-parameter";
name: string;
baseType?: ObjectTypeReference|TypeParameter;
}
export interface MethodDeclaration extends DeclarationBase {

@@ -38,2 +44,3 @@ kind: "method";

returnType: Type;
typeParameters: TypeParameter[];
}

@@ -46,2 +53,3 @@

returnType: Type;
typeParameters: TypeParameter[];
}

@@ -59,2 +67,3 @@

implements: InterfaceDeclaration[];
typeParameters: TypeParameter[];
baseType?: ObjectTypeReference;

@@ -155,3 +164,3 @@ }

export type Type = TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType;
export type Type = TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType | TypeParameter;

@@ -173,2 +182,3 @@ export type Import = ImportAllDeclaration | ImportDefaultDeclaration;

ExportDefault = 1 << 6,
ReadOnly = 1 << 7,
}

@@ -202,6 +212,14 @@

members: [],
implements: []
implements: [],
typeParameters: []
};
},
typeParameter(name: string, baseType?: ObjectTypeReference|TypeParameter): TypeParameter {
return {
kind: 'type-parameter',
name, baseType
};
},
enum(name: string, constant: boolean = false): EnumDeclaration {

@@ -232,2 +250,3 @@ return {

kind: "method",
typeParameters: [],
name, parameters, returnType, flags

@@ -240,2 +259,3 @@ };

kind: "function",
typeParameters: [],
name, parameters, returnType

@@ -461,2 +481,6 @@ };

if (flags & DeclarationFlags.ReadOnly) {
out += 'readonly ';
}
return out;

@@ -555,2 +579,3 @@ }

tab();
if (member.flags & DeclarationFlags.ReadOnly) print('readonly ');
print(quoteIfNeeded(member.name));

@@ -574,3 +599,7 @@ if (member.flags & DeclarationFlags.Optional) print('?');

switch (e.kind) {
case "type-parameter":
case "class":
case "interface":
case "name":
case "alias":
print(e.name);

@@ -586,7 +615,2 @@ break;

case "class":
case "interface":
print(e.name);
break;
case "object":

@@ -616,2 +640,29 @@ printObjectTypeMembers(e.members);

function writeTypeParameters(params: TypeParameter[]) {
if (params.length === 0) return;
print('<');
let first = true;
for (const p of params) {
if (!first) print(', ');
print(p.name);
if (p.baseType) {
print(' extends ');
if (p.baseType.kind === 'type-parameter')
print(p.baseType.name);
else
writeReference(p.baseType);
}
first = false;
}
print('>');
}
function writeInterface(d: InterfaceDeclaration) {

@@ -648,4 +699,5 @@ printDeclarationComments(d);

startWithDeclareOrExport(`function ${f.name}(`, f.flags);
startWithDeclareOrExport(`function ${f.name}`, f.flags);
writeTypeParameters(f.typeParameters);
print('(')
writeDelimited(f.parameters, ', ', writeParameter);

@@ -682,2 +734,3 @@ print('): ');

startWithDeclareOrExport(`${classFlagsToString(c.flags)}class ${c.name}`, c.flags);
writeTypeParameters(c.typeParameters);
if (c.baseType) {

@@ -737,3 +790,5 @@ print(' extends ');

printDeclarationComments(m);
start(`${memberFlagsToString(m.flags)}${quoteIfNeeded(m.name)}(`);
start(`${memberFlagsToString(m.flags)}${quoteIfNeeded(m.name)}`);
writeTypeParameters(m.typeParameters);
print('(');
writeDelimited(m.parameters, ', ', writeParameter);

@@ -740,0 +795,0 @@ print('): ');

2

package.json
{
"name": "dts-dom",
"version": "0.1.13",
"version": "0.1.14",
"homepage": "https://github.com/RyanCavanaugh/dts-dom",

@@ -5,0 +5,0 @@ "description": "DOM for TypeScript Declaration Files",

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