Git Product home page Git Product logo

Comments (13)

kaelzhang avatar kaelzhang commented on September 26, 2024

Could you provide the use cases or concrete code slices?

Is it only a linting warning about potential issues or are there any real failures?

Here is the test case only for ts definition: https://github.com/kaelzhang/node-ignore/blob/master/test/ts/simple.ts

from node-ignore.

k2snowman69 avatar k2snowman69 commented on September 26, 2024

Sure and it's a real typescript typing/intellisense failure, not just linting. I ran into this in my own project here:
https://github.com/snowcoders/sortier/pull/2226/files#diff-55dee8ec3daf30391537fdc45f8c2639cca5d3e63faf83671ee7505eeb8fed03R10

I think with typescript + node16 resolution, when you share a single types file with cjs and esm, it seems to assume cjs. In this code, I had to @ts-expect-error because ignore here was the import module and typescript wanted me to use ignore.default(). Obviously that doesn't match your build output so I had to ignore the error to be able to get the program to continue to run.

If you need a repo environment, that project should work, just removed the @ts-expect-error and you should see the same bug. If that doesn't work for you, creating a narrowed reproduction repo wouldn't be difficult, it will just take a few days since the work week is starting.

from node-ignore.

kaelzhang avatar kaelzhang commented on September 26, 2024

It is really weird that tsc treats packages with/without type: module differently.

  • tsc ./src/lib/is-ignored/index.ts --moduleResolution Node16 failed with type:module in package.json
  • tsc ./src/lib/is-ignored/index.ts --moduleResolution Node16 succeeded with no type:module in package.json
  • tsc ./src/lib/is-ignored/index.ts succeeded

from node-ignore.

guoyunhe avatar guoyunhe commented on September 26, 2024

@kaelzhang I think the only way to fix this is to add a real esm output:

{
  "name": "ignore",
  "version": "5.3.0",
  "main": "index.js",
  "module": "index.mjs",
  "types": "index.d.ts"
}

from node-ignore.

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.