Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@effect/language-service

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/language-service - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

_mjs/utils/AST.mjs

6

diagnostics/definition.d.ts

@@ -1,3 +0,3 @@

import type * as T from "@effect/io/Effect";
import type * as Ch from "@fp-ts/data/Chunk";
import type * as AST from "@effect/language-service/utils/AST";
import type * as Ch from "@effect/language-service/utils/ReadonlyArray";
import type ts from "typescript/lib/tsserverlibrary";

@@ -12,5 +12,5 @@ export interface DiagnosticDefinitionMessage {

category: DiagnosticDefinitionMessageCategory;
apply: <E>(sourceFile: ts.SourceFile) => T.Effect<typeof ts | ts.Program, E, Ch.Chunk<DiagnosticDefinitionMessage>>;
apply: (ts: AST.TypeScriptApi, program: ts.Program) => (sourceFile: ts.SourceFile) => Ch.Chunk<DiagnosticDefinitionMessage>;
}
export declare function createDiagnostic(definition: DiagnosticDefinition): DiagnosticDefinition;
//# sourceMappingURL=definition.d.ts.map

@@ -7,7 +7,6 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/diagnostics/definition");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -18,5 +17,3 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

category: "none",
apply: sourceFile => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
const program = yield* $(T.service(AST.TypeScriptProgram));
apply: (ts, program) => sourceFile => {
const typeChecker = program.getTypeChecker();

@@ -59,5 +56,5 @@ function isEffectType(type) {

})));
})
}
});
exports.default = _default;
//# sourceMappingURL=ensureGetCallTrace.js.map

@@ -1,2 +0,2 @@

