go icon indicating copy to clipboard operation
go copied to clipboard

x/pkgsite: provide options for sorting search results by number of imports and stars on GitHub

Open thejerf opened this issue 5 years ago • 12 comments

As requested on https://blog.golang.org/pkg.go.dev-2020: I have found godoc.org to be the best way to search for quality Go modules, significantly because it defaults to sorting by the number of imports (possibly informed by the number of stars).

Compare: https://pkg.go.dev/search?q=smtp

To: https://godoc.org/?q=smtp

Observe, for instance, that on godoc.org, Brad Fitz's smtpd server comes up early, whereas on pkg.go.dev the front page has several packages of much less importance, and smtpd shows up on page 17 after a lot of inner modules and minor forks and larger projects that just happen to have an "smtp" package. Prioritizing hits at the "top level" of the package is probably a good idea, too; github.com/blah/smtpd is much more likely to be what I'm looking for than github.com/blah/project/go/inner1/inner2/smtp.

I also routinely suggest this to newcomers as a way of locating modules for Go.

thejerf avatar Jan 31 '20 21:01 thejerf

Thanks for the investigation! Looking into it. It could have something to do with a change to openapi-typescript-helpers. I think I’m going to add tests for different moduleResolutions somehow. Could or could not be the problem based on #1634, but couldn’t hurt to eliminate that as a possibility. This seems like a bug, as TSConfig settings shouldn’t affect type safety.

drwpow avatar Apr 28 '24 21:04 drwpow

Let me know if I can help - I had a sniff that the helpers might be involved too but I couldn't quite see how. There are a number of typing related changes in there, so it's a bit beyond my limited current understanding of the type infra here.

djMax avatar Apr 28 '24 21:04 djMax

Is this theoretically fixed? I think it is but I have only seen that the playground errors now (as it should). But before I go through the variety of deps to update would love to know it was intentional :)

djMax avatar May 19 '24 22:05 djMax

Running into exactly the same problem, currently stuck on 0.9.3, all versions afterwards lose all type information.

image

Whereas it used to work :)

image

Tried both openapi-typescript-helpers 0.0.7 and 0.0.8, no difference in the generated output together with openapi-typescript 6.7.6

My tsconfig.json has both module and moduleResolution set to NodeNext.

jacquesg avatar Jun 06 '24 21:06 jacquesg

Investigated this a little further and in planning for the upcoming 0.10.0 release (which requires [email protected] which will also get a stable release at the same time) this is hopefully fixed. Or if not fixed, easier to debug.

I believe some of this came from [email protected] generating a lot of partial schemas, which made inference harder. 7.x generating full schemas with never types means openapi-fetch can get simpler inference, and easier cross-comparison since all shapes are fully outlined. Or that’s the hope, at least.

drwpow avatar Jun 19 '24 21:06 drwpow

Some of the type inference that I believe led to the regression has been changed in 0.10.0. Are people still seeing the failures with the latest version?

drwpow avatar Jun 24 '24 14:06 drwpow

Not resolved here.

Bumped both fetch and generator to latest, regenerated, but no types. Using nodenext.

noetix avatar Jun 24 '24 23:06 noetix

It seems to be resolved with [email protected] and [email protected]. Thanks :)

Baldinof avatar Aug 20 '24 15:08 Baldinof

Thanks @Baldinof. Issue is still open because we didn’t find the original root cause as to what went wrong. But when it comes to advanced TypeScript inference, combining lots of objects that can differ from one user to the next, it’s easy to create “impossible unions” of types. openapi-typescript@7 was the first version released since openapi-fetch came out, and it generates a lot of key?: never types which at first glance seem like wasted boilerplate, but actually help make inference more efficient and more accurate (TS likes when all the shapes are the same).

I suspect the original issue had to do with the perfect storm of limitations of openapi-typescript@6 coupled with openapi-fetch working around those limitations as best it could, and some user-generated schemas not being in our test suite. Whether or not we could have solved it on the previous versions is hard to say. But either way, will leave this issue open for longer to see if others report problems with the current versions.

drwpow avatar Aug 20 '24 15:08 drwpow

I think I'm still having this problem :-( (with latest versions: "openapi-fetch": "0.12.0", "typescript": "5.6.2")

For a Node project, the only way I get types is with "module": "CommonJS", in tsconfig, setting "module": "NodeNext", breaks it.

osmestad avatar Sep 17 '24 13:09 osmestad

Is any reproduction available? I have a project at work that

  • uses ESNext modules (esm = transpiles into import/export syntax)
  • tsconfig moduleResolution set to "Bundler"
  • package.json has type: "module" to indicate that esm should be used (I guess)

The module system in javascript is a bit complicated to say the least (there's some light reading available at https://www.typescriptlang.org/docs/handbook/modules/theory.html#the-module-output-format).

edit: forgot to say that in the case of my project, I don't get this issue

mikavilpas avatar Sep 17 '24 16:09 mikavilpas

I think I figured out my problem, if I switch the TS "module" type I also need to add file extensions to the imports of the files (for modern/ESM format) it seems. So I guess that makes sense :-)

osmestad avatar Sep 17 '24 16:09 osmestad