🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

ts-snippet

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-snippet - npm Package Compare versions

Comparing version

to
5.0.1

7

CHANGELOG.md

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

<a name="5.0.1"></a>
## [5.0.1](https://github.com/cartant/ts-snippet/compare/v5.0.0...v5.0.1) (2020-11-21)
### Changes
* Include the actual error(s) when a failure expectation's regular expression does not match. ([55778a5](https://github.com/cartant/ts-snippet/commit/55778a5))
<a name="5.0.0"></a>

@@ -2,0 +9,0 @@ ## [5.0.0](https://github.com/cartant/ts-snippet/compare/v4.3.0...v5.0.0) (2020-10-28)

18

compiler.js

@@ -13,2 +13,18 @@ "use strict";

};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -26,3 +42,3 @@ exports.Compiler = void 0;

var _a = ts.convertCompilerOptionsFromJson(__assign({ moduleResolution: "node", skipLibCheck: true, target: "es2017" }, compilerOptions), normalize(rootDirectory)), errors = _a.errors, options = _a.options;
var error = errors[0];
var _b = __read(errors, 1), error = _b[0];
if (error) {

@@ -29,0 +45,0 @@ throw new Error(this.formatDiagnostic(error));

11

esm2015/snippet.js

@@ -14,2 +14,5 @@ import * as tsutils from "tsutils";

}
expect(fileName) {
return new Expect(this.fail.bind(this, fileName), this.infer.bind(this, fileName), this.succeed.bind(this, fileName));
}
fail(fileName, expectedMessage) {

@@ -21,3 +24,6 @@ const diagnostics = this._getDiagnostics(fileName);

this.assertFail(expectedMessage
? `Expected an error matching ${expectedMessage}`
? `Expected an error matching:
${expectedMessage}
but received:
${[...new Set(messages)].join("\n")}`
: "Expected an error");

@@ -29,5 +35,2 @@ }

}
expect(fileName) {
return new Expect(this.fail.bind(this, fileName), this.infer.bind(this, fileName), this.succeed.bind(this, fileName));
}
infer(fileName, variableName, expectedType) {

@@ -34,0 +37,0 @@ this.succeed(fileName);

@@ -12,2 +12,18 @@ var __assign = (this && this.__assign) || function () {

};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
import * as ts from "typescript";

@@ -23,3 +39,3 @@ var Compiler = (function () {

var _a = ts.convertCompilerOptionsFromJson(__assign({ moduleResolution: "node", skipLibCheck: true, target: "es2017" }, compilerOptions), normalize(rootDirectory)), errors = _a.errors, options = _a.options;
var error = errors[0];
var _b = __read(errors, 1), error = _b[0];
if (error) {

@@ -26,0 +42,0 @@ throw new Error(this.formatDiagnostic(error));

@@ -0,1 +1,21 @@

var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
import * as tsutils from "tsutils";

@@ -14,2 +34,5 @@ import { Compiler } from "./compiler";

}
Snippet.prototype.expect = function (fileName) {
return new Expect(this.fail.bind(this, fileName), this.infer.bind(this, fileName), this.succeed.bind(this, fileName));
};
Snippet.prototype.fail = function (fileName, expectedMessage) {

@@ -23,3 +46,3 @@ var diagnostics = this._getDiagnostics(fileName);

this.assertFail(expectedMessage
? "Expected an error matching " + expectedMessage
? "Expected an error matching:\n" + expectedMessage + "\nbut received:\n" + __spread(new Set(messages)).join("\n")
: "Expected an error");

@@ -31,5 +54,2 @@ }

};
Snippet.prototype.expect = function (fileName) {
return new Expect(this.fail.bind(this, fileName), this.infer.bind(this, fileName), this.succeed.bind(this, fileName));
};
Snippet.prototype.infer = function (fileName, variableName, expectedType) {

@@ -53,3 +73,3 @@ this.succeed(fileName);

if (diagnostics.length) {
var diagnostic = diagnostics[0];
var _a = __read(diagnostics, 1), diagnostic = _a[0];
this.assertFail(this._compiler.formatDiagnostic(diagnostic));

@@ -56,0 +76,0 @@ }

@@ -42,3 +42,3 @@ {

"types": "./index.d.ts",
"version": "5.0.0"
"version": "5.0.1"
}

@@ -13,4 +13,4 @@ import * as ts from "typescript";

}, _compiler: Compiler);
expect(fileName: string): Expect;
fail(fileName: string, expectedMessage?: RegExp): void;
expect(fileName: string): Expect;
infer(fileName: string, variableName: string, expectedType: string): void;

@@ -17,0 +17,0 @@ succeed(fileName: string): void;

"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -17,2 +37,5 @@ exports.snippet = exports.getVariables = exports.areEquivalentTypeStrings = exports.Snippet = void 0;

}
Snippet.prototype.expect = function (fileName) {
return new expect_1.Expect(this.fail.bind(this, fileName), this.infer.bind(this, fileName), this.succeed.bind(this, fileName));
};
Snippet.prototype.fail = function (fileName, expectedMessage) {

@@ -26,3 +49,3 @@ var diagnostics = this._getDiagnostics(fileName);

this.assertFail(expectedMessage
? "Expected an error matching " + expectedMessage
? "Expected an error matching:\n" + expectedMessage + "\nbut received:\n" + __spread(new Set(messages)).join("\n")
: "Expected an error");

@@ -34,5 +57,2 @@ }

};
Snippet.prototype.expect = function (fileName) {
return new expect_1.Expect(this.fail.bind(this, fileName), this.infer.bind(this, fileName), this.succeed.bind(this, fileName));
};
Snippet.prototype.infer = function (fileName, variableName, expectedType) {

@@ -56,3 +76,3 @@ this.succeed(fileName);

if (diagnostics.length) {
var diagnostic = diagnostics[0];
var _a = __read(diagnostics, 1), diagnostic = _a[0];
this.assertFail(this._compiler.formatDiagnostic(diagnostic));

@@ -59,0 +79,0 @@ }