import * as AST from "@effect/language-service/ast";
import * as AST from "@effect/language-service/utils/AST";
export declare const noSyncWithConstantMethodsMap: {

@@ -3,0 +3,0 @@ sync: string;

@@ -9,8 +9,6 @@ "use strict";

exports.noSyncWithConstantMethodsMap = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/diagnostics/definition");
var _utils = /*#__PURE__*/require("@effect/language-service/utils");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -26,5 +24,5 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

return (moduleIdentifier, methodName) => node => {
if ((0, _utils.isCombinatorCall)(ts)(moduleIdentifier, methodName)(node) && node.arguments.length === 1) {
if (AST.isCombinatorCall(ts)(moduleIdentifier, methodName)(node) && node.arguments.length === 1) {
const arg = node.arguments[0];
if (ts.isArrowFunction(arg) && (0, _utils.isLiteralConstantValue)(ts)(arg.body)) {
if (ts.isArrowFunction(arg) && AST.isLiteralConstantValue(ts)(arg.body)) {
return true;

@@ -39,5 +37,4 @@ }

category: "warning",
apply: sourceFile => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
const effectIdentifier = (0, _utils.getEffectModuleIdentifier)(ts)(sourceFile);
apply: ts => sourceFile => {
const effectIdentifier = AST.getEffectModuleIdentifier(ts)(sourceFile);
let result = Ch.empty;

@@ -52,5 +49,5 @@ for (const methodName of Object.keys(noSyncWithConstantMethodsMap)) {

return result;
})
}
});
exports.default = _default;
//# sourceMappingURL=noSyncWithConstant.js.map

@@ -8,3 +8,3 @@ "use strict";

var utils = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/eslint-rules/utils"));
var U = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var ts = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("typescript/lib/tsserverlibrary"));

@@ -19,3 +19,3 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
if (U.isCurryArrow(ts)(tsNode)) {
if (AST.isCurryArrow(ts)(tsNode)) {
context.report({

@@ -22,0 +22,0 @@ messageId: "noCurryArrow",

"use strict";
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _config = /*#__PURE__*/require("@effect/language-service/config");
var _index = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("@effect/language-service/diagnostics/index"));
var _index2 = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("@effect/language-service/refactors/index"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// eslint-disable-next-line @typescript-eslint/consistent-type-imports

@@ -46,3 +45,3 @@ function init(modules) {

if (program) {
const effectDiagnostics = (0, _Function.pipe)(AST.getSourceFile(fileName), T.flatMap(sourceFile => (0, _Function.pipe)(Object.values(_index.default).map(applyConfiguredDiagnosticCategory).filter(_ => _.category !== "none"), T.forEachPar(diagnostic => (0, _Function.pipe)(diagnostic.apply(sourceFile), T.map(Ch.map(_ => ({
const effectDiagnostics = (0, _Function.pipe)(AST.getSourceFile(program)(fileName), sourceFile => (0, _Function.pipe)(Object.values(_index.default).map(applyConfiguredDiagnosticCategory).filter(_ => _.category !== "none"), _ => _.map(diagnostic => (0, _Function.pipe)(diagnostic.apply(modules.typescript, program)(sourceFile), Ch.map(_ => ({
file: sourceFile,

@@ -55,3 +54,3 @@ start: _.node.pos,

source: "effect"
}))))))), T.map(Ch.flatten), T.map(e => Array.from(e)), T.provideService(AST.TypeScriptProgram)(program), T.provideService(AST.TypeScriptApi)(modules.typescript), T.unsafeRunSync);
})), _ => Array.from(_)))), _ => _.flat());
return suggestionDiagnostics.concat(effectDiagnostics);

@@ -67,3 +66,3 @@ }

const textRange = AST.toTextRange(positionOrRange);
const effectRefactors = (0, _Function.pipe)(AST.getSourceFile(fileName), T.flatMap(sourceFile => (0, _Function.pipe)(Object.values(_index2.default).map(refactor => (0, _Function.pipe)(refactor.apply(sourceFile, textRange), T.map(O.map(_ => ({
const effectRefactors = (0, _Function.pipe)(AST.getSourceFile(program)(fileName), sourceFile => (0, _Function.pipe)(Object.values(_index2.default).map(refactor => (0, _Function.pipe)(refactor.apply(modules.typescript, program)(sourceFile, textRange), O.map(_ => ({
name: refactor.name,

@@ -75,3 +74,3 @@ description: refactor.description,

}]
}))))), T.collectAllWith(_Function.identity))), T.map(v => Array.from(v)), T.provideService(AST.TypeScriptProgram)(program), T.provideService(AST.TypeScriptApi)(modules.typescript), T.unsafeRunSync);
})))), _ => _.reduce((arr, maybeRefactor) => arr.concat(O.isSome(maybeRefactor) ? [maybeRefactor.value] : []), [])));
info.project.projectService.logger.info("[@effect/language-service] possible refactors are " + JSON.stringify(effectRefactors));

@@ -87,22 +86,20 @@ return applicableRefactors.concat(effectRefactors);

if (refactor.name === refactorName) {
return (0, _Function.pipe)(T.gen(function* ($) {
const sourceFile = yield* $(AST.getSourceFile(fileName));
const textRange = AST.toTextRange(positionOrRange);
const possibleRefactor = yield* $(refactor.apply(sourceFile, textRange));
if (O.isNone(possibleRefactor)) {
info.project.projectService.logger.info("[@effect/language-service] requested refactor " + refactorName + " is not applicable");
return {
edits: []
};
}
const formatContext = ts.formatting.getFormatContext(formatOptions, info.languageServiceHost);
const edits = ts.textChanges.ChangeTracker.with({
formatContext,
host: info.languageServiceHost,
preferences: preferences || {}
}, changeTracker => (0, _Function.pipe)(possibleRefactor.value.apply, T.provideService(AST.ChangeTrackerApi)(changeTracker), T.provideService(AST.TypeScriptApi)(modules.typescript), T.provideService(AST.TypeScriptProgram)(program), T.unsafeRunSync));
const sourceFile = AST.getSourceFile(program)(fileName);
const textRange = AST.toTextRange(positionOrRange);
const possibleRefactor = refactor.apply(modules.typescript, program)(sourceFile, textRange);
if (O.isNone(possibleRefactor)) {
info.project.projectService.logger.info("[@effect/language-service] requested refactor " + refactorName + " is not applicable");
return {
edits
edits: []
};
}), T.provideService(AST.TypeScriptApi)(modules.typescript), T.provideService(AST.TypeScriptProgram)(program), T.unsafeRunSync);
}
const formatContext = ts.formatting.getFormatContext(formatOptions, info.languageServiceHost);
const edits = ts.textChanges.ChangeTracker.with({
formatContext,
host: info.languageServiceHost,
preferences: preferences || {}
}, changeTracker => possibleRefactor.value.apply(changeTracker));
return {
edits
};
}

@@ -109,0 +106,0 @@ }

{
"name": "@effect/language-service",
"version": "0.0.11",
"version": "0.0.12",
"license": "MIT",

@@ -10,4 +10,2 @@ "repository": {

"dependencies": {
"@effect/io": "~0.0.32",
"@effect/printer": "~0.1.11",
"@fp-ts/core": "~0.0.9",

@@ -14,0 +12,0 @@ "@fp-ts/data": "~0.0.22"

@@ -7,9 +7,7 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var _utils = /*#__PURE__*/require("@effect/language-service/utils");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -20,16 +18,12 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Rewrite using pipe",
apply: (sourceFile, textRange) => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
return (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.reverse, Ch.fromIterable, Ch.filter(AST.isNodeInRange(textRange)), Ch.filter((0, _utils.isPipeableCallExpression)(ts)), Ch.head, O.map(node => ({
description: `Rewrite ${AST.getHumanReadableName(sourceFile, node.expression)} to pipe`,
apply: T.gen(function* ($) {
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
const args = (0, _utils.asPipeArguments)(ts)(node);
const newNode = ts.factory.createCallExpression(ts.factory.createIdentifier("pipe"), undefined, Array.from(args));
changeTracker.replaceNode(sourceFile, node, newNode);
})
})));
})
apply: ts => (sourceFile, textRange) => (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.reverse, Ch.fromIterable, Ch.filter(AST.isNodeInRange(textRange)), Ch.filter(AST.isPipeableCallExpression(ts)), Ch.head, O.map(node => ({
description: `Rewrite ${AST.getHumanReadableName(sourceFile, node.expression)} to pipe`,
apply: changeTracker => {
const args = AST.asPipeArguments(ts)(node);
const newNode = ts.factory.createCallExpression(ts.factory.createIdentifier("pipe"), undefined, Array.from(args));
changeTracker.replaceNode(sourceFile, node, newNode);
}
})))
});
exports.default = _default;
//# sourceMappingURL=addPipe.js.map

@@ -7,9 +7,7 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var _utils = /*#__PURE__*/require("@effect/language-service/utils");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -20,16 +18,12 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Convert to Effect.gen",
apply: (sourceFile, textRange) => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
return (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isFunctionDeclaration), Ch.filter(node => !!node.body), Ch.filter(node => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)), Ch.head, O.map(node => ({
description: "Rewrite to Effect.gen",
apply: T.gen(function* ($) {
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
const effectName = (0, _utils.getEffectModuleIdentifier)(ts)(sourceFile);
const newDeclaration = (0, _utils.transformAsyncAwaitToEffectGen)(ts)(node, effectName, expression => ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(effectName), "promise"), undefined, [expression]));
changeTracker.replaceNode(sourceFile, node, newDeclaration);
})
})));
})
apply: ts => (sourceFile, textRange) => (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isFunctionDeclaration), Ch.filter(node => !!node.body), Ch.filter(node => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)), Ch.head, O.map(node => ({
description: "Rewrite to Effect.gen",
apply: changeTracker => {
const effectName = AST.getEffectModuleIdentifier(ts)(sourceFile);
const newDeclaration = AST.transformAsyncAwaitToEffectGen(ts)(node, effectName, expression => ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(effectName), "promise"), undefined, [expression]));
changeTracker.replaceNode(sourceFile, node, newDeclaration);
}
})))
});
exports.default = _default;
//# sourceMappingURL=asyncAwaitToGen.js.map

