Comparing version 3.6.0 to 3.7.0
@@ -31,3 +31,3 @@ export interface DeclarationBase { | ||
name: string; | ||
baseType?: ObjectTypeReference | TypeParameter; | ||
baseType?: ObjectTypeReference | TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType | TypeParameter; | ||
defaultType?: Type; | ||
@@ -77,2 +77,3 @@ } | ||
members: ObjectTypeMember[]; | ||
typeParameters: TypeParameter[]; | ||
baseTypes?: ObjectTypeReference[]; | ||
@@ -199,3 +200,4 @@ } | ||
} | ||
export declare type PrimitiveType = "string" | "number" | "boolean" | "any" | "void" | "object" | "null" | "undefined" | "true" | "false" | StringLiteral | NumberLiteral; | ||
export declare type PrimitiveType = "string" | "number" | "boolean" | "any" | "unknown" | "void" | "object" | "null" | "undefined" | "true" | "false" | StringLiteral | NumberLiteral; | ||
export declare function isPrimitiveType(x: Type): x is PrimitiveType; | ||
export declare type ThisType = "this"; | ||
@@ -210,3 +212,3 @@ export declare type TripleSlashDirective = TripleSlashReferencePathDirective | TripleSlashReferenceTypesDirective | TripleSlashReferenceNoDefaultLibDirective | TripleSlashAmdModuleDirective; | ||
export declare type NamespaceMember = InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | NamespaceDeclaration | ConstDeclaration | VariableDeclaration | FunctionDeclaration | EnumDeclaration; | ||
export declare type ModuleMember = InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | NamespaceDeclaration | ConstDeclaration | VariableDeclaration | FunctionDeclaration | Import | ExportEqualsDeclaration | ExportDefaultDeclaration; | ||
export declare type ModuleMember = InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | NamespaceDeclaration | ConstDeclaration | VariableDeclaration | FunctionDeclaration | Import | ExportEqualsDeclaration | ExportDefaultDeclaration | EnumDeclaration; | ||
export declare type TopLevelDeclaration = NamespaceMember | ExportEqualsDeclaration | ExportDefaultDeclaration | ExportNameDeclaration | ModuleDeclaration | EnumDeclaration | Import; | ||
@@ -236,3 +238,3 @@ export declare enum DeclarationFlags { | ||
class(name: string, flags?: DeclarationFlags): ClassDeclaration; | ||
typeParameter(name: string, baseType?: InterfaceDeclaration | ClassDeclaration | TypeParameter | undefined): TypeParameter; | ||
typeParameter(name: string, baseType?: "string" | "number" | "boolean" | "undefined" | "object" | "unknown" | EnumDeclaration | InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | NamespaceDeclaration | ConstDeclaration | VariableDeclaration | FunctionDeclaration | ExportEqualsDeclaration | ExportDefaultDeclaration | ExportNameDeclaration | ModuleDeclaration | ImportAllDeclaration | ImportDefaultDeclaration | ImportNamedDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamedTypeReference | ArrayTypeReference | "any" | "void" | "null" | "true" | "false" | StringLiteral | NumberLiteral | UnionType | IntersectionType | ObjectType | TypeofReference | FunctionType | TypeParameter | undefined): TypeParameter; | ||
enum(name: string, constant?: boolean, flags?: DeclarationFlags): EnumDeclaration; | ||
@@ -280,2 +282,3 @@ enumValue(name: string, value?: string | number | undefined): EnumMemberDeclaration; | ||
any: PrimitiveType; | ||
unknown: PrimitiveType; | ||
void: PrimitiveType; | ||
@@ -282,0 +285,0 @@ object: PrimitiveType; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function isPrimitiveType(x) { | ||
switch (x) { | ||
case "string": | ||
case "number": | ||
case "boolean": | ||
case "any": | ||
case "unknown": | ||
case "void": | ||
case "object": | ||
case "null": | ||
case "undefined": | ||
case "true": | ||
case "false": | ||
return true; | ||
} | ||
// StringLiteral | ||
if (typeof x === 'string') { | ||
return true; | ||
} | ||
// NumberLiteral | ||
if (typeof x === 'number') { | ||
return true; | ||
} | ||
return false; | ||
} | ||
exports.isPrimitiveType = isPrimitiveType; | ||
var DeclarationFlags; | ||
@@ -31,2 +57,3 @@ (function (DeclarationFlags) { | ||
baseTypes: [], | ||
typeParameters: [], | ||
kind: "interface", | ||
@@ -300,2 +327,3 @@ members: [], | ||
any: "any", | ||
unknown: "unknown", | ||
void: "void", | ||
@@ -498,12 +526,3 @@ object: "object", | ||
print("("); | ||
var first_1 = true; | ||
for (var _i = 0, _a = member.parameters; _i < _a.length; _i++) { | ||
var param = _a[_i]; | ||
if (!first_1) | ||
print(", "); | ||
first_1 = false; | ||
print(param.name); | ||
print(": "); | ||
writeReference(param.type); | ||
} | ||
writeDelimited(member.parameters, ', ', writeParameter); | ||
print("): "); | ||
@@ -524,4 +543,4 @@ writeReference(member.returnType); | ||
var first = true; | ||
for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { | ||
var param = _c[_b]; | ||
for (var _i = 0, _a = member.parameters; _i < _a.length; _i++) { | ||
var param = _a[_i]; | ||
if (!first) | ||
@@ -633,3 +652,5 @@ print(', '); | ||
print(' extends '); | ||
if (p.baseType.kind === 'type-parameter') | ||
if (isPrimitiveType(p.baseType)) | ||
print(String(p.baseType)); | ||
else if (p.baseType.kind === 'type-parameter') | ||
print(p.baseType.name); | ||
@@ -663,3 +684,5 @@ else | ||
printDeclarationComments(d); | ||
startWithDeclareOrExport("interface " + d.name + " ", d.flags); | ||
startWithDeclareOrExport("interface ", d.flags); | ||
print(d.name); | ||
writeTypeParameters(d.typeParameters); | ||
if (d.baseTypes && d.baseTypes.length) { | ||
@@ -676,2 +699,3 @@ print("extends "); | ||
} | ||
print(" "); | ||
printObjectTypeMembers(d.members); | ||
@@ -678,0 +702,0 @@ newline(); |
@@ -36,3 +36,3 @@ export interface DeclarationBase { | ||
name: string; | ||
baseType?: ObjectTypeReference|TypeParameter; | ||
baseType?: ObjectTypeReference | TypeReference | UnionType | IntersectionType | PrimitiveType | ObjectType | TypeofReference | FunctionType | TypeParameter; | ||
defaultType?: Type; | ||
@@ -89,2 +89,3 @@ } | ||
members: ObjectTypeMember[]; | ||
typeParameters: TypeParameter[]; | ||
baseTypes?: ObjectTypeReference[]; | ||
@@ -238,4 +239,30 @@ } | ||
export type PrimitiveType = "string" | "number" | "boolean" | "any" | "void" | "object" | "null" | "undefined" | "true" | "false" | StringLiteral | NumberLiteral; | ||
export type PrimitiveType = "string" | "number" | "boolean" | "any" | "unknown" | "void" | "object" | "null" | "undefined" | "true" | "false" | StringLiteral | NumberLiteral; | ||
export function isPrimitiveType(x: Type): x is PrimitiveType { | ||
switch (x) { | ||
case "string": | ||
case "number": | ||
case "boolean": | ||
case "any": | ||
case "unknown": | ||
case "void": | ||
case "object": | ||
case "null": | ||
case "undefined": | ||
case "true": | ||
case "false": | ||
return true; | ||
} | ||
// StringLiteral | ||
if (typeof x === 'string') { | ||
return true; | ||
} | ||
// NumberLiteral | ||
if (typeof x === 'number') { | ||
return true; | ||
} | ||
return false; | ||
} | ||
export type ThisType = "this"; | ||
@@ -256,3 +283,3 @@ | ||
export type NamespaceMember = InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | NamespaceDeclaration | ConstDeclaration | VariableDeclaration | FunctionDeclaration | EnumDeclaration; | ||
export type ModuleMember = InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | NamespaceDeclaration | ConstDeclaration | VariableDeclaration | FunctionDeclaration | Import | ExportEqualsDeclaration | ExportDefaultDeclaration; | ||
export type ModuleMember = InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | NamespaceDeclaration | ConstDeclaration | VariableDeclaration | FunctionDeclaration | Import | ExportEqualsDeclaration | ExportDefaultDeclaration | EnumDeclaration; | ||
export type TopLevelDeclaration = NamespaceMember | ExportEqualsDeclaration | ExportDefaultDeclaration | ExportNameDeclaration | ModuleDeclaration | EnumDeclaration | Import; | ||
@@ -288,2 +315,3 @@ | ||
baseTypes: [], | ||
typeParameters: [], | ||
kind: "interface", | ||
@@ -306,3 +334,3 @@ members: [], | ||
typeParameter(name: string, baseType?: ObjectTypeReference|TypeParameter): TypeParameter { | ||
typeParameter(name: string, baseType?: TypeParameter['baseType']): TypeParameter { | ||
return { | ||
@@ -583,2 +611,3 @@ kind: 'type-parameter', | ||
any: <PrimitiveType>"any", | ||
unknown: <PrimitiveType>"unknown", | ||
void: <PrimitiveType>"void", | ||
@@ -806,10 +835,3 @@ object: <PrimitiveType>"object", | ||
print("("); | ||
let first = true; | ||
for (const param of member.parameters) { | ||
if (!first) print(", "); | ||
first = false; | ||
print(param.name); | ||
print(": "); | ||
writeReference(param.type); | ||
} | ||
writeDelimited(member.parameters, ', ', writeParameter); | ||
print("): "); | ||
@@ -943,3 +965,5 @@ writeReference(member.returnType); | ||
if (p.baseType.kind === 'type-parameter') | ||
if (isPrimitiveType(p.baseType)) | ||
print(String(p.baseType)); | ||
else if (p.baseType.kind === 'type-parameter') | ||
print(p.baseType.name); | ||
@@ -981,3 +1005,5 @@ else | ||
printDeclarationComments(d); | ||
startWithDeclareOrExport(`interface ${d.name} `, d.flags); | ||
startWithDeclareOrExport(`interface `, d.flags); | ||
print(d.name); | ||
writeTypeParameters(d.typeParameters); | ||
if (d.baseTypes && d.baseTypes.length) { | ||
@@ -992,2 +1018,3 @@ print(`extends `); | ||
} | ||
print(" "); | ||
printObjectTypeMembers(d.members); | ||
@@ -994,0 +1021,0 @@ newline(); |
{ | ||
"name": "dts-dom", | ||
"version": "3.6.0", | ||
"version": "3.7.0", | ||
"homepage": "https://github.com/RyanCavanaugh/dts-dom", | ||
@@ -5,0 +5,0 @@ "description": "DOM for TypeScript Declaration Files", |
@@ -46,2 +46,5 @@ [![npm version](https://badge.fury.io/js/dts-dom.svg)](https://badge.fury.io/js/dts-dom) | ||
## 3.7.0 | ||
* **New Functionality**: [Support for `unknown`](https://github.com/RyanCavanaugh/dts-dom/pull/86) | ||
## 3.6.0 | ||
@@ -48,0 +51,0 @@ * **New Functionality**: [Namespaces may now contain enums](https://github.com/RyanCavanaugh/dts-dom/pull/62) |
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
147436
35
2838
150