Reflect Store #15
Replies: 9 comments 28 replies
-
Interesting... I actually hacked something together for this in another local branch, was just playing/testing so it's an absolute mess, but it works Also figured a somewhat okay method for finding the entry ts/js file of the source This object is added to any sources which are considered an "entry point", which is a lot, but doesn't depend on any importing... which can also be problematic
"process" holds the main store of types, rather than "typesMetaCache" in the reflect lib Then for the rest of the code, they reference this "store" object above to set/get types, reflect also uses this store It feels a little weird, but at the same time, seems to be working really great. If you're interested in it, I can push my branch to my fork^^ |
Beta Was this translation helpful? Give feedback.
-
It's interesting.. is that entry file detection reliable? It probably detect more files, that's quite Ok, but can it miss one?
Sorry, what does it mean? Ctors are not imported by that new require you wrote or runtime package is not imported or something else? My plan was make the metadata lib file mode default, store everything in one file and let user import this one file at startup. (And provide lookup methods from #2) BTW, we can change config |
Beta Was this translation helpful? Give feedback.
-
I have no idea about that piece but, i noticed when working with my code that did a similar thing in the past, that even if you create the identifier once, it wouldn't stay the same between different source files(if i remember correctly) I've also done a bit of refactoring on my code and changed it up to work with a meta file similar to your original implementation and it works great :D It also adds the lib import to all files(could be optimised so that it only adds it to ones who need it), but i don't think it matters too much Circular dependency isn't an issue(i don't think) since the new ctor implementation i did doesn't need the classes to be imported in the meta lib file However I just stumbled across one issue with this :( with those ctors and their path being relative to the source file who originally made the getType() call, they're invalid when in the meta file I think I can fix this though, might be over-thinking it, but pretty sure they just need to be relative to the meta file instead :D hopefully i can make a push soon so you can see! |
Beta Was this translation helpful? Give feedback.
-
I've just got an idea how to detect those situations,.. I gonna try to write some code and I hope that buggy identifier thing happen. |
Beta Was this translation helpful? Give feedback.
-
Oh nice :D thankfully you could reproduce, was so random for me ^^ I also pushed my wip code, there's a lot that isn't documented/tested/covered and i imagine in breaks the current in-line setup, but if you want to pull and have a little look, it works pretty damn well ^^ https://github.com/iDevelopThings/ts-reflection/tree/testing-hot-swappable-store-and-meta |
Beta Was this translation helpful? Give feedback.
-
@Hookyns are you against me extracting descriptions for the runtime package to separate files? My OCD is going slightly insane, it's also getting tiring scrolling for ever looking for things 😅 |
Beta Was this translation helpful? Give feedback.
-
So... been playing some more and tidying up all my code from yesterday + documenting. Also ran the regular inline generation through my code, it works well. Figured I can also just use it's current flow to add the reflect import into the file, this way we don't need to track the "getType import". Which will clean up the code base a lot I'll push this code, then I'll remove the code related to that in a separate commit so I can roll it back and then you can see what you think - idk if this refactor is a little overkill or not, but it allows us to modify key parts pretty easily and from main places, rather than all over the place :D |
Beta Was this translation helpful? Give feedback.
-
Was just also thinking about a way to mark things as "indexable" Like, it would be nice if we could use Maybe specifying an array of glob locations in tsconfig "reflection" : {
"metadata" : {
"paths" : [
"src/Services/**/*.ts",
"src/SomeExplicitFile.ts",
]
}
} If you're open to the idea, it's something I can work on a little whilst you're busy with this stuff^^ I feel it'd be quite a simple addition |
Beta Was this translation helpful? Give feedback.
-
@iDevelopThings U've ruined my life by that separation of |
Beta Was this translation helpful? Give feedback.
-
Just a random idea that crossed my mind
Do you think it would be better/possible to store the types/regular getType call on the window/process object(global basically)?
From time to time, I get random issues with the package not being imported from nested getType calls. Not sure if this is just cause of jest/ts-jest also
But this would also remove the need for that import + provide a global store that would work from everywhere right? 🤔
Beta Was this translation helpful? Give feedback.
All reactions