Comments (11)
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.
This is the intended behavior unless you have an export { };
in the file (which tsc automatically inserts)
from typescript.
declaration.d.ts
already has an export
though?
from typescript.
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.
This doesn't work in module augmentation.
In module augmentation, you can already refer to types in the outer block
from typescript.
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.
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.
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.
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.
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.
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)
- A Pragmatic, Not-Really-Typed Errors Proposal HOT 11
- Make switch exhaustiveness check as a configuration of tsc. HOT 1
- Cannot extend `XMLHttpRequest` when target is `ES5` HOT 2
- Type predicate not inferred for discriminated union?
- Compilation error when reassigning destructurig array variable names HOT 1
- Operator '<' ***CAN*** be applied to types 'number | BigInt' and 'number' HOT 8
- JSDoc typedef imports are emitted with a resolved path to node_modules HOT 1
- Incorrect Path Resolution for Type Imports in TypeScript Declarations HOT 2
- All primitives can be spread in objects according to MDN but TypeScript prevents it HOT 15
- Go-to-definition should only show relevant definitions when value & type have same name HOT 6
- ArrayBuffer.isView not narrowing type HOT 3
- Update import/export specifier sort on rename HOT 7
- TS can't automatically infer type from outer function in certain cases HOT 7
- Allow non-polymorphic ("private") extension of base classes HOT 4
- Design Meeting Notes, 3/26/2024
- Shorter tuple contravariant inference gets picked over longer covariant inference when both come from rests
- Type widened prematurely in `catch` HOT 2
- Inconsistency with Template Literal Types and Conditional Types HOT 1
- Uninitialized instance properties can be accessed via initializers HOT 2
- No duplicate identifier error issued if `const` declared with function type with expandos HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.