Code Monkey home page Code Monkey logo

Comments (8)

andrewbranch avatar andrewbranch commented on May 16, 2024 1

This is currently expected behavior, but I do think we should explore changing it. This happens to avoid loading your own output files as part of your input files, but it doesn’t make a lot of sense to do for files that you didn’t emit, e.g. declaration files in node_modules.

from typescript.

MartinJohns avatar MartinJohns commented on May 16, 2024

The .ts files are included in the published package to enable "Go to source definition" for users. Is it really necessary to place all generated files into a separate directory?

Yes. A .ts is always preferred over the .d.ts. The declaration file is considered a build artifact of the TypeScript file.

See also #56412 (comment) and #15272.

from typescript.

fatcerberus avatar fatcerberus commented on May 16, 2024

Also worth noting is that "Go to source definition" only works at all because the TS language service prefers to load the .ts over the .d.ts

from typescript.

RyanCavanaugh avatar RyanCavanaugh commented on May 16, 2024

I'm confused how this project even builds. The inclusion of this .ts file should have been a rootDir and/or composite violation, and we should be trying to emit a .d.ts file for it.

Can we get a sample repo?

from typescript.

sheetalkamat avatar sheetalkamat commented on May 16, 2024

If file is imported from node_modules its not considered for "rootDir" and "composite" calculations as it wont be emitted

from typescript.

lucacasonato avatar lucacasonato commented on May 16, 2024

I'll set up a reproduction repo tomorrow

from typescript.

lucacasonato avatar lucacasonato commented on May 16, 2024

Made a small reproduction, instructions are in the README: https://github.com/lucacasonato/typescript-issue-58353

from typescript.

lucacasonato avatar lucacasonato commented on May 16, 2024

Our workaround for this was emitting both the .js and .d.ts files into a separate directory, but this has other issues (namely import.meta.url is now wrong for users, e.g jsr-io/jsr#477).

We'll try again here, by only emitting .d.ts files into a subdirectory, and keeping the .js files next to the .ts files - I think this will work, because we can already rewrite specifiers in the .d.ts files, but it'll be weird.

from typescript.

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.