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 1.0.0 to 2.0.0

lib/__tests__/__snapshots__/tripleSlashDirective.test.ts.snap

27

bin/index.d.ts

@@ -174,4 +174,21 @@ export interface DeclarationBase {

}
export interface TripleSlashReferencePathDirective {
kind: "triple-slash-reference-path";
path: string;
}
export interface TripleSlashReferenceTypesDirective {
kind: "triple-slash-reference-types";
types: string;
}
export interface TripleSlashReferenceNoDefaultLibDirective {
kind: "triple-slash-reference-no-default-lib";
value: boolean;
}
export interface TripleSlashAmdModuleDirective {
kind: "triple-slash-amd-module";
name?: string;
}
export declare type PrimitiveType = "string" | "number" | "boolean" | "any" | "void" | "object" | "null" | "undefined" | "true" | "false" | StringLiteral | NumberLiteral;
export declare type ThisType = "this";
export declare type TripleSlashDirective = TripleSlashReferencePathDirective | TripleSlashReferenceTypesDirective | TripleSlashReferenceNoDefaultLibDirective | TripleSlashAmdModuleDirective;
export declare type TypeReference = TopLevelDeclaration | NamedTypeReference | ArrayTypeReference | PrimitiveType;

@@ -237,2 +254,6 @@ export declare type ObjectTypeReference = ClassDeclaration | InterfaceDeclaration;

typeof(type: NamedTypeReference): TypeofReference;
tripleSlashReferencePathDirective(path: string): TripleSlashReferencePathDirective;
tripleSlashReferenceTypesDirective(types: string): TripleSlashReferenceTypesDirective;
tripleSlashReferenceNoDefaultLibDirective(value?: boolean): TripleSlashReferenceNoDefaultLibDirective;
tripleSlashAmdModuleDirective(name?: string | undefined): TripleSlashAmdModuleDirective;
};

@@ -266,2 +287,6 @@ export declare const type: {

export declare function never(x: never, err: string): never;
export declare function emit(rootDecl: TopLevelDeclaration, rootFlags?: ContextFlags): string;
export interface EmitOptions {
rootFlags?: ContextFlags;
tripleSlashDirectives?: TripleSlashDirective[];
}
export declare function emit(rootDecl: TopLevelDeclaration, {rootFlags, tripleSlashDirectives}?: EmitOptions): string;

@@ -235,2 +235,27 @@ "use strict";

};
},
tripleSlashReferencePathDirective: function (path) {
return {
kind: "triple-slash-reference-path",
path: path
};
},
tripleSlashReferenceTypesDirective: function (types) {
return {
kind: "triple-slash-reference-types",
types: types
};
},
tripleSlashReferenceNoDefaultLibDirective: function (value) {
if (value === void 0) { value = true; }
return {
kind: "triple-slash-reference-no-default-lib",
value: value
};
},
tripleSlashAmdModuleDirective: function (name) {
return {
kind: "triple-slash-amd-module",
name: name
};
}

@@ -306,7 +331,8 @@ };