@@ -7,9 +7,7 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var _utils = /*#__PURE__*/require("@effect/language-service/utils");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -20,21 +18,17 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Convert to Effect.gen with failures",
apply: (sourceFile, textRange) => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
return (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isFunctionDeclaration), Ch.filter(node => !!node.body), Ch.filter(node => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)), Ch.head, O.map(node => ({
description: "Rewrite to Effect.gen with failures",
apply: T.gen(function* ($) {
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
const effectName = (0, _utils.getEffectModuleIdentifier)(ts)(sourceFile);
let errorCount = 0;
function createErrorADT() {
errorCount++;
return ts.factory.createObjectLiteralExpression([ts.factory.createPropertyAssignment("_tag", ts.factory.createAsExpression(ts.factory.createStringLiteral("Error" + errorCount), ts.factory.createTypeReferenceNode("const"))), ts.factory.createShorthandPropertyAssignment("error")]);
}
const newDeclaration = (0, _utils.transformAsyncAwaitToEffectGen)(ts)(node, effectName, expression => ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(effectName), "tryCatchPromise"), undefined, [ts.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, expression), ts.factory.createArrowFunction(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, "error")], undefined, undefined, createErrorADT())]));
changeTracker.replaceNode(sourceFile, node, newDeclaration);
})
})));
})
apply: ts => (sourceFile, textRange) => (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isFunctionDeclaration), Ch.filter(node => !!node.body), Ch.filter(node => !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Async)), Ch.head, O.map(node => ({
description: "Rewrite to Effect.gen with failures",
apply: changeTracker => {
const effectName = AST.getEffectModuleIdentifier(ts)(sourceFile);
let errorCount = 0;
function createErrorADT() {
errorCount++;
return ts.factory.createObjectLiteralExpression([ts.factory.createPropertyAssignment("_tag", ts.factory.createAsExpression(ts.factory.createStringLiteral("Error" + errorCount), ts.factory.createTypeReferenceNode("const"))), ts.factory.createShorthandPropertyAssignment("error")]);
}
const newDeclaration = AST.transformAsyncAwaitToEffectGen(ts)(node, effectName, expression => ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(effectName), "tryCatchPromise"), undefined, [ts.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, expression), ts.factory.createArrowFunction(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, "error")], undefined, undefined, createErrorADT())]));
changeTracker.replaceNode(sourceFile, node, newDeclaration);
}
})))
});
exports.default = _default;
//# sourceMappingURL=asyncAwaitToGenTryPromise.js.map

