Comments (5)
The comment was left over from the original repro, because the original author wanted object | null
to mean object
, even with noImplicitAny: false
.
from typescript.
Expected and Actual are swapped, I think?
from typescript.
No, it's the right way round. object
becomes any
when noImplicitAny: false
, and signature quickinfo should reflect that.
from typescript.
So this runs into an existing weird situation with reusing existing type declaration. It's not even unique to JSDoc types.
type /*1*/O = {
/*2*/foo: any | string
}
At marker 1 we can see:
type O = {
foo: any | string;
}
but at marker 2 we can see:
(property) foo: any
Note that declaration emit preserves any | string
here even in 5.4.
The reason why the type for @param
gets printed as any
is that it's the computed symbol's type that gets printed. When we hover over the function's symbol we end up serializing that symbol using serializeTypeForDeclaration
(called by symbolToParameterDeclaration
) and that prefers reusing the existing type node.
It's enough to wrap the type in this original repro into an object to get consistent non-reduced results:
/**
* @param {{prop: object | null}} o
*/
function create2(o) {}
create2/*1*/(undefined);
With the above, { prop: object | null; }
gets printed consistently. But that consistent result is misleading since the user won't easily notice that it's an any
in disguise.
from typescript.
@sandersn In that case, it’s not true that create(undefined)
“should error”. That’s why I asked. 😉
from typescript.
Related Issues (20)
- super() typed as returning void HOT 2
- Move to File does not generate imports in the same way that autoimports does
- Move To File makes extra spaces when moving jsdoc comments
- Type all exported members according to some interface HOT 2
- JSDoc typed function comments inside functions
- Error when accessing CSS property value using kebab case in `CSSStyleDeclaration` object HOT 1
- Type 'never' incorrectly inferred for mixed primitive type properties assignment with strictNullChecks disabled HOT 2
- Array of object unions not working as expected HOT 2
- Support WebIDL interfaces nominally (not just structurally) HOT 9
- Improve type inference for nullish coalescing (??) after null checks on multiple variables HOT 2
- [NewErrors] 5.7.0-dev.20240915 vs 5.6.2 HOT 6
- [ServerErrors][JavaScript] 5.7.0-dev.20240915 vs 5.6.2 HOT 3
- [ServerErrors][TypeScript] 5.7.0-dev.20240915 vs 5.6.2 HOT 4
- Inlay parameter hints don't account for trailing required parameters HOT 1
- JsDoc with overloads and different generics results in wrong dts output
- Generic Conditional Type resolved to `any` when passed an error `any` type HOT 8
- Typescript v5.6.2 resulting in "Overload signatures must all be optional or required." on alpine linux arm64 HOT 2
- File watching is registering thousands of redundant watchers
- File watching creates hundreds of recursive watchers in mono-repo when opening loose file
- Raise tsconfig default to ES2015 or later HOT 1
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.