@effect/language-service 0.51.1 → 0.52.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/cli.js +370 -219
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +312 -195
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +312 -195
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +312 -195
- package/transform.js.map +1 -1
package/cli.js
CHANGED
|
@@ -26990,6 +26990,7 @@ var getZshCompletions2 = (self, state = {
|
|
|
26990
26990
|
|
|
26991
26991
|
// node_modules/.pnpm/@effect+cli@0.71.0_@effect+platform@0.92.1_@effect+printer-ansi@0.46.0_@effect+printer@0.46.0_effect@3.18.4/node_modules/@effect/cli/dist/esm/Options.js
|
|
26992
26992
|
var all7 = all6;
|
|
26993
|
+
var boolean5 = boolean4;
|
|
26993
26994
|
var choice3 = choice2;
|
|
26994
26995
|
var directory2 = directory;
|
|
26995
26996
|
var file3 = file2;
|
|
@@ -30956,7 +30957,8 @@ var getModuleFilePath = fn("getModuleFilePath")(
|
|
|
30956
30957
|
var getTypeScriptApisUtils = fn("getTypeScriptApisFile")(
|
|
30957
30958
|
function* (dirPath4) {
|
|
30958
30959
|
const filePath = yield* getModuleFilePath(dirPath4, "typescript");
|
|
30959
|
-
const
|
|
30960
|
+
const sourceText = yield* getSourceFileText(filePath);
|
|
30961
|
+
const sourceFile = yield* getUnpatchedSourceFile(filePath, sourceText);
|
|
30960
30962
|
const bodyWithoutBundlerComment = yield* omitBundlerSourceFileComment(
|
|
30961
30963
|
sourceFile.text.split("\n").map((line4) => ` ${line4}`).join("\n")
|
|
30962
30964
|
);
|
|
@@ -31069,27 +31071,31 @@ var applyTextChanges = fn("applyTextChanges")(
|
|
|
31069
31071
|
return newSourceText;
|
|
31070
31072
|
}
|
|
31071
31073
|
);
|
|
31072
|
-
var
|
|
31074
|
+
var getSourceFileText = fn("getSourceFileText")(function* (filePath) {
|
|
31073
31075
|
const fs = yield* FileSystem;
|
|
31074
|
-
|
|
31075
|
-
const sourceText = yield* fs.readFileString(filePath);
|
|
31076
|
-
const sourceFile = ts.createSourceFile(
|
|
31077
|
-
filePath,
|
|
31078
|
-
sourceText,
|
|
31079
|
-
ts.ScriptTarget.ES2022,
|
|
31080
|
-
true
|
|
31081
|
-
);
|
|
31082
|
-
const { revertChanges } = yield* extractAppliedEffectLspPatches(sourceFile);
|
|
31083
|
-
if (revertChanges.length === 0) return sourceFile;
|
|
31084
|
-
const newSourceText = yield* applyTextChanges(sourceText, revertChanges);
|
|
31085
|
-
const newSourceFile = ts.createSourceFile(
|
|
31086
|
-
filePath,
|
|
31087
|
-
newSourceText,
|
|
31088
|
-
ts.ScriptTarget.ES2022,
|
|
31089
|
-
true
|
|
31090
|
-
);
|
|
31091
|
-
return newSourceFile;
|
|
31076
|
+
return yield* fs.readFileString(filePath);
|
|
31092
31077
|
});
|
|
31078
|
+
var getUnpatchedSourceFile = fn("getUnpatchedSourceFile")(
|
|
31079
|
+
function* (filePath, sourceText) {
|
|
31080
|
+
const ts = yield* getTypeScript;
|
|
31081
|
+
const sourceFile = ts.createSourceFile(
|
|
31082
|
+
filePath,
|
|
31083
|
+
sourceText,
|
|
31084
|
+
ts.ScriptTarget.ES2022,
|
|
31085
|
+
true
|
|
31086
|
+
);
|
|
31087
|
+
const { revertChanges } = yield* extractAppliedEffectLspPatches(sourceFile);
|
|
31088
|
+
if (revertChanges.length === 0) return sourceFile;
|
|
31089
|
+
const newSourceText = yield* applyTextChanges(sourceText, revertChanges);
|
|
31090
|
+
const newSourceFile = ts.createSourceFile(
|
|
31091
|
+
filePath,
|
|
31092
|
+
newSourceText,
|
|
31093
|
+
ts.ScriptTarget.ES2022,
|
|
31094
|
+
true
|
|
31095
|
+
);
|
|
31096
|
+
return newSourceFile;
|
|
31097
|
+
}
|
|
31098
|
+
);
|
|
31093
31099
|
var omitBundlerSourceFileComment = fn("omitBundlerSourceFileComment")(
|
|
31094
31100
|
function* (originalSourceText) {
|
|
31095
31101
|
const ts = yield* getTypeScript;
|
|
@@ -31907,9 +31913,10 @@ var nanoLayer3 = (fa) => gen3(function* () {
|
|
|
31907
31913
|
const tsUtils = yield* service2(TypeScriptUtils);
|
|
31908
31914
|
const typeChecker = yield* service2(TypeCheckerApi);
|
|
31909
31915
|
const typeCheckerUtils = yield* service2(TypeCheckerUtils);
|
|
31916
|
+
const program = yield* service2(TypeScriptProgram);
|
|
31910
31917
|
return yield* pipe(
|
|
31911
31918
|
fa,
|
|
31912
|
-
provideService7(TypeParser, make64(ts, tsUtils, typeChecker, typeCheckerUtils))
|
|
31919
|
+
provideService7(TypeParser, make64(ts, tsUtils, typeChecker, typeCheckerUtils, program))
|
|
31913
31920
|
);
|
|
31914
31921
|
});
|
|
31915
31922
|
var TypeParserIssue = class _TypeParserIssue {
|
|
@@ -31919,7 +31926,92 @@ var TypeParserIssue = class _TypeParserIssue {
|
|
|
31919
31926
|
function typeParserIssue(_message, _type, _node) {
|
|
31920
31927
|
return TypeParserIssue.issue;
|
|
31921
31928
|
}
|
|
31922
|
-
function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
31929
|
+
function make64(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
31930
|
+
const getSourceFilePackageInfo = cachedBy(
|
|
31931
|
+
fn2("TypeParser.getSourceFilePackageInfo")(function* (sourceFile) {
|
|
31932
|
+
return tsUtils.resolveModuleWithPackageInfoFromSourceFile(program, sourceFile);
|
|
31933
|
+
}),
|
|
31934
|
+
`TypeParser.getSourceFilePackageInfo`,
|
|
31935
|
+
(sourceFile) => sourceFile
|
|
31936
|
+
);
|
|
31937
|
+
const getSourceFilesDeclaringSymbolModule = (packageName) => cachedBy(
|
|
31938
|
+
fn2("TypeParser.getSourceFilesDeclaringSymbolModule")(function* (symbol3) {
|
|
31939
|
+
const result = [];
|
|
31940
|
+
if (!symbol3.declarations) return yield* typeParserIssue("Symbol has no declarations", void 0, void 0);
|
|
31941
|
+
for (const sourceFile of symbol3.declarations) {
|
|
31942
|
+
if (!ts.isSourceFile(sourceFile)) continue;
|
|
31943
|
+
const packageInfo = yield* getSourceFilePackageInfo(sourceFile);
|
|
31944
|
+
if (!packageInfo || packageInfo.name.toLowerCase() !== packageName.toLowerCase()) continue;
|
|
31945
|
+
result.push(sourceFile);
|
|
31946
|
+
}
|
|
31947
|
+
if (result.length > 0) {
|
|
31948
|
+
return result;
|
|
31949
|
+
}
|
|
31950
|
+
return yield* typeParserIssue(`Symbol has no source file declarations`, void 0, void 0);
|
|
31951
|
+
}),
|
|
31952
|
+
`TypeParser.getSourceFilesDeclaringSymbolModule(${packageName})`,
|
|
31953
|
+
(symbol3) => symbol3
|
|
31954
|
+
);
|
|
31955
|
+
const isSymbolReferenceToPackageModule = (givenSymbol, packageName, checkSourceFile) => {
|
|
31956
|
+
let symbol3 = givenSymbol;
|
|
31957
|
+
while (symbol3.flags & ts.SymbolFlags.Alias) {
|
|
31958
|
+
symbol3 = typeChecker.getAliasedSymbol(symbol3);
|
|
31959
|
+
}
|
|
31960
|
+
return pipe(
|
|
31961
|
+
getSourceFilesDeclaringSymbolModule(packageName)(symbol3),
|
|
31962
|
+
flatMap18(
|
|
31963
|
+
(sourceFiles) => firstSuccessOf2(
|
|
31964
|
+
sourceFiles.map((_) => checkSourceFile(_))
|
|
31965
|
+
)
|
|
31966
|
+
)
|
|
31967
|
+
);
|
|
31968
|
+
};
|
|
31969
|
+
const isNodeReferenceToPackageModule = (givenNode, packageName, isCorrectSourceFile) => {
|
|
31970
|
+
const symbol3 = typeChecker.getSymbolAtLocation(givenNode);
|
|
31971
|
+
if (!symbol3) return typeParserIssue("Node has no symbol", void 0, givenNode);
|
|
31972
|
+
return isSymbolReferenceToPackageModule(symbol3, packageName, isCorrectSourceFile);
|
|
31973
|
+
};
|
|
31974
|
+
const getSourceFilesDeclaringSymbolExportedUnderPackageModule = (packageName, memberName) => cachedBy(
|
|
31975
|
+
fn2("TypeParser.getSourceFilesDeclaringSymbolUnderPackageExportedMember")(function* (symbol3) {
|
|
31976
|
+
const result = [];
|
|
31977
|
+
if (!symbol3.declarations) return yield* typeParserIssue("Symbol has no declarations", void 0, void 0);
|
|
31978
|
+
for (const declaration of symbol3.declarations) {
|
|
31979
|
+
const sourceFile = tsUtils.getSourceFileOfNode(declaration);
|
|
31980
|
+
if (!sourceFile) continue;
|
|
31981
|
+
const packageInfo = yield* getSourceFilePackageInfo(sourceFile);
|
|
31982
|
+
if (!packageInfo || packageInfo.name.toLowerCase() !== packageName.toLowerCase()) continue;
|
|
31983
|
+
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
|
31984
|
+
if (!moduleSymbol) continue;
|
|
31985
|
+
const memberSymbol = typeChecker.tryGetMemberInModuleExports(memberName, moduleSymbol);
|
|
31986
|
+
if (memberSymbol && memberSymbol === symbol3) result.push({ memberSymbol, moduleSymbol, sourceFile });
|
|
31987
|
+
}
|
|
31988
|
+
if (result.length > 0) {
|
|
31989
|
+
return result;
|
|
31990
|
+
}
|
|
31991
|
+
return yield* typeParserIssue(`Symbol has no declarations`, void 0, void 0);
|
|
31992
|
+
}),
|
|
31993
|
+
`TypeParser.getSourceFilesDeclaringSymbolUnderPackageExportedMember(${packageName}, ${memberName})`,
|
|
31994
|
+
(sym) => sym
|
|
31995
|
+
);
|
|
31996
|
+
const isSymbolExportOfPackageModule = (givenSymbol, packageName, memberName, checkSourceFile) => {
|
|
31997
|
+
let symbol3 = givenSymbol;
|
|
31998
|
+
while (symbol3.flags & ts.SymbolFlags.Alias) {
|
|
31999
|
+
symbol3 = typeChecker.getAliasedSymbol(symbol3);
|
|
32000
|
+
}
|
|
32001
|
+
return pipe(
|
|
32002
|
+
getSourceFilesDeclaringSymbolExportedUnderPackageModule(packageName, memberName)(symbol3),
|
|
32003
|
+
flatMap18(
|
|
32004
|
+
(sourceFiles) => firstSuccessOf2(
|
|
32005
|
+
sourceFiles.map((_) => checkSourceFile(_.sourceFile, _.moduleSymbol, _.memberSymbol))
|
|
32006
|
+
)
|
|
32007
|
+
)
|
|
32008
|
+
);
|
|
32009
|
+
};
|
|
32010
|
+
const isNodeReferenceToExportOfPackageModule = (givenNode, packageName, isCorrectSourceFile, memberName) => {
|
|
32011
|
+
const symbol3 = typeChecker.getSymbolAtLocation(givenNode);
|
|
32012
|
+
if (!symbol3) return typeParserIssue("Node has no symbol", void 0, givenNode);
|
|
32013
|
+
return isSymbolExportOfPackageModule(symbol3, packageName, memberName, isCorrectSourceFile);
|
|
32014
|
+
};
|
|
31923
32015
|
function covariantTypeArgument(type2) {
|
|
31924
32016
|
const signatures = typeChecker.getSignaturesOfType(type2, ts.SignatureKind.Call);
|
|
31925
32017
|
if (signatures.length !== 1) {
|
|
@@ -32025,6 +32117,26 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32025
32117
|
"TypeParser.strictEffectType",
|
|
32026
32118
|
(type2) => type2
|
|
32027
32119
|
);
|
|
32120
|
+
const isEffectTypeSourceFile = cachedBy(
|
|
32121
|
+
fn2("TypeParser.isEffectTypeSourceFile")(function* (sourceFile) {
|
|
32122
|
+
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
|
32123
|
+
if (!moduleSymbol) return yield* typeParserIssue("Node has no symbol", void 0, sourceFile);
|
|
32124
|
+
const effectTypeSymbol = typeChecker.tryGetMemberInModuleExports("Effect", moduleSymbol);
|
|
32125
|
+
if (!effectTypeSymbol) return yield* typeParserIssue("Effect type not found", void 0, sourceFile);
|
|
32126
|
+
const type2 = typeChecker.getDeclaredTypeOfSymbol(effectTypeSymbol);
|
|
32127
|
+
yield* effectType(type2, sourceFile);
|
|
32128
|
+
return sourceFile;
|
|
32129
|
+
}),
|
|
32130
|
+
"TypeParser.isEffectTypeSourceFile",
|
|
32131
|
+
(sourceFile) => sourceFile
|
|
32132
|
+
);
|
|
32133
|
+
const isNodeReferenceToEffectModuleApi = (memberName) => cachedBy(
|
|
32134
|
+
fn2("TypeParser.isNodeReferenceToEffectModuleApi")(function* (node) {
|
|
32135
|
+
return yield* isNodeReferenceToExportOfPackageModule(node, "effect", isEffectTypeSourceFile, memberName);
|
|
32136
|
+
}),
|
|
32137
|
+
`TypeParser.isNodeReferenceToEffectModuleApi(${memberName})`,
|
|
32138
|
+
(node) => node
|
|
32139
|
+
);
|
|
32028
32140
|
const layerType = cachedBy(
|
|
32029
32141
|
fn2("TypeParser.layerType")(function* (type2, atLocation) {
|
|
32030
32142
|
yield* pipeableType(type2, atLocation);
|
|
@@ -32081,36 +32193,6 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32081
32193
|
"TypeParser.effectSubtype",
|
|
32082
32194
|
(type2) => type2
|
|
32083
32195
|
);
|
|
32084
|
-
const importedSchemaModule = cachedBy(
|
|
32085
|
-
fn2("TypeParser.importedSchemaModule")(function* (node) {
|
|
32086
|
-
if (!ts.isIdentifier(node)) {
|
|
32087
|
-
return yield* typeParserIssue("Node is not an expression", void 0, node);
|
|
32088
|
-
}
|
|
32089
|
-
const type2 = typeChecker.getTypeAtLocation(node);
|
|
32090
|
-
const propertySymbol = typeChecker.getPropertyOfType(type2, "Class");
|
|
32091
|
-
if (!propertySymbol) {
|
|
32092
|
-
return yield* typeParserIssue("Type has no 'Class' property", type2, node);
|
|
32093
|
-
}
|
|
32094
|
-
const sourceFile = tsUtils.getSourceFileOfNode(node);
|
|
32095
|
-
if (!sourceFile) {
|
|
32096
|
-
return yield* typeParserIssue("Node is not in a source file", void 0, node);
|
|
32097
|
-
}
|
|
32098
|
-
const schemaIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
32099
|
-
sourceFile,
|
|
32100
|
-
"effect",
|
|
32101
|
-
"Schema"
|
|
32102
|
-
);
|
|
32103
|
-
if (!schemaIdentifier) {
|
|
32104
|
-
return yield* typeParserIssue("Schema module not found", void 0, node);
|
|
32105
|
-
}
|
|
32106
|
-
if (ts.idText(node) !== schemaIdentifier) {
|
|
32107
|
-
return yield* typeParserIssue("Node is not a schema module reference", void 0, node);
|
|
32108
|
-
}
|
|
32109
|
-
return node;
|
|
32110
|
-
}),
|
|
32111
|
-
"TypeParser.importedSchemaModule",
|
|
32112
|
-
(node) => node
|
|
32113
|
-
);
|
|
32114
32196
|
const importedContextModule = cachedBy(
|
|
32115
32197
|
fn2("TypeParser.importedContextModule")(function* (node) {
|
|
32116
32198
|
const type2 = typeChecker.getTypeAtLocation(node);
|
|
@@ -32141,22 +32223,9 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32141
32223
|
"TypeParser.importedContextModule",
|
|
32142
32224
|
(node) => node
|
|
32143
32225
|
);
|
|
32144
|
-
const importedEffectModule =
|
|
32145
|
-
|
|
32146
|
-
|
|
32147
|
-
const propertySymbol = typeChecker.getPropertyOfType(type2, "never");
|
|
32148
|
-
if (!propertySymbol) {
|
|
32149
|
-
return yield* typeParserIssue("Type has no 'never' property", type2, node);
|
|
32150
|
-
}
|
|
32151
|
-
if (!ts.isExpression(node)) {
|
|
32152
|
-
return yield* typeParserIssue("Node is not an expression", type2, node);
|
|
32153
|
-
}
|
|
32154
|
-
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, node);
|
|
32155
|
-
yield* effectType(propertyType, node);
|
|
32156
|
-
return node;
|
|
32157
|
-
}),
|
|
32158
|
-
"TypeParser.importedEffectModule",
|
|
32159
|
-
(node) => node
|
|
32226
|
+
const importedEffectModule = (node) => pipe(
|
|
32227
|
+
isNodeReferenceToPackageModule(node, "effect", isEffectTypeSourceFile),
|
|
32228
|
+
map34(() => node)
|
|
32160
32229
|
);
|
|
32161
32230
|
const importedDataModule = cachedBy(
|
|
32162
32231
|
fn2("TypeParser.importedDataModule")(function* (node) {
|
|
@@ -32207,14 +32276,11 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32207
32276
|
return typeParserIssue("Node is not a property access expression", void 0, node);
|
|
32208
32277
|
}
|
|
32209
32278
|
const propertyAccess = node.expression;
|
|
32210
|
-
if (!(ts.isIdentifier(propertyAccess.name) && ts.idText(propertyAccess.name) === "gen")) {
|
|
32211
|
-
return typeParserIssue("Call expression name is not 'gen'", void 0, node);
|
|
32212
|
-
}
|
|
32213
32279
|
return pipe(
|
|
32214
|
-
|
|
32215
|
-
map34((
|
|
32280
|
+
isNodeReferenceToEffectModuleApi("gen")(propertyAccess),
|
|
32281
|
+
map34(() => ({
|
|
32216
32282
|
node,
|
|
32217
|
-
effectModule,
|
|
32283
|
+
effectModule: propertyAccess.expression,
|
|
32218
32284
|
generatorFunction,
|
|
32219
32285
|
body: generatorFunction.body
|
|
32220
32286
|
}))
|
|
@@ -32250,18 +32316,11 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32250
32316
|
);
|
|
32251
32317
|
}
|
|
32252
32318
|
const propertyAccess = node.expression;
|
|
32253
|
-
if (!(ts.isIdentifier(propertyAccess.name) && ts.idText(propertyAccess.name) === "fnUntraced")) {
|
|
32254
|
-
return typeParserIssue(
|
|
32255
|
-
"Call expression name is not 'fnUntraced'",
|
|
32256
|
-
void 0,
|
|
32257
|
-
node
|
|
32258
|
-
);
|
|
32259
|
-
}
|
|
32260
32319
|
return pipe(
|
|
32261
|
-
|
|
32262
|
-
map34((
|
|
32320
|
+
isNodeReferenceToEffectModuleApi("fnUntraced")(propertyAccess),
|
|
32321
|
+
map34(() => ({
|
|
32263
32322
|
node,
|
|
32264
|
-
effectModule,
|
|
32323
|
+
effectModule: propertyAccess.expression,
|
|
32265
32324
|
generatorFunction,
|
|
32266
32325
|
body: generatorFunction.body
|
|
32267
32326
|
}))
|
|
@@ -32302,19 +32361,12 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32302
32361
|
);
|
|
32303
32362
|
}
|
|
32304
32363
|
const propertyAccess = expressionToTest;
|
|
32305
|
-
if (!(ts.isIdentifier(propertyAccess.name) && ts.idText(propertyAccess.name) === "fn")) {
|
|
32306
|
-
return typeParserIssue(
|
|
32307
|
-
"Call expression name is not 'fn'",
|
|
32308
|
-
void 0,
|
|
32309
|
-
node
|
|
32310
|
-
);
|
|
32311
|
-
}
|
|
32312
32364
|
return pipe(
|
|
32313
|
-
|
|
32314
|
-
map34((
|
|
32365
|
+
isNodeReferenceToEffectModuleApi("fn")(propertyAccess),
|
|
32366
|
+
map34(() => ({
|
|
32315
32367
|
node,
|
|
32316
32368
|
generatorFunction,
|
|
32317
|
-
effectModule,
|
|
32369
|
+
effectModule: propertyAccess.expression,
|
|
32318
32370
|
body: generatorFunction.body
|
|
32319
32371
|
}))
|
|
32320
32372
|
);
|
|
@@ -32416,6 +32468,26 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32416
32468
|
"TypeParser.effectSchemaType",
|
|
32417
32469
|
(type2) => type2
|
|
32418
32470
|
);
|
|
32471
|
+
const isEffectSchemaTypeSourceFile = cachedBy(
|
|
32472
|
+
fn2("TypeParser.isEffectSchemaTypeSourceFile")(function* (sourceFile) {
|
|
32473
|
+
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
|
32474
|
+
if (!moduleSymbol) return yield* typeParserIssue("Node has no symbol", void 0, sourceFile);
|
|
32475
|
+
const typeSymbol = typeChecker.tryGetMemberInModuleExports("Schema", moduleSymbol);
|
|
32476
|
+
if (!typeSymbol) return yield* typeParserIssue("Schema type not found", void 0, sourceFile);
|
|
32477
|
+
const type2 = typeChecker.getDeclaredTypeOfSymbol(typeSymbol);
|
|
32478
|
+
yield* effectSchemaType(type2, sourceFile);
|
|
32479
|
+
return sourceFile;
|
|
32480
|
+
}),
|
|
32481
|
+
"TypeParser.isEffectSchemaTypeSourceFile",
|
|
32482
|
+
(sourceFile) => sourceFile
|
|
32483
|
+
);
|
|
32484
|
+
const isNodeReferenceToEffectSchemaModuleApi = (memberName) => cachedBy(
|
|
32485
|
+
fn2("TypeParser.isNodeReferenceToEffectSchemaModuleApi")(function* (node) {
|
|
32486
|
+
return yield* isNodeReferenceToExportOfPackageModule(node, "effect", isEffectSchemaTypeSourceFile, memberName);
|
|
32487
|
+
}),
|
|
32488
|
+
`TypeParser.isNodeReferenceToEffectSchemaModuleApi(${memberName})`,
|
|
32489
|
+
(node) => node
|
|
32490
|
+
);
|
|
32419
32491
|
const contextTagVarianceStruct = (type2, atLocation) => map34(
|
|
32420
32492
|
all9(
|
|
32421
32493
|
varianceStructInvariantType(type2, atLocation, "_Identifier"),
|
|
@@ -32542,22 +32614,15 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32542
32614
|
if (ts.isCallExpression(expression)) {
|
|
32543
32615
|
const schemaCall = expression.expression;
|
|
32544
32616
|
if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
|
|
32545
|
-
const
|
|
32546
|
-
|
|
32547
|
-
|
|
32548
|
-
|
|
32549
|
-
|
|
32550
|
-
|
|
32551
|
-
|
|
32552
|
-
|
|
32553
|
-
|
|
32554
|
-
if (isSome2(parsedSchemaModule)) {
|
|
32555
|
-
return {
|
|
32556
|
-
className: atLocation.name,
|
|
32557
|
-
selfTypeNode,
|
|
32558
|
-
Schema: parsedSchemaModule.value
|
|
32559
|
-
};
|
|
32560
|
-
}
|
|
32617
|
+
const isEffectSchemaModuleApi = yield* pipe(
|
|
32618
|
+
isNodeReferenceToEffectSchemaModuleApi("Class")(schemaCall.expression),
|
|
32619
|
+
option4
|
|
32620
|
+
);
|
|
32621
|
+
if (isSome2(isEffectSchemaModuleApi)) {
|
|
32622
|
+
return {
|
|
32623
|
+
className: atLocation.name,
|
|
32624
|
+
selfTypeNode: schemaCall.typeArguments[0]
|
|
32625
|
+
};
|
|
32561
32626
|
}
|
|
32562
32627
|
}
|
|
32563
32628
|
}
|
|
@@ -32586,23 +32651,17 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32586
32651
|
const schemaTaggedClassTCall = expression.expression;
|
|
32587
32652
|
if (ts.isCallExpression(schemaTaggedClassTCall) && schemaTaggedClassTCall.typeArguments && schemaTaggedClassTCall.typeArguments.length > 0) {
|
|
32588
32653
|
const selfTypeNode = schemaTaggedClassTCall.typeArguments[0];
|
|
32589
|
-
const
|
|
32590
|
-
|
|
32591
|
-
|
|
32592
|
-
|
|
32593
|
-
|
|
32594
|
-
|
|
32595
|
-
|
|
32596
|
-
|
|
32597
|
-
|
|
32598
|
-
|
|
32599
|
-
|
|
32600
|
-
selfTypeNode,
|
|
32601
|
-
keyStringLiteral: schemaTaggedClassTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedClassTCall.arguments[0]) ? schemaTaggedClassTCall.arguments[0] : void 0,
|
|
32602
|
-
tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
|
|
32603
|
-
Schema: parsedSchemaModule.value
|
|
32604
|
-
};
|
|
32605
|
-
}
|
|
32654
|
+
const isEffectSchemaModuleApi = yield* pipe(
|
|
32655
|
+
isNodeReferenceToEffectSchemaModuleApi("TaggedClass")(schemaTaggedClassTCall.expression),
|
|
32656
|
+
option4
|
|
32657
|
+
);
|
|
32658
|
+
if (isSome2(isEffectSchemaModuleApi)) {
|
|
32659
|
+
return {
|
|
32660
|
+
className: atLocation.name,
|
|
32661
|
+
selfTypeNode,
|
|
32662
|
+
keyStringLiteral: schemaTaggedClassTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedClassTCall.arguments[0]) ? schemaTaggedClassTCall.arguments[0] : void 0,
|
|
32663
|
+
tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0
|
|
32664
|
+
};
|
|
32606
32665
|
}
|
|
32607
32666
|
}
|
|
32608
32667
|
}
|
|
@@ -32631,23 +32690,17 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32631
32690
|
const schemaTaggedErrorTCall = expression.expression;
|
|
32632
32691
|
if (ts.isCallExpression(schemaTaggedErrorTCall) && schemaTaggedErrorTCall.typeArguments && schemaTaggedErrorTCall.typeArguments.length > 0) {
|
|
32633
32692
|
const selfTypeNode = schemaTaggedErrorTCall.typeArguments[0];
|
|
32634
|
-
const
|
|
32635
|
-
|
|
32636
|
-
|
|
32637
|
-
|
|
32638
|
-
|
|
32639
|
-
|
|
32640
|
-
|
|
32641
|
-
|
|
32642
|
-
|
|
32643
|
-
|
|
32644
|
-
|
|
32645
|
-
selfTypeNode,
|
|
32646
|
-
keyStringLiteral: schemaTaggedErrorTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedErrorTCall.arguments[0]) ? schemaTaggedErrorTCall.arguments[0] : void 0,
|
|
32647
|
-
tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
|
|
32648
|
-
Schema: parsedSchemaModule.value
|
|
32649
|
-
};
|
|
32650
|
-
}
|
|
32693
|
+
const isEffectSchemaModuleApi = yield* pipe(
|
|
32694
|
+
isNodeReferenceToEffectSchemaModuleApi("TaggedError")(schemaTaggedErrorTCall.expression),
|
|
32695
|
+
option4
|
|
32696
|
+
);
|
|
32697
|
+
if (isSome2(isEffectSchemaModuleApi)) {
|
|
32698
|
+
return {
|
|
32699
|
+
className: atLocation.name,
|
|
32700
|
+
selfTypeNode,
|
|
32701
|
+
keyStringLiteral: schemaTaggedErrorTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedErrorTCall.arguments[0]) ? schemaTaggedErrorTCall.arguments[0] : void 0,
|
|
32702
|
+
tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0
|
|
32703
|
+
};
|
|
32651
32704
|
}
|
|
32652
32705
|
}
|
|
32653
32706
|
}
|
|
@@ -32659,8 +32712,8 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32659
32712
|
"TypeParser.extendsSchemaTaggedError",
|
|
32660
32713
|
(atLocation) => atLocation
|
|
32661
32714
|
);
|
|
32662
|
-
const
|
|
32663
|
-
fn2("TypeParser.
|
|
32715
|
+
const extendsSchemaTaggedRequest = cachedBy(
|
|
32716
|
+
fn2("TypeParser.extendsSchemaTaggedRequest")(function* (atLocation) {
|
|
32664
32717
|
if (!atLocation.name) {
|
|
32665
32718
|
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
32666
32719
|
}
|
|
@@ -32673,18 +32726,19 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32673
32726
|
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
32674
32727
|
const expression = typeX.expression;
|
|
32675
32728
|
if (ts.isCallExpression(expression)) {
|
|
32676
|
-
const
|
|
32677
|
-
|
|
32678
|
-
|
|
32679
|
-
const
|
|
32680
|
-
|
|
32729
|
+
const schemaTaggedRequestTCall = expression.expression;
|
|
32730
|
+
if (ts.isCallExpression(schemaTaggedRequestTCall) && schemaTaggedRequestTCall.typeArguments && schemaTaggedRequestTCall.typeArguments.length > 0) {
|
|
32731
|
+
const selfTypeNode = schemaTaggedRequestTCall.typeArguments[0];
|
|
32732
|
+
const isEffectSchemaModuleApi = yield* pipe(
|
|
32733
|
+
isNodeReferenceToEffectSchemaModuleApi("TaggedRequest")(schemaTaggedRequestTCall.expression),
|
|
32681
32734
|
option4
|
|
32682
32735
|
);
|
|
32683
|
-
if (isSome2(
|
|
32736
|
+
if (isSome2(isEffectSchemaModuleApi)) {
|
|
32684
32737
|
return {
|
|
32685
32738
|
className: atLocation.name,
|
|
32686
|
-
|
|
32687
|
-
|
|
32739
|
+
selfTypeNode,
|
|
32740
|
+
tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
|
|
32741
|
+
keyStringLiteral: schemaTaggedRequestTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedRequestTCall.arguments[0]) ? schemaTaggedRequestTCall.arguments[0] : void 0
|
|
32688
32742
|
};
|
|
32689
32743
|
}
|
|
32690
32744
|
}
|
|
@@ -32692,13 +32746,13 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32692
32746
|
}
|
|
32693
32747
|
}
|
|
32694
32748
|
}
|
|
32695
|
-
return yield* typeParserIssue("Class does not extend
|
|
32749
|
+
return yield* typeParserIssue("Class does not extend Schema.TaggedRequest", void 0, atLocation);
|
|
32696
32750
|
}),
|
|
32697
|
-
"TypeParser.
|
|
32751
|
+
"TypeParser.extendsSchemaTaggedRequest",
|
|
32698
32752
|
(atLocation) => atLocation
|
|
32699
32753
|
);
|
|
32700
|
-
const
|
|
32701
|
-
fn2("TypeParser.
|
|
32754
|
+
const extendsDataTaggedError = cachedBy(
|
|
32755
|
+
fn2("TypeParser.extendsDataTaggedError")(function* (atLocation) {
|
|
32702
32756
|
if (!atLocation.name) {
|
|
32703
32757
|
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
32704
32758
|
}
|
|
@@ -32711,9 +32765,9 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32711
32765
|
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
32712
32766
|
const expression = typeX.expression;
|
|
32713
32767
|
if (ts.isCallExpression(expression)) {
|
|
32714
|
-
const
|
|
32715
|
-
const dataIdentifier =
|
|
32716
|
-
if (ts.isPropertyAccessExpression(dataIdentifier) && ts.isIdentifier(dataIdentifier.name) && ts.idText(dataIdentifier.name) === "
|
|
32768
|
+
const dataTaggedErrorCall = expression;
|
|
32769
|
+
const dataIdentifier = dataTaggedErrorCall.expression;
|
|
32770
|
+
if (ts.isPropertyAccessExpression(dataIdentifier) && ts.isIdentifier(dataIdentifier.name) && ts.idText(dataIdentifier.name) === "TaggedError") {
|
|
32717
32771
|
const parsedDataModule = yield* pipe(
|
|
32718
32772
|
importedDataModule(dataIdentifier.expression),
|
|
32719
32773
|
option4
|
|
@@ -32721,7 +32775,7 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32721
32775
|
if (isSome2(parsedDataModule)) {
|
|
32722
32776
|
return {
|
|
32723
32777
|
className: atLocation.name,
|
|
32724
|
-
keyStringLiteral:
|
|
32778
|
+
keyStringLiteral: dataTaggedErrorCall.arguments.length > 0 && ts.isStringLiteral(dataTaggedErrorCall.arguments[0]) ? dataTaggedErrorCall.arguments[0] : void 0,
|
|
32725
32779
|
Data: parsedDataModule.value
|
|
32726
32780
|
};
|
|
32727
32781
|
}
|
|
@@ -32730,13 +32784,13 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32730
32784
|
}
|
|
32731
32785
|
}
|
|
32732
32786
|
}
|
|
32733
|
-
return yield* typeParserIssue("Class does not extend Data.
|
|
32787
|
+
return yield* typeParserIssue("Class does not extend Data.TaggedError", void 0, atLocation);
|
|
32734
32788
|
}),
|
|
32735
|
-
"TypeParser.
|
|
32789
|
+
"TypeParser.extendsDataTaggedError",
|
|
32736
32790
|
(atLocation) => atLocation
|
|
32737
32791
|
);
|
|
32738
|
-
const
|
|
32739
|
-
fn2("TypeParser.
|
|
32792
|
+
const extendsDataTaggedClass = cachedBy(
|
|
32793
|
+
fn2("TypeParser.extendsDataTaggedClass")(function* (atLocation) {
|
|
32740
32794
|
if (!atLocation.name) {
|
|
32741
32795
|
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
32742
32796
|
}
|
|
@@ -32749,35 +32803,28 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32749
32803
|
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
32750
32804
|
const expression = typeX.expression;
|
|
32751
32805
|
if (ts.isCallExpression(expression)) {
|
|
32752
|
-
const
|
|
32753
|
-
|
|
32754
|
-
|
|
32755
|
-
const
|
|
32756
|
-
|
|
32757
|
-
|
|
32758
|
-
|
|
32759
|
-
|
|
32760
|
-
|
|
32761
|
-
|
|
32762
|
-
|
|
32763
|
-
|
|
32764
|
-
|
|
32765
|
-
className: atLocation.name,
|
|
32766
|
-
selfTypeNode,
|
|
32767
|
-
tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
|
|
32768
|
-
keyStringLiteral: schemaTaggedRequestTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedRequestTCall.arguments[0]) ? schemaTaggedRequestTCall.arguments[0] : void 0,
|
|
32769
|
-
Schema: parsedSchemaModule.value
|
|
32770
|
-
};
|
|
32771
|
-
}
|
|
32806
|
+
const dataTaggedClassCall = expression;
|
|
32807
|
+
const dataIdentifier = dataTaggedClassCall.expression;
|
|
32808
|
+
if (ts.isPropertyAccessExpression(dataIdentifier) && ts.isIdentifier(dataIdentifier.name) && ts.idText(dataIdentifier.name) === "TaggedClass") {
|
|
32809
|
+
const parsedDataModule = yield* pipe(
|
|
32810
|
+
importedDataModule(dataIdentifier.expression),
|
|
32811
|
+
option4
|
|
32812
|
+
);
|
|
32813
|
+
if (isSome2(parsedDataModule)) {
|
|
32814
|
+
return {
|
|
32815
|
+
className: atLocation.name,
|
|
32816
|
+
keyStringLiteral: dataTaggedClassCall.arguments.length > 0 && ts.isStringLiteral(dataTaggedClassCall.arguments[0]) ? dataTaggedClassCall.arguments[0] : void 0,
|
|
32817
|
+
Data: parsedDataModule.value
|
|
32818
|
+
};
|
|
32772
32819
|
}
|
|
32773
32820
|
}
|
|
32774
32821
|
}
|
|
32775
32822
|
}
|
|
32776
32823
|
}
|
|
32777
32824
|
}
|
|
32778
|
-
return yield* typeParserIssue("Class does not extend
|
|
32825
|
+
return yield* typeParserIssue("Class does not extend Data.TaggedClass", void 0, atLocation);
|
|
32779
32826
|
}),
|
|
32780
|
-
"TypeParser.
|
|
32827
|
+
"TypeParser.extendsDataTaggedClass",
|
|
32781
32828
|
(atLocation) => atLocation
|
|
32782
32829
|
);
|
|
32783
32830
|
const extendsContextTag = cachedBy(
|
|
@@ -32837,6 +32884,10 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32837
32884
|
if (!heritageClauses) {
|
|
32838
32885
|
return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
|
|
32839
32886
|
}
|
|
32887
|
+
const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
|
|
32888
|
+
if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
|
|
32889
|
+
const type2 = typeChecker.getTypeOfSymbol(classSym);
|
|
32890
|
+
const tagType = yield* contextTag(type2, atLocation);
|
|
32840
32891
|
for (const heritageClause of heritageClauses) {
|
|
32841
32892
|
for (const typeX of heritageClause.types) {
|
|
32842
32893
|
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
@@ -32846,26 +32897,19 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32846
32897
|
if (ts.isCallExpression(effectTagCall) && wholeCall.typeArguments && wholeCall.typeArguments.length > 0) {
|
|
32847
32898
|
const effectTagIdentifier = effectTagCall.expression;
|
|
32848
32899
|
const selfTypeNode = wholeCall.typeArguments[0];
|
|
32849
|
-
|
|
32850
|
-
|
|
32851
|
-
|
|
32852
|
-
|
|
32853
|
-
|
|
32854
|
-
|
|
32855
|
-
|
|
32856
|
-
|
|
32857
|
-
|
|
32858
|
-
|
|
32859
|
-
|
|
32860
|
-
|
|
32861
|
-
|
|
32862
|
-
keyStringLiteral: ts.isStringLiteral(effectTagCall.arguments[0]) ? effectTagCall.arguments[0] : void 0,
|
|
32863
|
-
args: effectTagCall.arguments,
|
|
32864
|
-
Identifier: tagType.Identifier,
|
|
32865
|
-
Service: tagType.Service,
|
|
32866
|
-
Tag: parsedEffectModule.value
|
|
32867
|
-
};
|
|
32868
|
-
}
|
|
32900
|
+
const isEffectTag = yield* pipe(
|
|
32901
|
+
isNodeReferenceToEffectModuleApi("Tag")(effectTagIdentifier),
|
|
32902
|
+
option4
|
|
32903
|
+
);
|
|
32904
|
+
if (isSome2(isEffectTag)) {
|
|
32905
|
+
return {
|
|
32906
|
+
className: atLocation.name,
|
|
32907
|
+
selfTypeNode,
|
|
32908
|
+
keyStringLiteral: ts.isStringLiteral(effectTagCall.arguments[0]) ? effectTagCall.arguments[0] : void 0,
|
|
32909
|
+
args: effectTagCall.arguments,
|
|
32910
|
+
Identifier: tagType.Identifier,
|
|
32911
|
+
Service: tagType.Service
|
|
32912
|
+
};
|
|
32869
32913
|
}
|
|
32870
32914
|
}
|
|
32871
32915
|
}
|
|
@@ -32895,13 +32939,16 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32895
32939
|
if (ts.isCallExpression(effectServiceCall) && effectServiceCall.typeArguments && effectServiceCall.typeArguments.length > 0) {
|
|
32896
32940
|
const effectServiceIdentifier = effectServiceCall.expression;
|
|
32897
32941
|
const selfTypeNode = effectServiceCall.typeArguments[0];
|
|
32898
|
-
|
|
32942
|
+
const isEffectService = yield* pipe(
|
|
32943
|
+
isNodeReferenceToEffectModuleApi("Service")(effectServiceIdentifier),
|
|
32944
|
+
option4
|
|
32945
|
+
);
|
|
32946
|
+
if (isSome2(isEffectService)) {
|
|
32899
32947
|
const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
|
|
32900
32948
|
if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
|
|
32901
32949
|
const type2 = typeChecker.getTypeOfSymbol(classSym);
|
|
32902
32950
|
const parsedContextTag = yield* pipe(
|
|
32903
|
-
|
|
32904
|
-
flatMap18(() => contextTag(type2, atLocation)),
|
|
32951
|
+
contextTag(type2, atLocation),
|
|
32905
32952
|
option4
|
|
32906
32953
|
);
|
|
32907
32954
|
if (isSome2(parsedContextTag)) {
|
|
@@ -32943,6 +32990,7 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32943
32990
|
(atLocation) => atLocation
|
|
32944
32991
|
);
|
|
32945
32992
|
return {
|
|
32993
|
+
isNodeReferenceToEffectModuleApi,
|
|
32946
32994
|
effectType,
|
|
32947
32995
|
strictEffectType,
|
|
32948
32996
|
layerType,
|
|
@@ -32971,6 +33019,80 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
32971
33019
|
};
|
|
32972
33020
|
}
|
|
32973
33021
|
|
|
33022
|
+
// src/diagnostics/catchUnfailableEffect.ts
|
|
33023
|
+
var catchUnfailableEffect = createDiagnostic({
|
|
33024
|
+
name: "catchUnfailableEffect",
|
|
33025
|
+
code: 2,
|
|
33026
|
+
severity: "suggestion",
|
|
33027
|
+
apply: fn2("catchUnfailableEffect.apply")(function* (sourceFile, report) {
|
|
33028
|
+
const ts = yield* service2(TypeScriptApi);
|
|
33029
|
+
const typeParser = yield* service2(TypeParser);
|
|
33030
|
+
const typeChecker = yield* service2(TypeCheckerApi);
|
|
33031
|
+
const nodeToVisit = [];
|
|
33032
|
+
const appendNodeToVisit = (node) => {
|
|
33033
|
+
nodeToVisit.push(node);
|
|
33034
|
+
return void 0;
|
|
33035
|
+
};
|
|
33036
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
33037
|
+
while (nodeToVisit.length > 0) {
|
|
33038
|
+
const node = nodeToVisit.shift();
|
|
33039
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
33040
|
+
if (ts.isCallExpression(node)) {
|
|
33041
|
+
const catchFunctions = ["catchAll", "catch", "catchIf", "catchSome", "catchTag", "catchTags"];
|
|
33042
|
+
const isCatchCall = yield* pipe(
|
|
33043
|
+
firstSuccessOf2(
|
|
33044
|
+
catchFunctions.map((catchFn) => typeParser.isNodeReferenceToEffectModuleApi(catchFn)(node.expression))
|
|
33045
|
+
),
|
|
33046
|
+
option4
|
|
33047
|
+
);
|
|
33048
|
+
if (isSome2(isCatchCall)) {
|
|
33049
|
+
const parent = node.parent;
|
|
33050
|
+
if (parent && ts.isCallExpression(parent)) {
|
|
33051
|
+
const pipeCallResult = yield* pipe(
|
|
33052
|
+
typeParser.pipeCall(parent),
|
|
33053
|
+
option4
|
|
33054
|
+
);
|
|
33055
|
+
if (isSome2(pipeCallResult)) {
|
|
33056
|
+
const { args: args3, node: pipeCallNode, subject } = pipeCallResult.value;
|
|
33057
|
+
const argIndex = args3.findIndex((arg) => arg === node);
|
|
33058
|
+
if (argIndex !== -1) {
|
|
33059
|
+
let effectTypeToCheck;
|
|
33060
|
+
if (argIndex === 0) {
|
|
33061
|
+
effectTypeToCheck = typeChecker.getTypeAtLocation(subject);
|
|
33062
|
+
} else {
|
|
33063
|
+
const signature = typeChecker.getResolvedSignature(pipeCallNode);
|
|
33064
|
+
if (signature) {
|
|
33065
|
+
const typeArguments = typeChecker.getTypeArgumentsForResolvedSignature(signature);
|
|
33066
|
+
if (typeArguments && typeArguments.length > argIndex) {
|
|
33067
|
+
effectTypeToCheck = typeArguments[argIndex];
|
|
33068
|
+
}
|
|
33069
|
+
}
|
|
33070
|
+
}
|
|
33071
|
+
if (effectTypeToCheck) {
|
|
33072
|
+
const effectType = yield* pipe(
|
|
33073
|
+
typeParser.effectType(effectTypeToCheck, node),
|
|
33074
|
+
option4
|
|
33075
|
+
);
|
|
33076
|
+
if (isSome2(effectType)) {
|
|
33077
|
+
const { E } = effectType.value;
|
|
33078
|
+
if (E.flags & ts.TypeFlags.Never) {
|
|
33079
|
+
report({
|
|
33080
|
+
location: node.expression,
|
|
33081
|
+
messageText: `Looks like the previous effect never fails, so probably this error handling will never be triggered.`,
|
|
33082
|
+
fixes: []
|
|
33083
|
+
});
|
|
33084
|
+
}
|
|
33085
|
+
}
|
|
33086
|
+
}
|
|
33087
|
+
}
|
|
33088
|
+
}
|
|
33089
|
+
}
|
|
33090
|
+
}
|
|
33091
|
+
}
|
|
33092
|
+
}
|
|
33093
|
+
})
|
|
33094
|
+
});
|
|
33095
|
+
|
|
32974
33096
|
// src/diagnostics/classSelfMismatch.ts
|
|
32975
33097
|
var classSelfMismatch = createDiagnostic({
|
|
32976
33098
|
name: "classSelfMismatch",
|
|
@@ -34230,11 +34352,11 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
34230
34352
|
"Layer"
|
|
34231
34353
|
) || "Layer";
|
|
34232
34354
|
const parseEffectProvideLayer = (node) => {
|
|
34233
|
-
if (ts.isCallExpression(node) &&
|
|
34355
|
+
if (ts.isCallExpression(node) && node.arguments.length > 0) {
|
|
34234
34356
|
const layer12 = node.arguments[0];
|
|
34235
34357
|
const type2 = typeChecker.getTypeAtLocation(layer12);
|
|
34236
34358
|
return pipe(
|
|
34237
|
-
typeParser.
|
|
34359
|
+
typeParser.isNodeReferenceToEffectModuleApi("provide")(node.expression),
|
|
34238
34360
|
flatMap18(() => typeParser.layerType(type2, layer12)),
|
|
34239
34361
|
map34(() => ({ layer: layer12, node })),
|
|
34240
34362
|
orElse14(() => void_8)
|
|
@@ -35083,10 +35205,10 @@ var strictEffectProvide = createDiagnostic({
|
|
|
35083
35205
|
const typeChecker = yield* service2(TypeCheckerApi);
|
|
35084
35206
|
const typeParser = yield* service2(TypeParser);
|
|
35085
35207
|
const parseEffectProvideWithLayer = (node) => gen3(function* () {
|
|
35086
|
-
if (!ts.isCallExpression(node) ||
|
|
35208
|
+
if (!ts.isCallExpression(node) || node.arguments.length === 0) {
|
|
35087
35209
|
return yield* typeParserIssue("Not an Effect.provide call");
|
|
35088
35210
|
}
|
|
35089
|
-
yield* typeParser.
|
|
35211
|
+
yield* typeParser.isNodeReferenceToEffectModuleApi("provide")(node.expression);
|
|
35090
35212
|
return yield* firstSuccessOf2(
|
|
35091
35213
|
node.arguments.map((arg) => {
|
|
35092
35214
|
const argType = typeChecker.getTypeAtLocation(arg);
|
|
@@ -35381,6 +35503,7 @@ var unsupportedServiceAccessors = createDiagnostic({
|
|
|
35381
35503
|
|
|
35382
35504
|
// src/diagnostics.ts
|
|
35383
35505
|
var diagnostics = [
|
|
35506
|
+
catchUnfailableEffect,
|
|
35384
35507
|
classSelfMismatch,
|
|
35385
35508
|
duplicatePackage,
|
|
35386
35509
|
effectGenUsesAdapter,
|
|
@@ -35548,6 +35671,13 @@ var moduleNames = choice3("module", [
|
|
|
35548
35671
|
repeated4,
|
|
35549
35672
|
withDescription3("The name of the module to patch.")
|
|
35550
35673
|
);
|
|
35674
|
+
var force = boolean5("force").pipe(
|
|
35675
|
+
withDefault3(false),
|
|
35676
|
+
withDescription3("Force patch even if already patched.")
|
|
35677
|
+
);
|
|
35678
|
+
var getPatchedMarker = (version) => {
|
|
35679
|
+
return `"use effect-lsp-patch-version ${version}";`;
|
|
35680
|
+
};
|
|
35551
35681
|
var getPatchesForModule = fn("getPatchesForModule")(
|
|
35552
35682
|
function* (moduleName, dirPath4, version, sourceFile) {
|
|
35553
35683
|
const ts = yield* getTypeScript;
|
|
@@ -35710,6 +35840,16 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
35710
35840
|
version
|
|
35711
35841
|
)
|
|
35712
35842
|
);
|
|
35843
|
+
patches.push(
|
|
35844
|
+
yield* makeEffectLspPatchChange(
|
|
35845
|
+
sourceFile.text,
|
|
35846
|
+
insertCheckSourceFilePosition.value.position,
|
|
35847
|
+
insertCheckSourceFilePosition.value.position,
|
|
35848
|
+
getPatchedMarker(version) + "\n",
|
|
35849
|
+
"\n",
|
|
35850
|
+
version
|
|
35851
|
+
)
|
|
35852
|
+
);
|
|
35713
35853
|
return patches;
|
|
35714
35854
|
}
|
|
35715
35855
|
);
|
|
@@ -35733,8 +35873,8 @@ var printRememberPrepareScript = fn("printRememberPrepareScript")(function* () {
|
|
|
35733
35873
|
}, ignore2);
|
|
35734
35874
|
var patch9 = make58(
|
|
35735
35875
|
"patch",
|
|
35736
|
-
{ dirPath: dirPath2, moduleNames },
|
|
35737
|
-
fn("patch")(function* ({ dirPath: dirPath4, moduleNames: moduleNames3 }) {
|
|
35876
|
+
{ dirPath: dirPath2, moduleNames, force },
|
|
35877
|
+
fn("patch")(function* ({ dirPath: dirPath4, force: force2, moduleNames: moduleNames3 }) {
|
|
35738
35878
|
const fs = yield* FileSystem;
|
|
35739
35879
|
const { version: effectLspVersion } = yield* getPackageJsonData(__dirname);
|
|
35740
35880
|
yield* logDebug2(`Searching for typescript in ${dirPath4}...`);
|
|
@@ -35745,7 +35885,16 @@ var patch9 = make58(
|
|
|
35745
35885
|
yield* logDebug2(`Searching ${moduleName}...`);
|
|
35746
35886
|
const filePath = yield* getModuleFilePath(dirPath4, moduleName);
|
|
35747
35887
|
yield* logDebug2(`Reading ${moduleName} from ${filePath}...`);
|
|
35748
|
-
const
|
|
35888
|
+
const sourceText = yield* getSourceFileText(filePath);
|
|
35889
|
+
yield* logDebug2(
|
|
35890
|
+
`Checking if ${filePath} is already patched with marker ${getPatchedMarker(effectLspVersion)}...`
|
|
35891
|
+
);
|
|
35892
|
+
if (!force2 && sourceText.indexOf(getPatchedMarker(effectLspVersion)) !== -1) {
|
|
35893
|
+
yield* logInfo2(`${filePath} is already patched with version ${effectLspVersion}, skipped.`);
|
|
35894
|
+
continue;
|
|
35895
|
+
}
|
|
35896
|
+
yield* logDebug2(`Parsing ${moduleName}...`);
|
|
35897
|
+
const sourceFile = yield* getUnpatchedSourceFile(filePath, sourceText);
|
|
35749
35898
|
yield* logDebug2(`Collecting patches for ${moduleName}...`);
|
|
35750
35899
|
const patches = yield* getPatchesForModule(moduleName, dirPath4, effectLspVersion, sourceFile);
|
|
35751
35900
|
const newSourceText = yield* applyTextChanges(sourceFile.text, patches);
|
|
@@ -35779,8 +35928,10 @@ var unpatch = make58(
|
|
|
35779
35928
|
for (const moduleName of modulesToUnpatch) {
|
|
35780
35929
|
yield* logDebug2(`Resolving ${moduleName}...`);
|
|
35781
35930
|
const filePath = yield* getModuleFilePath(dirPath4, moduleName);
|
|
35931
|
+
yield* logDebug2(`Reading ${moduleName} from ${filePath}...`);
|
|
35932
|
+
const sourceText = yield* getSourceFileText(filePath);
|
|
35782
35933
|
yield* logDebug2(`Unpatching ${filePath}...`);
|
|
35783
|
-
const sourceFile = yield* getUnpatchedSourceFile(filePath);
|
|
35934
|
+
const sourceFile = yield* getUnpatchedSourceFile(filePath, sourceText);
|
|
35784
35935
|
yield* logDebug2(`Writing ${filePath}...`);
|
|
35785
35936
|
yield* fs.writeFileString(filePath, sourceFile.text);
|
|
35786
35937
|
yield* logInfo2(`${filePath} unpatched successfully.`);
|