@@ -1,3 +0,3 @@

import type * as T from "@effect/io/Effect";
import type * as O from "@fp-ts/data/Option";
import type * as AST from "@effect/language-service/utils/AST";
import type * as O from "@effect/language-service/utils/Option";
import type ts from "typescript/lib/tsserverlibrary";

@@ -7,8 +7,9 @@ export interface RefactorDefinition {

description: string;
apply: <E>(sourceFile: ts.SourceFile, textRange: ts.TextRange) => T.Effect<typeof ts | ts.Program, E, O.Option<{
description: string;
apply: T.Effect<typeof ts | ts.Program | ts.textChanges.ChangeTracker, E, void>;
}>>;
apply: (ts: AST.TypeScriptApi, program: ts.Program) => (sourceFile: ts.SourceFile, textRange: ts.TextRange) => O.Option<ApplicableRefactorDefinition>;
}
export interface ApplicableRefactorDefinition {
description: string;
apply: (changeTracker: ts.textChanges.ChangeTracker) => void;
}
export declare function createRefactor(definition: RefactorDefinition): RefactorDefinition;
//# sourceMappingURL=definition.d.ts.map

@@ -7,8 +7,7 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -19,36 +18,32 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Convert to arrow",
apply: (sourceFile, textRange) => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
return (0, _Function.pipe)((0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isFunctionDeclaration)), Ch.concat((0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isMethodDeclaration))), Ch.filter(node => !!node.body), Ch.filter(node => !!node.name && AST.isNodeInRange(textRange)(node.name)), Ch.head, O.map(node => ({
description: "Convert to arrow",
apply: T.gen(function* ($) {
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
const body = node.body;
let newBody = ts.factory.createBlock(body.statements);
if (body.statements.length === 1) {
const statement = body.statements[0];
if (statement && ts.isReturnStatement(statement) && statement.expression) {
newBody = statement.expression;
}
apply: ts => (sourceFile, textRange) => (0, _Function.pipe)((0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isFunctionDeclaration)), Ch.concat((0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isMethodDeclaration))), Ch.filter(node => !!node.body), Ch.filter(node => !!node.name && AST.isNodeInRange(textRange)(node.name)), Ch.head, O.map(node => ({
description: "Convert to arrow",
apply: changeTracker => {
const body = node.body;
let newBody = ts.factory.createBlock(body.statements);
if (body.statements.length === 1) {
const statement = body.statements[0];
if (statement && ts.isReturnStatement(statement) && statement.expression) {
newBody = statement.expression;
}
let arrowFlags = ts.getCombinedModifierFlags(node);
arrowFlags &= ~ts.ModifierFlags.Export;
arrowFlags &= ~ts.ModifierFlags.Default;
const arrowModifiers = ts.factory.createModifiersFromModifierFlags(arrowFlags);
const arrowFunction = ts.factory.createArrowFunction(arrowModifiers, node.typeParameters, node.parameters, undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), newBody);
let constFlags = ts.getCombinedModifierFlags(node);
constFlags &= ~arrowFlags;
const constModifiers = ts.factory.createModifiersFromModifierFlags(constFlags);
let newDeclaration = node;
if (ts.isMethodDeclaration(node)) {
newDeclaration = ts.factory.createPropertyDeclaration(constModifiers, node.name, undefined, undefined, arrowFunction);
} else if (ts.isFunctionDeclaration(node)) {
newDeclaration = ts.factory.createVariableStatement(constModifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(node.name, undefined, undefined, arrowFunction)], ts.NodeFlags.Const));
}
changeTracker.replaceNode(sourceFile, node, newDeclaration);
})
})));
})
}
let arrowFlags = ts.getCombinedModifierFlags(node);
arrowFlags &= ~ts.ModifierFlags.Export;
arrowFlags &= ~ts.ModifierFlags.Default;
const arrowModifiers = ts.factory.createModifiersFromModifierFlags(arrowFlags);
const arrowFunction = ts.factory.createArrowFunction(arrowModifiers, node.typeParameters, node.parameters, undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), newBody);
let constFlags = ts.getCombinedModifierFlags(node);
constFlags &= ~arrowFlags;
const constModifiers = ts.factory.createModifiersFromModifierFlags(constFlags);
let newDeclaration = node;
if (ts.isMethodDeclaration(node)) {
newDeclaration = ts.factory.createPropertyDeclaration(constModifiers, node.name, undefined, undefined, arrowFunction);
} else if (ts.isFunctionDeclaration(node)) {
newDeclaration = ts.factory.createVariableStatement(constModifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(node.name, undefined, undefined, arrowFunction)], ts.NodeFlags.Const));
}
changeTracker.replaceNode(sourceFile, node, newDeclaration);
}
})))
});
exports.default = _default;
//# sourceMappingURL=functionToArrow.js.map

