@effect/language-service 0.38.2 → 0.38.3

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/index.js CHANGED
@@ -1194,10 +1194,10 @@ function makeTypeScriptUtils(ts) {
1194
1194
  if (!hasProperty(packageJsonScope.contents, "packageJsonContent")) return;
1195
1195
  const packageJsonContent = packageJsonScope.contents.packageJsonContent;
1196
1196
  if (!hasProperty(packageJsonContent, "name")) return;
1197
- if (!hasProperty(packageJsonContent, "version")) return;
1198
1197
  if (!hasProperty(packageJsonScope, "packageDirectory")) return;
1199
1198
  if (!isString(packageJsonScope.packageDirectory)) return;
1200
- const { name, version } = packageJsonContent;
1199
+ const { name } = packageJsonContent;
1200
+ const version = hasProperty(packageJsonScope, "version") ? packageJsonScope.version : "";
1201
1201
  if (!isString(name)) return;
1202
1202
  if (!isString(version)) return;
1203
1203
  const hasEffectInPeerDependencies = hasProperty(packageJsonContent, "peerDependencies") && isObject(packageJsonContent.peerDependencies) && hasProperty(packageJsonContent.peerDependencies, "effect");
@@ -1219,9 +1219,20 @@ function makeTypeScriptUtils(ts) {
1219
1219
  exportsKeys
1220
1220
  };
1221
1221
  }
1222
- function resolveModulePattern(sourceFile, pattern) {
1222
+ function resolveModulePattern(program, sourceFile, pattern) {
1223
1223
  if (pattern.indexOf("*") === -1) return [pattern.toLowerCase()];
1224
- const packageJsonScope = parsePackageContentNameAndVersionFromScope(sourceFile);
1224
+ let packageJsonScope = parsePackageContentNameAndVersionFromScope(sourceFile);
1225
+ if (!packageJsonScope && hasProperty(ts, "getPackageScopeForPath") && isFunction2(ts.getPackageScopeForPath) && hasProperty(ts, "getTemporaryModuleResolutionState") && isFunction2(ts.getTemporaryModuleResolutionState) && hasProperty(ts, "getPackageScopeForPath") && isFunction2(ts.getPackageScopeForPath)) {
1226
+ const temporaryModuleResolutionState = ts.getTemporaryModuleResolutionState(
1227
+ void 0,
1228
+ program,
1229
+ program.getCompilerOptions()
1230
+ );
1231
+ packageJsonScope = parsePackageContentNameAndVersionFromScope({
1232
+ ...sourceFile,
1233
+ packageJsonScope: ts.getPackageScopeForPath(sourceFile.fileName, temporaryModuleResolutionState)
1234
+ });
1235
+ }
1225
1236
  const referencedPackages = [];
1226
1237
  for (const statement of sourceFile.statements) {
1227
1238
  if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {
@@ -4029,7 +4040,7 @@ var importFromBarrel = createDiagnostic({
4029
4040
  const program = yield* service(TypeScriptProgram);
4030
4041
  const packageNamesToCheck = flatten(
4031
4042
  languageServicePluginOptions.namespaceImportPackages.map(
4032
- (packageName) => tsUtils.resolveModulePattern(sourceFile, packageName)
4043
+ (packageName) => tsUtils.resolveModulePattern(program, sourceFile, packageName)
4033
4044
  )
4034
4045
  );
4035
4046
  const isImportedFromBarrelExport = (element) => {
@@ -5767,7 +5778,7 @@ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
5767
5778
  const collectImportCache = fn("TypeScriptApi")(
5768
5779
  function* (packagePatterns, kind, topLevelNamedReexports) {
5769
5780
  for (const packagePattern of packagePatterns) {
5770
- const packageNames = tsUtils.resolveModulePattern(fromSourceFile, packagePattern);
5781
+ const packageNames = tsUtils.resolveModulePattern(program, fromSourceFile, packagePattern);
5771
5782
  for (const packageName of packageNames) {
5772
5783
  const packageInfo = getPackageInfo(fromSourceFile.fileName, packageName);
5773
5784
  if (!packageInfo) continue;