Comments (4)
Alias
kind should work for my use case but if you want to keep original typescript behaviour, even a way to check the "deep equality" of the type could work. I'm not really interested in name of the type but it's just knowing that they are exactly equal, (not structurally). Side-effect of fullname not being there is is
comparison doesn't work.
In containers, then equality would have to be checked recursively descending into the types
property. And by equality I mean, exact class is used. (even though ts considers classes structurally assignable, instanceof checks fail). And there would have to be a similar rule set for other types.
P.S. when doing Alias
there will be a generic case to consider. eg, my type above type ManagedReference<Other>
from tst-reflect.
I'm getting some inconsistent behaviours with how it handles container types. For example, using the above type,
class Foo {}
type ManagedReference<Other> = Other & Ref<any, Other>
type X = ManagedReference<any> // resolves to any
type Y = ManagedReference<unknown> // resolves to Ref<any, unknown>
type Z = ManagedReference<Foo> // resolves to intersection with Foo & Ref<any, Foo>
type V = ManagedReference<Foo | null> // same type as above but empty name & fullName, I think this is a bug
When it resolved to any, it's not visible whether a container was used. I think we should be capturing the type the user has used, not the final simplified type.
from tst-reflect.
That simplification is what TypeScript does, that's how the type
aliases works. It's just "virtual" placeholder; it's not a real type. Type alias is direct type reference or alias/placeholder for some unions and/or intersections. That's why container types should not have name nor fullName, never. U should not try to compare containers directly IMHO. You can end up with one container which will be union of two other containers eg. intersections. type A = (B & C) | (D & E)
Maybe the top level container will have a name, but those inner containers will not, they have no name, because they are not aliased.
Eg. type T = any & Ref<any, any>
.
I'm able to get information about that alias by reading its declaration (traversing the AST) but that's complicated. I would have to handle all possible declarations. That's why Record, Omit etc. were not working for a long time. I removed manual reading and now I just ask TS what type it is.
But I can change a behavior around types
a little. I can introduce new kind Alias
. It will have name and fullName but it will still resolve into final simplified type. It will be like Container
kind but you will know that it is specific type
alias with name and fullName.
from tst-reflect.
Fixed in v1. Not in the current version.
from tst-reflect.
Related Issues (20)
- `import * as _Br from 'tst-reflect'` is added to every compiled file HOT 4
- Add support of `isDefaultValueAvailable` and `getDefaultValue` on PropertyInfo and Parameter types HOT 6
- Support decorators from TS 4.8 HOT 2
- Unable to access parameter decorators HOT 2
- [BUG] Set not comparable HOT 1
- [Question] Anyway to add it as angular transformer HOT 18
- [BUG] tst-reflect: You call getType() method directly. You have probably wrong configuration, because tst-reflect-transformer package should replace this call by the Type instance. HOT 8
- [BUG] type metadata HOT 6
- Can't get `getType<T>()` to work HOT 5
- Participation in the new version of the system HOT 52
- [BUG] Watch mode HOT 1
- Can't get function to work with create-react-app HOT 3
- [BUG] Uncaught ReferenceError: _ßr is not defined HOT 4
- [Question] npm package using tst-reflect cannot be imported HOT 1
- [BUG] Union properties are broken HOT 5
- [BUG] TS 4.9 - "[ERR] tst-reflect: You call getType() method directly..." error when following base usage examples. HOT 17
- [Question] Comparison of Array types HOT 9
- [Question] How to get field type inside a decorator HOT 2
- [Question] Vite support HOT 3
- [Question] Does this work with functions? 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 tst-reflect.