@@ -7,10 +7,8 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _noSyncWithConstant = /*#__PURE__*/require("@effect/language-service/diagnostics/noSyncWithConstant");
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var _utils = /*#__PURE__*/require("@effect/language-service/utils");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -21,5 +19,4 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Rewrite using pipe",
apply: (sourceFile, textRange) => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
const effectIdentifier = (0, _utils.getEffectModuleIdentifier)(ts)(sourceFile);
apply: ts => (sourceFile, textRange) => {
const effectIdentifier = AST.getEffectModuleIdentifier(ts)(sourceFile);
const nodes = (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.reverse, Ch.fromIterable, Ch.filter(AST.isNodeInRange(textRange)));

@@ -30,10 +27,9 @@ for (const methodName of Object.keys(_noSyncWithConstant.noSyncWithConstantMethodsMap)) {

description: `Rewrite ${methodName} to ${suggestedMethodName}`,
apply: T.gen(function* ($) {
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
apply: changeTracker => {
const arg = node.arguments[0];
if (ts.isArrowFunction(arg) && (0, _utils.isLiteralConstantValue)(ts)(arg.body)) {
if (ts.isArrowFunction(arg) && AST.isLiteralConstantValue(ts)(arg.body)) {
const newNode = ts.factory.updateCallExpression(node, ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(effectIdentifier), suggestedMethodName), node.typeArguments, ts.factory.createNodeArray([arg.body]));
changeTracker.replaceNode(sourceFile, node, newNode);
}
})
}
})));

