Comparing version 0.1.16 to 0.1.17
@@ -134,2 +134,3 @@ export interface DeclarationBase { | ||
export declare type PrimitiveType = "string" | "number" | "boolean" | "any" | "void"; | ||
export declare type ThisType = "this"; | ||
export declare type TypeReference = TopLevelDeclaration | NamedTypeReference | ArrayTypeReference | PrimitiveType; | ||
@@ -139,3 +140,3 @@ export declare type ObjectTypeReference = ClassDeclaration | InterfaceDeclaration; | ||
export declare type ClassMember = ObjectTypeMember | ConstructorDeclaration; | ||
export declare type Type = TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType | TypeParameter; | ||
export declare type Type = TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType | TypeParameter | ThisType; | ||
export declare type Import = ImportAllDeclaration | ImportDefaultDeclaration; | ||
@@ -198,2 +199,3 @@ export declare type NamespaceMember = InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | NamespaceDeclaration | ConstDeclaration | FunctionDeclaration; | ||
void: PrimitiveType; | ||
this: "this"; | ||
}; | ||
@@ -200,0 +202,0 @@ export declare const reservedWords: string[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var DeclarationFlags; | ||
@@ -196,3 +197,4 @@ (function (DeclarationFlags) { | ||
any: "any", | ||
void: "void" | ||
void: "void", | ||
this: "this" | ||
}; | ||
@@ -260,4 +262,5 @@ exports.reservedWords = ['abstract', 'await', 'boolean', 'break', 'byte', 'case', | ||
function classFlagsToString(flags) { | ||
if (flags === void 0) { flags = DeclarationFlags.None; } | ||
var out = ''; | ||
if (flags & DeclarationFlags.Abstract) { | ||
if (flags && flags & DeclarationFlags.Abstract) { | ||
out += 'abstract '; | ||
@@ -268,2 +271,3 @@ } | ||
function memberFlagsToString(flags) { | ||
if (flags === void 0) { flags = DeclarationFlags.None; } | ||
var out = ''; | ||
@@ -288,2 +292,3 @@ if (flags & DeclarationFlags.Private) { | ||
function startWithDeclareOrExport(s, flags) { | ||
if (flags === void 0) { flags = DeclarationFlags.None; } | ||
if (getContextFlags() & ContextFlags.InAmbientNamespace) { | ||
@@ -343,2 +348,8 @@ // Already in an all-export context | ||
} | ||
function hasFlag(haystack, needle) { | ||
if (haystack === undefined) { | ||
return false; | ||
} | ||
return !!(needle & haystack); | ||
} | ||
function printObjectTypeMembers(members) { | ||
@@ -371,3 +382,3 @@ print('{'); | ||
print(quoteIfNeeded(member.name)); | ||
if (member.flags & DeclarationFlags.Optional) | ||
if (hasFlag(member.flags, DeclarationFlags.Optional)) | ||
print('?'); | ||
@@ -393,6 +404,6 @@ print('('); | ||
tab(); | ||
if (member.flags & DeclarationFlags.ReadOnly) | ||
if (hasFlag(member.flags, DeclarationFlags.ReadOnly)) | ||
print('readonly '); | ||
print(quoteIfNeeded(member.name)); | ||
if (member.flags & DeclarationFlags.Optional) | ||
if (hasFlag(member.flags, DeclarationFlags.Optional)) | ||
print('?'); | ||
@@ -513,3 +524,4 @@ print(': '); | ||
function writeParameter(p) { | ||
print("" + (p.flags & ParameterFlags.Rest ? '...' : '') + p.name + (p.flags & ParameterFlags.Optional ? '?' : '') + ": "); | ||
var flags = p.flags || DeclarationFlags.None; | ||
print("" + (flags & ParameterFlags.Rest ? '...' : '') + p.name + (flags & ParameterFlags.Optional ? '?' : '') + ": "); | ||
writeReference(p.type); | ||
@@ -516,0 +528,0 @@ } |
@@ -161,2 +161,4 @@ export interface DeclarationBase { | ||
export type ThisType = "this"; | ||
export type TypeReference = TopLevelDeclaration | NamedTypeReference | ArrayTypeReference | PrimitiveType; | ||
@@ -168,3 +170,3 @@ | ||
export type Type = TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType | TypeParameter; | ||
export type Type = TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType | TypeParameter | ThisType; | ||
@@ -391,3 +393,4 @@ export type Import = ImportAllDeclaration | ImportDefaultDeclaration; | ||
any: <PrimitiveType>"any", | ||
void: <PrimitiveType>"void" | ||
void: <PrimitiveType>"void", | ||
this: <ThisType>"this" | ||
}; | ||
@@ -461,6 +464,6 @@ | ||
function classFlagsToString(flags: DeclarationFlags | undefined): string { | ||
function classFlagsToString(flags: DeclarationFlags | undefined = DeclarationFlags.None): string { | ||
let out = ''; | ||
if (flags & DeclarationFlags.Abstract) { | ||
if (flags && flags & DeclarationFlags.Abstract) { | ||
out += 'abstract '; | ||
@@ -472,3 +475,3 @@ } | ||
function memberFlagsToString(flags: DeclarationFlags | undefined): string { | ||
function memberFlagsToString(flags: DeclarationFlags | undefined = DeclarationFlags.None): string { | ||
let out = ''; | ||
@@ -498,3 +501,3 @@ | ||
function startWithDeclareOrExport(s: string, flags: DeclarationFlags | undefined) { | ||
function startWithDeclareOrExport(s: string, flags: DeclarationFlags | undefined = DeclarationFlags.None) { | ||
if (getContextFlags() & ContextFlags.InAmbientNamespace) { | ||
@@ -555,2 +558,10 @@ // Already in an all-export context | ||
function hasFlag<T extends number>(haystack: T | undefined, needle: T): boolean; | ||
function hasFlag(haystack: number | undefined, needle: number) { | ||
if (haystack === undefined) { | ||
return false; | ||
} | ||
return !!(needle & haystack); | ||
} | ||
function printObjectTypeMembers(members: ObjectTypeMember[]) { | ||
@@ -583,3 +594,3 @@ print('{'); | ||
print(quoteIfNeeded(member.name)); | ||
if (member.flags & DeclarationFlags.Optional) print('?'); | ||
if (hasFlag(member.flags, DeclarationFlags.Optional)) print('?'); | ||
print('('); | ||
@@ -602,5 +613,5 @@ let first = true; | ||
tab(); | ||
if (member.flags & DeclarationFlags.ReadOnly) print('readonly '); | ||
if (hasFlag(member.flags, DeclarationFlags.ReadOnly)) print('readonly '); | ||
print(quoteIfNeeded(member.name)); | ||
if (member.flags & DeclarationFlags.Optional) print('?'); | ||
if (hasFlag(member.flags, DeclarationFlags.Optional)) print('?'); | ||
print(': '); | ||
@@ -735,3 +746,4 @@ writeReference(member.type); | ||
function writeParameter(p: Parameter) { | ||
print(`${p.flags & ParameterFlags.Rest ? '...' : ''}${p.name}${p.flags & ParameterFlags.Optional ? '?' : ''}: `); | ||
const flags = p.flags || DeclarationFlags.None; | ||
print(`${flags & ParameterFlags.Rest ? '...' : ''}${p.name}${flags & ParameterFlags.Optional ? '?' : ''}: `); | ||
writeReference(p.type); | ||
@@ -738,0 +750,0 @@ } |
{ | ||
"name": "dts-dom", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90184
1787