@effect/language-service 0.40.1 → 0.41.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 CHANGED
@@ -61,6 +61,7 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
61
61
  - Detect unnecessary pipe chains like `X.pipe(Y).pipe(Z)`
62
62
  - Warn when using `Effect.Service` with `accessors: true` but methods have generics or multiple signatures
63
63
  - Warn on missing service dependencies in `Effect.Service` declarations
64
+ - Warn when `Effect.Service` is used with a primitive type instead of an object type
64
65
  - Warn when schema classes override the default constructor behavior
65
66
 
66
67
  ### Completions
package/cli.js CHANGED
@@ -29125,10 +29125,48 @@ var all9 = fn2("all")(
29125
29125
  var TypeScriptApi = Tag4("TypeScriptApi");
29126
29126
  var TypeScriptProgram = Tag4("TypeScriptProgram");
29127
29127
  var ChangeTracker = Tag4("ChangeTracker");
29128
+ function getPackageJsonInfoCache(program) {
29129
+ try {
29130
+ if (hasProperty(program, "getModuleResolutionCache") && isFunction2(program.getModuleResolutionCache)) {
29131
+ const moduleResolutionCache = program.getModuleResolutionCache();
29132
+ if (hasProperty(moduleResolutionCache, "getPackageJsonInfoCache") && isFunction2(moduleResolutionCache.getPackageJsonInfoCache)) {
29133
+ return moduleResolutionCache.getPackageJsonInfoCache();
29134
+ }
29135
+ }
29136
+ } catch (_) {
29137
+ return void 0;
29138
+ }
29139
+ return void 0;
29140
+ }
29141
+ function getDirectoryPath(ts4, path2) {
29142
+ try {
29143
+ if (hasProperty(ts4, "getDirectoryPath") && isFunction2(ts4.getDirectoryPath)) {
29144
+ return ts4.getDirectoryPath(path2);
29145
+ }
29146
+ return path2;
29147
+ } catch (_) {
29148
+ return path2;
29149
+ }
29150
+ }
29151
+ function makeGetTemporaryModuleResolutionState(ts4) {
29152
+ if (hasProperty(ts4, "getTemporaryModuleResolutionState") && isFunction2(ts4.getTemporaryModuleResolutionState)) {
29153
+ const _internal = ts4.getTemporaryModuleResolutionState;
29154
+ return (cache, program, compilerOptions) => _internal(cache, program, compilerOptions);
29155
+ }
29156
+ return void 0;
29157
+ }
29158
+ function makeGetPackageScopeForPath(ts4) {
29159
+ if (hasProperty(ts4, "getPackageScopeForPath") && isFunction2(ts4.getPackageScopeForPath)) {
29160
+ const _internal = ts4.getPackageScopeForPath;
29161
+ return (path2, state) => _internal(path2, state);
29162
+ }
29163
+ }
29128
29164
 
29129
29165
  // src/core/TypeScriptUtils.ts
29130
29166
  var TypeScriptUtils = Tag4("TypeScriptUtils");
29131
29167
  function makeTypeScriptUtils(ts4) {
29168
+ const getTemporaryModuleResolutionState = makeGetTemporaryModuleResolutionState(ts4);
29169
+ const getPackageScopeForPath = makeGetPackageScopeForPath(ts4);
29132
29170
  function parsePackageContentNameAndVersionFromScope(v) {
29133
29171
  if (!isObject(v)) return;
29134
29172
  if (!hasProperty(v, "packageJsonScope")) return;
@@ -29163,20 +29201,26 @@ function makeTypeScriptUtils(ts4) {
29163
29201
  exportsKeys
29164
29202
  };
29165
29203
  }
29166
- function resolveModulePattern(program, sourceFile, pattern2) {
29167
- if (pattern2.indexOf("*") === -1) return [pattern2.toLowerCase()];
29204
+ function resolveModuleWithPackageInfoFromSourceFile(program, sourceFile) {
29168
29205
  let packageJsonScope = parsePackageContentNameAndVersionFromScope(sourceFile);
29169
- if (!packageJsonScope && hasProperty(ts4, "getPackageScopeForPath") && isFunction2(ts4.getPackageScopeForPath) && hasProperty(ts4, "getTemporaryModuleResolutionState") && isFunction2(ts4.getTemporaryModuleResolutionState) && hasProperty(ts4, "getPackageScopeForPath") && isFunction2(ts4.getPackageScopeForPath)) {
29170
- const temporaryModuleResolutionState = ts4.getTemporaryModuleResolutionState(
29171
- void 0,
29206
+ if (!packageJsonScope && getPackageScopeForPath && getTemporaryModuleResolutionState) {
29207
+ const packageJsonInfoCache = getPackageJsonInfoCache(program);
29208
+ const temporaryModuleResolutionState = getTemporaryModuleResolutionState(
29209
+ packageJsonInfoCache,
29172
29210
  program,
29173
29211
  program.getCompilerOptions()
29174
29212
  );
29213
+ const directoryPath = getDirectoryPath(ts4, sourceFile.fileName);
29175
29214
  packageJsonScope = parsePackageContentNameAndVersionFromScope({
29176
29215
  ...sourceFile,
29177
- packageJsonScope: ts4.getPackageScopeForPath(sourceFile.fileName, temporaryModuleResolutionState)
29216
+ packageJsonScope: getPackageScopeForPath(directoryPath, temporaryModuleResolutionState)
29178
29217
  });
29179
29218
  }
29219
+ return packageJsonScope;
29220
+ }
29221
+ function resolveModulePattern(program, sourceFile, pattern2) {
29222
+ if (pattern2.indexOf("*") === -1) return [pattern2.toLowerCase()];
29223
+ const packageJsonScope = resolveModuleWithPackageInfoFromSourceFile(program, sourceFile);
29180
29224
  const referencedPackages = [];
29181
29225
  for (const statement of sourceFile.statements) {
29182
29226
  if (ts4.isImportDeclaration(statement) && ts4.isStringLiteral(statement.moduleSpecifier)) {
@@ -29194,20 +29238,6 @@ function makeTypeScriptUtils(ts4) {
29194
29238
  )
29195
29239
  );
29196
29240
  }
29197
- function makeGetModuleSpecifier() {
29198
- if (!(hasProperty(ts4, "moduleSpecifiers") && hasProperty(ts4.moduleSpecifiers, "getModuleSpecifier") && isFunction2(ts4.moduleSpecifiers.getModuleSpecifier))) return;
29199
- const _internal = ts4.moduleSpecifiers.getModuleSpecifier;
29200
- return (compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, options3) => {
29201
- return _internal(
29202
- compilerOptions,
29203
- importingSourceFile,
29204
- importingSourceFileName,
29205
- toFileName,
29206
- host,
29207
- options3
29208
- );
29209
- };
29210
- }
29211
29241
  function findNodeWithLeadingCommentAtPosition(sourceFile, position) {
29212
29242
  const sourceText = sourceFile.text;
29213
29243
  let result;
@@ -29596,6 +29626,7 @@ function makeTypeScriptUtils(ts4) {
29596
29626
  findNodeAtPositionIncludingTrivia,
29597
29627
  parsePackageContentNameAndVersionFromScope,
29598
29628
  resolveModulePattern,
29629
+ resolveModuleWithPackageInfoFromSourceFile,
29599
29630
  findNodeWithLeadingCommentAtPosition,
29600
29631
  getCommentAtPosition,
29601
29632
  getAncestorNodesInRange,
@@ -29610,7 +29641,6 @@ function makeTypeScriptUtils(ts4) {
29610
29641
  parseDataForExtendsClassCompletion,
29611
29642
  createEffectGenCallExpressionWithBlock,
29612
29643
  createReturnYieldStarStatement,
29613
- makeGetModuleSpecifier,
29614
29644
  parseAccessedExpressionForCompletion,
29615
29645
  getSourceFileOfNode
29616
29646
  };