@@ -43,5 +39,5 @@ if (O.isSome(refactor)) return refactor;

return O.none;
})
}
});
exports.default = _default;
//# sourceMappingURL=noSyncWithConstant.js.map

@@ -7,9 +7,7 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var _utils = /*#__PURE__*/require("@effect/language-service/utils");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -20,16 +18,12 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Remove arrow",
apply: (sourceFile, textRange) => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
return (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter((0, _utils.isCurryArrow)(ts)), Ch.head, O.map(node => ({
description: `Remove arrow ${AST.getHumanReadableName(sourceFile, node.body)}`,
apply: T.gen(function* ($) {
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
if (!ts.isCallExpression(node.body)) return;
const newNode = node.body.expression;
changeTracker.replaceNode(sourceFile, node, newNode);
})
})));
})
apply: ts => (sourceFile, textRange) => (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(AST.isCurryArrow(ts)), Ch.head, O.map(node => ({
description: `Remove arrow ${AST.getHumanReadableName(sourceFile, node.body)}`,
apply: changeTracker => {
if (!ts.isCallExpression(node.body)) return;
const newNode = node.body.expression;
changeTracker.replaceNode(sourceFile, node, newNode);
}
})))
});
exports.default = _default;
//# sourceMappingURL=removeCurryArrow.js.map

@@ -7,9 +7,7 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var _utils = /*#__PURE__*/require("@effect/language-service/utils");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -20,15 +18,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Remove pipe call",
apply: (sourceFile, textRange) => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
return (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter((0, _utils.isPipeCall)(ts)), Ch.filter(node => AST.isNodeInRange(textRange)(node.expression)), Ch.filter(node => node.arguments.length > 1), Ch.head, O.map(node => ({
description: "Remove pipe call",
apply: T.gen(function* ($) {
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
const newNode = node.arguments.slice(1).reduce((inner, exp) => ts.factory.createCallExpression(exp, undefined, [inner]), node.arguments[0]);
changeTracker.replaceNode(sourceFile, node, newNode);
})
})));
})
apply: ts => (sourceFile, textRange) => (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(AST.isPipeCall(ts)), Ch.filter(node => AST.isNodeInRange(textRange)(node.expression)), Ch.filter(node => node.arguments.length > 1), Ch.head, O.map(node => ({
description: "Remove pipe call",
apply: changeTracker => {
const newNode = node.arguments.slice(1).reduce((inner, exp) => ts.factory.createCallExpression(exp, undefined, [inner]), node.arguments[0]);
changeTracker.replaceNode(sourceFile, node, newNode);
}
})))
});
exports.default = _default;
//# sourceMappingURL=removePipe.js.map

@@ -7,9 +7,7 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var _utils = /*#__PURE__*/require("@effect/language-service/utils");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -20,4 +18,3 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Toggle return type annotation",
apply: (sourceFile, textRange) => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
apply: (ts, program) => (sourceFile, textRange) => {
function isConvertibleDeclaration(node) {

@@ -36,8 +33,6 @@ switch (node.kind) {

description: "Toggle return type annotation",
apply: T.gen(function* ($) {
const program = yield* $(T.service(AST.TypeScriptProgram));
apply: changeTracker => {
const typeChecker = program.getTypeChecker();
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
if (node.type) {
(0, _utils.removeReturnTypeAnnotation)(ts, changeTracker)(sourceFile, node);
AST.removeReturnTypeAnnotation(ts, changeTracker)(sourceFile, node);
return;

@@ -50,8 +45,8 @@ }

const returnTypeNode = returnTypeNodes.length === 1 ? returnTypeNodes[0] : ts.factory.createUnionTypeNode(returnTypeNodes);
(0, _utils.addReturnTypeAnnotation)(ts, changeTracker)(sourceFile, node, returnTypeNode);
})
AST.addReturnTypeAnnotation(ts, changeTracker)(sourceFile, node, returnTypeNode);
}
})));
})
}
});
exports.default = _default;
//# sourceMappingURL=toggleReturnTypeAnnotation.js.map

