-
Notifications
You must be signed in to change notification settings - Fork 104
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
Switching to typescript #183
Conversation
Ah yes, thanks for the head's up. I'l do the |
No worries, wasn't trying to pressure you, though. It was just in case someone would jump in to help! |
Now that |
VariablesState and StoryState look the most interesting to me, in terms of better understanding the flow of Ink. StoryState depends on CallStack, though, so maybe it makes sense for me to start with VariablesState while someone else does CallStack. |
Sounds good to me! @ephread what do you feel like tackling next? I might take NativeFunctionCall, but I don't really mind either way. |
@y-lohse I don't mind either way, I guess I'm going to do |
@y-lohse yet another bunch of items to add to Stuff to review. Checks
Cleanup & style
Decisions
|
Since we're almost done with the actual porting, I'll kick off discussions about the decisions. Let's try it all in this PR, we'll see if we need to split up discussions. 1. Raising exception vs. having undefined behavior (related to JsonSerialisation and Value, e. g. (int) variable vs parseInt(variable)).I'm not sure what this one is about, can we have a bit more details? 2. Explicitly annotating the return type vs. letting TypeScript infer it.Is there any upside to define the return types explicitly when TS can infer it? It looks like unnecessary extra work to me. 3. Use of TryGet functions.I have to look into that one before I have an opinion myself, but if you have one, shoot! 4. Use of throwNullException function.Nothing to complain about here — it highlights places were variables could be null, and makes the errors more explicit should they happen. The impact on readability is very manageable. 5. Porting all Debug.Assert from C#.Again, i have to look into that one. But it looks like something that can be done afterwards? It also ties in with the use of the 6. Define the rules about where to initialize properties.As in, whether we define them inside vs outside the constructor? If so, I'm very much in favor of declaring them outside, specifically having the declaration order match the C# order. 7. Decide what we do about the unified-signature rule
I suspect that forcing the unification will actually make declarations less readable. Am I the only one? Whereas I really don't mind the multiple declaration. |
For instance,
I agree!
Opening another issue on this topic may be a good idea!
I'd like to make one change: removing the string parameter from
Definitely, we could open another issue to deal with this. I kind of like the idea of being explicit, but maybe we should disable any console use in production (using a flag?).
That's correct. I think we should follow strictly what the C# does, and in the uninitialized properties, initialize them outside of the constructor. |
@NQNStudios I think you ere the one commenting on proxies here? If so, do you remember what you had in mind? |
src/Container.ts
Outdated
|
||
function appendIndentation(){ | ||
const spacesPerIndent = 4; // Truly const in the original code | ||
let spacesPerIndent = 4; // Truly let in the original code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Truly let" 😂, you dumb computer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops, good catch^^
124115d
to
1dddc2d
Compare
We're getting there! Most of the remaining checklist are non-urgent things. Just a few more questions for you @ephread :
|
Awesome!
It's a reminder to decide whether we should throw if the value is not of the correct type (to match the C# code). What do you think?
It can wait, as we need to refactor the tests first (to get the proper line report when the test fail). At the moment, the test suit run against the compiled & concatenated JavaScript file and doesn't pick up the source maps, resulting in funky line numbers.
I believe it's a reminder to make sure we that check against the appropriate value. |
Ah, ok! I opened an issue for this, but I think we should throw. Since there's an issue for that I'll consider it non blocking for the merge.
Alright!
Ah yes, good catch! |
* wip * more wip * Finished porting Value to Typescript * Finished first pass * linting * Force type casting o value creation * Fix indentation * set contextindex default value * Overload ListValue constructor * linting * remove unnecessary return types * use tryParseInt & tryParseFloat * allow value to be null * Match C# constructor order
* feat: convert CallStack * fix: CallStack failing tests
* Almost done with first pass VariablesState conversion Co-authored-by: Eliana Abraham <[email protected]> * Done with first pass of VariablesState Co-authored-by: Eliana Abraham <[email protected]> * Done with first pass of VariablesState Co-authored-by: Eliana Abraham <[email protected]> * Replacing Object assign with Map copy sonstructor Co-authored-by: Eliana Abraham <[email protected]> * style: Fix linter warnings * fix: Reorganize file to match C# order and fix map copy * fix: Replace any by CallStack where it makes sense * fix: remove useless boolean coercion * fix: Explicitely state return type of varValue
* feat: port native function call * feat: Copied over type assertion changes * fix: various fixups * fix: number of parameters can't be null * fix: use asOrThrows
Alright, it's time to merge this PR! First of all I want to thank @ephread for leading this effort and doing the bulk of the work. Big thanks as well to @NQNStudios for participating in this effort. The remaining items on the checklist are not blocking and can be sorted over time. Some already have dedicated issues, other will get them as we go. Keeping this PR open until everything is checked would drag things out forever. Going forward, I'll focus on making sure the changes from ink v0.8.2 get integrated before releasing a new stable version, and then avoiding having to do huge changes in one go as much as possible. |
Continuing #175!
Stuff to review (from #175 (comment) & #175 (comment))
Checks
Object
have been converted toMap
where appropriate (and that it works properly, especially inInkList
)const
are only used for constants.any
make sense (and are not placeholders for other types).VariablesState
.Cleanup & style
as
intoasOrNull
and(type)
intohasOrThrow
where applicable.forEach
loops intofor...of
loops.Decisions
JsonSerialisation
andValue
, e. g.(int) variable
vsparseInt(variable)
). -> Throwing in case of failed cast #227Debug.Assert
from C#. -> Debug.Assert calls and debug messages #221unified-signature
ruleChanges from master since the port has started
297f0b2...master