X Tutup
Skip to content

New functions v2#465

Merged
Perryvw merged 16 commits intomasterfrom
new-functions-v2
Mar 15, 2019
Merged

New functions v2#465
Perryvw merged 16 commits intomasterfrom
new-functions-v2

Conversation

@tomblind
Copy link
Collaborator

@tomblind tomblind commented Mar 2, 2019

-all functions default to having a self parameter
-@noSelf can be added to namespace or class to set the default within that scope (recursive)
-function assignment tests re-written in a more 'procedural' way, making them more thorough, but more numerous
-fixed an issue in generators where parameters were being hidden by redundant definitions

tomblind added 4 commits March 2, 2019 10:33
- also added noSelf directive to add `this: void` namespace/class-wide
- rewrote function assignment tests to be more thorough and maintainable
- fixed bug in generators where parameters were being hidden
- fixed bad definition in one of the assign test functions
- performing diagnostics on invalif function assignment tests
- added check in transpileString to ensure ignoreDiagnostics command line flag is respected
src/TSHelper.ts Outdated
return ContextType.Void;

let scopeDeclaration: ts.Declaration = signatureDeclaration;
while (true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably nice to refactor this loop into its own TSHelper.hasNoSelfAncestor

this: void,
arr: T[],
callbackFn: (this: void, element: T, index?: number, array?: T[]) => boolean
callbackFn: (element: T, index?: number, array?: T[]) => boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this callback inherits the void context from the function definition? Maybe it's me, but this doesn't seem very intuitive to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not inherited. I set the callback to take as self, so regularly defined functions can be passed in here. Otherwise any non-expression functions used as callbacks would need the this: void which would get annoying.

@tomblind tomblind marked this pull request as ready for review March 6, 2019 13:51
@Perryvw Perryvw merged commit 1e0247f into master Mar 15, 2019
@Perryvw Perryvw deleted the new-functions-v2 branch March 15, 2019 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup