New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

martok

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

martok - npm Package Compare versions

Comparing version 0.9.2 to 0.9.3

tests/comparisons/single/tagged3.d.ts

5

package.json
{
"name": "martok",
"version": "0.9.2",
"version": "0.9.3",
"description": "",

@@ -15,4 +15,5 @@ "main": "dist/src/index.js",

"tagged2": "ts-node src/index.ts tests/comparisons/single/tagged2.d.ts -o ./schema/martok --package net.sarazan.martok --datePattern standard",
"tagged3": "ts-node src/index.ts tests/comparisons/single/tagged3.d.ts -o ./schema/martok --package net.sarazan.martok --datePattern standard",
"literal": "ts-node src/index.ts tests/comparisons/single/stringLiteral.d.ts -o ./schema/martok --package net.sarazan.martok --datePattern standard",
"faceoff": "ts-node src/index.ts ../../volley/faceoff-backend/src/types -o ./schema/faceoff --package net.sarazan.martok --datePattern standard",
"faceoff": "ts-node src/index.ts ../../volley/faceoff-backend/src/types/core -o ./schema/faceoff --package net.sarazan.martok --datePattern standard",
"lint": "eslint . --ext .ts"

@@ -19,0 +20,0 @@ },

6

src/errors/TaggedUnionError.ts

@@ -1,7 +0,5 @@

import { ErrorDiscriminate } from "../typescript/UnionHelpers";
export class TaggedUnionError extends Error {
constructor() {
super(ErrorDiscriminate);
constructor(file: string, typeName: string) {
super(`Error processing tagged union in ${file}:\n${typeName}`);
}
}
import { Martok } from "../Martok";
import {
IntersectionTypeNode,
isIntersectionTypeNode,

@@ -38,4 +39,6 @@ isLiteralExpression,

const members: TypeElement[] = [];
if (!isTypeAliasDeclaration(node)) return undefined;
const type = node.type;
let type = node;
if (isTypeAliasDeclaration(node)) {
type = node.type;
}
if (!(isIntersectionTypeNode(type) || isUnionTypeNode(type)))

@@ -47,7 +50,2 @@ return undefined;

});
for (const type of types) {
if (isTypeLiteralNode(type)) {
members.push(...type.members);
}
}
const union = [type, ...types].find((value) => isUnionTypeNode(value)) as

@@ -59,2 +57,10 @@ | UnionTypeNode

}
const intersection = [type].filter((value) =>
isIntersectionTypeNode(value)
) as IntersectionTypeNode[];
for (const type of intersection.flatMap((value) => value.types)) {
if (isTypeLiteralNode(type)) {
members.push(...type.members);
}
}
const tag = this.getTag(union);

@@ -61,0 +67,0 @@

@@ -10,3 +10,2 @@ import { glob } from "glob";

import { StandardDatePattern } from "../typescript/Patterns";
import { ErrorDiscriminate } from "../typescript/UnionHelpers";

@@ -92,14 +91,2 @@ const PACKAGE = "net.sarazan.martok";

}
{
const filename = `${root}/ErrorDiscriminated.d.ts`;
it(path.basename(filename), async () => {
const martok = new Martok({
files: [filename],
package: PACKAGE,
sourceRoot: root,
});
expect(() => martok.generateMultiFile()).toThrow(ErrorDiscriminate);
});
}
});

@@ -160,3 +160,4 @@ import {

}),
isTaggedUnion
isTaggedUnion,
node
);

@@ -163,0 +164,0 @@ } else if (isTypeReferenceNode(node)) {

@@ -1,8 +0,7 @@

import { TypeChecker, TypeElement } from "typescript";
import { Node, TypeChecker, TypeElement, TypeNode } from "typescript";
import { getMemberType } from "./MemberHelpers";
import { TaggedUnionError } from "../errors/TaggedUnionError";
import { all } from "./utils";
import path from "path";
export const ErrorDiscriminate = `Can't have fully discriminated unions/intersections yet...`;
/**

@@ -13,2 +12,3 @@ * @throws TaggedUnionError

* @param isTaggedUnion
* @param typeName
*/

@@ -18,3 +18,4 @@ export function dedupeUnion(

types: ReadonlyArray<TypeElement>,
isTaggedUnion: boolean
isTaggedUnion: boolean,
node: Node
): ReadonlyArray<TypeElement> {

@@ -28,3 +29,4 @@ const seen = new Set<string>();

if (!isTaggedUnion) {
throw new TaggedUnionError();
const filename = path.basename(node.getSourceFile().fileName);
throw new TaggedUnionError(filename, node.getText());
}

@@ -31,0 +33,0 @@ } else {

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