exports.never = never;
function emit(rootDecl, rootFlags) {
if (rootFlags === void 0) { rootFlags = ContextFlags.None; }
function emit(rootDecl, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.rootFlags, rootFlags = _c === void 0 ? ContextFlags.None : _c, _d = _b.tripleSlashDirectives, tripleSlashDirectives = _d === void 0 ? [] : _d;
var output = "";
var indentLevel = 0;
var contextStack = [rootFlags];
tripleSlashDirectives.forEach(writeTripleSlashDirective);
writeDeclaration(rootDecl);

@@ -826,2 +852,26 @@ newline();

}
function writeTripleSlashDirective(t) {
var type = t.kind === "triple-slash-amd-module" ? "amd-module" : "reference";
start("/// <" + type);
switch (t.kind) {
case "triple-slash-reference-path":
print(" path=\"" + t.path + "\"");
break;
case "triple-slash-reference-types":
print(" types=\"" + t.types + "\"");
break;
case "triple-slash-reference-no-default-lib":
print(" no-default-lib=\"" + t.value + "\"");
break;
case "triple-slash-amd-module":
if (t.name) {
print(" name=\"" + t.name + "\"");
}
break;
default:
never(t, "Unknown triple slash directive kind " + t.kind);
}
print(" />");
newline();
}
function writeDeclaration(d) {

@@ -828,0 +878,0 @@ if (typeof d === 'string') {

@@ -208,2 +208,22 @@ export interface DeclarationBase {

export interface TripleSlashReferencePathDirective {
kind: "triple-slash-reference-path",
path: string;
}
export interface TripleSlashReferenceTypesDirective {
kind: "triple-slash-reference-types",
types: string;
}
export interface TripleSlashReferenceNoDefaultLibDirective {
kind: "triple-slash-reference-no-default-lib",
value: boolean;
}
export interface TripleSlashAmdModuleDirective {
kind: "triple-slash-amd-module",
name?: string;
}
export type PrimitiveType = "string" | "number" | "boolean" | "any" | "void" | "object" | "null" | "undefined" | "true" | "false" | StringLiteral | NumberLiteral;

@@ -213,2 +233,4 @@

export type TripleSlashDirective = TripleSlashReferencePathDirective | TripleSlashReferenceTypesDirective | TripleSlashReferenceNoDefaultLibDirective | TripleSlashAmdModuleDirective;
export type TypeReference = TopLevelDeclaration | NamedTypeReference | ArrayTypeReference | PrimitiveType;

@@ -479,2 +501,30 @@

};
},
tripleSlashReferencePathDirective(path: string): TripleSlashReferencePathDirective {
return {
kind: "triple-slash-reference-path",
path
};
},
tripleSlashReferenceTypesDirective(types: string): TripleSlashReferenceTypesDirective {
return {
kind: "triple-slash-reference-types",
types
};
},
tripleSlashReferenceNoDefaultLibDirective(value: boolean = true): TripleSlashReferenceNoDefaultLibDirective {
return {
kind: "triple-slash-reference-no-default-lib",
value
};
},
tripleSlashAmdModuleDirective(name?: string): TripleSlashAmdModuleDirective {
return {
kind: "triple-slash-amd-module",
name
};
}

@@ -553,3 +603,8 @@ };

export function emit(rootDecl: TopLevelDeclaration, rootFlags = ContextFlags.None): string {
export interface EmitOptions {
rootFlags?: ContextFlags;
tripleSlashDirectives?: TripleSlashDirective[];
}
export function emit(rootDecl: TopLevelDeclaration, { rootFlags = ContextFlags.None, tripleSlashDirectives = [] }: EmitOptions = {}): string {
let output = "";

@@ -559,2 +614,4 @@ let indentLevel = 0;

tripleSlashDirectives.forEach(writeTripleSlashDirective);
writeDeclaration(rootDecl);

@@ -1110,2 +1167,29 @@ newline();

function writeTripleSlashDirective(t: TripleSlashDirective) {
const type = t.kind === "triple-slash-amd-module" ? "amd-module" : "reference";
start(`/// <${type}`);
switch (t.kind) {
case "triple-slash-reference-path":
print(` path="${t.path}"`);
break;
case "triple-slash-reference-types":
print(` types="${t.types}"`);
break;
case "triple-slash-reference-no-default-lib":
print(` no-default-lib="${t.value}"`);
break;
case "triple-slash-amd-module":
if (t.name) {
print(` name="${t.name}"`);
}
break;
default:
never(t, `Unknown triple slash directive kind ${(t as TripleSlashDirective).kind}`);
}
print(" />");
newline();
}
function writeDeclaration(d: TopLevelDeclaration) {

@@ -1112,0 +1196,0 @@ if (typeof d === 'string') {

5

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

@@ -38,4 +38,7 @@ "description": "DOM for TypeScript Declaration Files",

"lib/**/*.ts"
],
"snapshotSerializers": [
"./lib/__tests__/string-snapshot-serializer"
]
}
}

@@ -44,2 +44,40 @@ [![npm version](https://badge.fury.io/js/dts-dom.svg)](https://badge.fury.io/js/dts-dom)

# Version History
## 2.0 (not yet released)
* **New Functionality**: Added the ability to emit [triple-slash directives](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html) #39
```ts
const tripleSlashDirectives = [create.tripleSlashReferenceTypesDirective("react")];
const returnType = create.namedTypeReference('JSX.Element');
const component = create.function('Component', [], returnType, DeclarationFlags.Export);
const s = emit(component, { tripleSlashDirectives });
```
The value of `s` is:
```ts
/// <reference types="react" />
export function Component(): JSX.Element;
```
* **Breaking Change**: Changed the second parameter of `emit` from `ContextFlags` to `EmitOptions` #39
```ts
// 1.0
const s = emit(tree, ContextFlags.Module);
// 2.0
const s = emit(tree, { rootFlags: ContextFlags.Module });
```
## 1.0
The same as 0.1.25
# Semver Policy
The major version will be bumped if:
* The *semantics* of emitted code changes, even if the prior emit was categorically wrong
* The API surface changes in a way that could break the runtime behavior of extant working code
The major version will *not* be bumped if:
* New API surface is added
* The *formatting* of emitted code changes
# Contributors

@@ -46,0 +84,0 @@

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc