-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad Typing Ok / Error #98
Comments
+1 for this. |
to solve the problem I mentioned i have created :
=> so object and type are identical and in my eslint I have forbidden the use of Ok and Error function :
|
@mobily I would like to draw your attention to this very important issue. Since this library is based on typescript and moreover on functional programming, it is very important that the types and implementation match. thank you in advance |
those |
@JUSTIVE Okay, I get the point! The only potential problem would be if someone used a library or coded something with the same structure, then there would be a conflict. I mean anything that uses a structure with : The best way to avoid this would be to have a key like: -> Of course, I'm aware that this type of conflict may be rare, but I like to use the safest code :) |
I see the concerns you have. But I think It's quite a rare to have such type, names. |
Hello everyone,
=> PROBLEM: __: 'Ok' doesn't exists in the Ok object in javascript, but exists in the typescript type.
=> REASON: the type lies about the real js object
=> PROPOSED SOLUTION: add __: 'Ok' to the Ok object js
I found in the source code that Ok and Error are incorrectly typed. I assume this is intentional, but it's a problem because the type lies about the actual object. For example, this is a problem in my use of the function stringify in the typia lib.
in node-modules of my project I found:
file: ts-belt/dist/types/Result/index.d.ts
export declare const Ok: (value: T) => Ok;
export declare type Ok = {
readonly TAG: 0;
readonly _0: T;
} & {
__: 'Ok';
};
file: ts-belt/dist/Result.js
const Ok = r => ({
TAG: 0,
_0: r
});
Like you can see, the type lies about the real js object ...
What do you think about that ?
Thank you and have a nice day :)
The text was updated successfully, but these errors were encountered: