GithubHelp home page GithubHelp logo

Comments (11)

jakebailey avatar jakebailey commented on April 28, 2024 1

But you're currently arguing for this like you would do it again if you could start from scratch and that I'm just not seeing.

"Intended" can mean "this sucks but we can't change it and we are intentionally not changing it".

But on DT, we can certainly try and create a lint rule that complains about mixed-exported types in modules without export {} (or force export {} in all files containing exports), or something, if that's the concern.

from typescript.

RyanCavanaugh avatar RyanCavanaugh commented on April 28, 2024

This is the intended behavior unless you have an export { }; in the file (which tsc automatically inserts)

from typescript.

fatcerberus avatar fatcerberus commented on April 28, 2024

declaration.d.ts already has an export though?

from typescript.

eps1lon avatar eps1lon commented on April 28, 2024

This is the intended behavior unless you have an export { }; in the file (which tsc automatically inserts)

This doesn't work in module augmentation.

// react.d.ts
export = React;
export as namespace React;
export {}

declare namespace React { }
// augmentation.d.t.s
export {}

declare module '.' {
   // can't put `export {}` here
   interface Whatever {}
}

will cause emissions of React.Whatever

Also:
it is intended behavior that it removes local types? What other bug would including local types cause?

from typescript.

RyanCavanaugh avatar RyanCavanaugh commented on April 28, 2024

This doesn't work in module augmentation.

In module augmentation, you can already refer to types in the outer block

from typescript.

typescript-bot avatar typescript-bot commented on April 28, 2024

This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

from typescript.

eps1lon avatar eps1lon commented on April 28, 2024

In module augmentation, you can already refer to types in the outer block

@RyanCavanaugh I don't understand what to make of this statement? I understand, that I can do that. How is that relevant here?

Edit:

You mean I should move it outside the module augmentation block and then it becomes hidden? Do we have lint rules for that in DT?

from typescript.

RyanCavanaugh avatar RyanCavanaugh commented on April 28, 2024

You mean I should move it outside the module augmentation block and then it becomes hidden?

Correct

Do we have lint rules for that in DT?

I'm not sure how/why we would? Both locations are valid depending on intent.

from typescript.

jakebailey avatar jakebailey commented on April 28, 2024

If you mean to flag unused ones that aren't exposed, those will get flagged once I have time to work on typescript-eslint/typescript-eslint#8611 and add it to DT (once I reimplement these scoping rules there), but yeah, there's no way to say "are you sure you meant to export that".

from typescript.

eps1lon avatar eps1lon commented on April 28, 2024

but yeah, there's no way to say "are you sure you meant to export that".

I'm pretty sure if you write type A = number; export type B = string; you either didn't meant to export A, or we can just force you to write export type A = number which is what we (used to?) do in DT packages where you either have to write export type ... everywhere or place an explicit export {}.

Why we need treat .d.ts, .ts and declare module entirely separately, I do not understand. I'd get it if this is just a just-so thing for backwards compat. But you're currently arguing for this like you would do it again if you could start from scratch and that I'm just not seeing.

from typescript.

RyanCavanaugh avatar RyanCavanaugh commented on April 28, 2024

Unless explicitly asked, I'm not here to discuss what we'd do differently from a blank slate perspective. Those responses are too long to fit in these tiny textboxes.

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.