Giter Site home page Giter Site logo

Comments (12)

orta avatar orta commented on May 18, 2024 1

I don't want to be replicating every possible way to determine whether there's types when there's an existing index of all this info, the npm-search index is wrong for this dep: https://yarnpkg.com/?q=type-fest the answer is in fixing that - maybe algolia/npm-search#407 fixes it

from type-fest.

sindresorhus avatar sindresorhus commented on May 18, 2024

Nice! Yes, would be nice to come up with a playground that shows off many of the utilities.

from type-fest.

resynth1943 avatar resynth1943 commented on May 18, 2024

I'll try and have a look into this, dude. ❤️

from type-fest.

resynth1943 avatar resynth1943 commented on May 18, 2024

@orta There's one thing I don't understand.

Is your README example meant to work?

There were no types for 'type-fest' - will not try again in this session

from type-fest.

orta avatar orta commented on May 18, 2024

Interesting, the algolia index thinks there's no types in the package:

curl 'https://ofcncog2cu-dsn.algolia.net/1/indexes/npm-search/type-fest?attributes=types&x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%20(lite)%203.27.1&x-algolia-application-id=OFCNCOG2CU&x-algolia-api-key=f54e21fa3a2a0160595bb058179bfb1e' \
-XGET \
-H 'Accept: */*' \
-H 'Origin: https://www.typescriptlang.org' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Host: ofcncog2cu-dsn.algolia.net' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15' \
-H 'Accept-Language: en-us' \
-H 'Referer: https://www.typescriptlang.org/' \
-H 'Connection: keep-alive'

So the playground doesn't grab them at runtime - the problem is here somehow: https://github.com/algolia/npm-search

from type-fest.

resynth1943 avatar resynth1943 commented on May 18, 2024

I'm no expert at whatever you're using, but couldn't you fetch the package.json of the package via unpkg and check the types property? And, if it exists, fetch the file referenced in types?

from type-fest.

resynth1943 avatar resynth1943 commented on May 18, 2024

Sitting at the computer thinking of how we could implement this. Seeing as TypeScript playground links are pretty long, would it be a good idea to setup a website (https://sindresorhus.github.io/type-fest/) that redirects a URL such as https://sindresorhus.github.io/type-fest/play/except to the appropriate TypeScript playground URL?

This might be easier to change, too. For example, we could just change the link in the redirection HTML to that of the new TypeScript playground link, should we choose to modify it.

Of course, the HTML for https://sindresorhus.github.io/type-fest/play/except would look like this.

<meta http-equiv="refresh" content="2; url=https://www.typescriptlang.org/play/..." />

Am I overthinking this, or this is genuinely a good idea?

EDIT: After some thinking, this seems like breaking an egg with a sledgehammer, so to speak.

Expect a PR with TypeScript playground links.

from type-fest.

orta avatar orta commented on May 18, 2024

Why not take the opposite approach, the playground already supports examples. Add support for remote examples from other github repos:

So, it could be instead of:

https://www.typescriptlang.org/v2/en/play/?target=1#example/hello-world

it could be:

https://www.typescriptlang.org/v2/en/play/#example/sindresorhus/type-fest/hello-world.ts

from type-fest.

ifiokjr avatar ifiokjr commented on May 18, 2024

Interesting, the algolia index thinks there's no types in the package:

Would a quick fix be to add a types field to this projects package.json?

from type-fest.

orta avatar orta commented on May 18, 2024

Sure, that might do it 👍

from type-fest.

resynth1943 avatar resynth1943 commented on May 18, 2024

Great. Let's do it now.

from type-fest.

Haroenv avatar Haroenv commented on May 18, 2024

The index seems to mark typescript as included now, but still is missing on the typescript playground, any idea what could be going on?

curl 'https://ofcncog2cu-dsn.algolia.net/1/indexes/npm-search/type-fest?attributes=types&x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%20(lite)%203.27.1&x-algolia-application-id=OFCNCOG2CU&x-algolia-api-key=f54e21fa3a2a0160595bb058179bfb1e' \
-XGET \
-H 'Accept: */*' \
-H 'Origin: https://www.typescriptlang.org' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Host: ofcncog2cu-dsn.algolia.net' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15' \
-H 'Accept-Language: en-us' \
-H 'Referer: https://www.typescriptlang.org/' \
-H 'Connection: keep-alive'
{"types":{"ts":"included"},"objectID":"type-fest"}

from type-fest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.