Giter VIP home page Giter VIP logo

Comments (4)

NickGerleman avatar NickGerleman commented on June 16, 2024

It seems like your tsconfig is not configured to allow TypeScript to resolve the “package.json” exports field.

This can be set using the “moduleResolution” option in your tsconfig. I would recommend “bundler” if you are using TypeScript 5, otherwise an option like “node16” or “nodenext” should work.

from yoga.

Omxjep3434 avatar Omxjep3434 commented on June 16, 2024

That does work for Typescript users, but what about Javascript users? They will have no tsconfig file. For example, my Visual Studio Code examples apply to Javascript users. They will essentially have no intellisense. Maybe that should be left for IDEs to implement though.

Do you think adding an index.d.ts file would be incorrect? I've never really dealt with type definitions and export maps in other projects.

from yoga.

NickGerleman avatar NickGerleman commented on June 16, 2024

I had originally had an extra “index.js” and “sync.js” files to try to catch clients which weren’t configured to support the exports field, but it ended up instead seeming like more churn than worth it.

It effectively means that you can transparently get opted out of platform conditions, and makes it very easy to get mismatched types from source.

I think the field will continue to become more common, and new out-of-the-box tsconfig for Node and frameworks do now tend to choose a compatible option. https://github.com/tsconfig/bases/tree/main/bases

As that continues, I would expect that VSCode learns to do ES Module resolution when a configuration file isn’t present, but IDE usage of types in an otherwise untyped project isn’t something I’ve tried to really test.

from yoga.

Omxjep3434 avatar Omxjep3434 commented on June 16, 2024

Cool, sounds good, I'll close the issue.

from yoga.

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.