@@ -7,8 +7,7 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Chunk"));
var _Function = /*#__PURE__*/require("@fp-ts/data/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/AST"));
var _Function = /*#__PURE__*/require("@effect/language-service/utils/Function");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
var Ch = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/ReadonlyArray"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -19,30 +18,25 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Toggle type annotation",
apply: (sourceFile, textRange) => T.gen(function* ($) {
const ts = yield* $(T.service(AST.TypeScriptApi));
return (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isVariableDeclaration), Ch.filter(node => AST.isNodeInRange(textRange)(node.name)), Ch.filter(node => !!node.initializer), Ch.head, O.map(node => ({
description: "Toggle type annotation",
apply: T.gen(function* ($) {
const program = yield* $(T.service(AST.TypeScriptProgram));
const typeChecker = program.getTypeChecker();
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
if (node.type) {
changeTracker.deleteRange(sourceFile, {
pos: node.name.end,
end: node.type.end
});
return;
}
const initializer = node.initializer;
const initializerType = typeChecker.getTypeAtLocation(initializer);
const initializerTypeNode = typeChecker.typeToTypeNode(initializerType, node, ts.NodeBuilderFlags.NoTruncation);
if (initializerTypeNode) {
changeTracker.insertNodeAt(sourceFile, node.name.end, initializerTypeNode, {
prefix: ": "
});
}
})
})));
})
apply: (ts, program) => (sourceFile, textRange) => (0, _Function.pipe)(AST.getNodesContainingRange(ts)(sourceFile, textRange), Ch.filter(ts.isVariableDeclaration), Ch.filter(node => AST.isNodeInRange(textRange)(node.name)), Ch.filter(node => !!node.initializer), Ch.head, O.map(node => ({
description: "Toggle type annotation",
apply: changeTracker => {
const typeChecker = program.getTypeChecker();
if (node.type) {
changeTracker.deleteRange(sourceFile, {
pos: node.name.end,
end: node.type.end
});
return;
}
const initializer = node.initializer;
const initializerType = typeChecker.getTypeAtLocation(initializer);
const initializerTypeNode = typeChecker.typeToTypeNode(initializerType, node, ts.NodeBuilderFlags.NoTruncation);
if (initializerTypeNode) {
changeTracker.insertNodeAt(sourceFile, node.name.end, initializerTypeNode, {
prefix: ": "
});
}
}
})))
});
exports.default = _default;
//# sourceMappingURL=toggleTypeAnnotation.js.map

@@ -7,6 +7,4 @@ "use strict";

exports.default = void 0;
var T = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var AST = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/ast"));
var _definition = /*#__PURE__*/require("@effect/language-service/refactors/definition");
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/data/Option"));
var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/language-service/utils/Option"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -17,15 +15,14 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

description: "Wrap with pipe",
apply: (sourceFile, textRange) => T.sync(() => {
apply: () => (sourceFile, textRange) => {
if (textRange.end - textRange.pos === 0) return O.none;
return O.some({
description: `Wrap with pipe(...)`,
apply: T.gen(function* ($) {
const changeTracker = yield* $(T.service(AST.ChangeTrackerApi));
apply: changeTracker => {
changeTracker.insertText(sourceFile, textRange.pos, "pipe(");
changeTracker.insertText(sourceFile, textRange.end, ")");
})
}
});
})
}
});
exports.default = _default;
//# sourceMappingURL=wrapWithPipe.js.map

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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