-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Adds type annotations for ember-glimmer macro implementations #15862
Conversation
import { assert } from 'ember-debug'; | ||
import { wrapComponentClassAttribute } from '../utils/bindings'; | ||
import { dynamicComponentMacro } from './dynamic-component'; | ||
import { hashToArgs } from './utils'; | ||
import { OpcodeBuilderDSL } from '@glimmer/runtime'; | ||
import { unwrap } from '@glimmer/util'; |
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.
I believe this is stripped in glimmer-vm, but I don’t believe that is true here.
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.
I had that question too, @chadhietala probably knows that stuff the most intimately.
let args: ComponentArgs = [params.slice(1), hashToArgs(hash), null, null]; | ||
|
||
// We have to coerce makeComponentDefinition into an `any` here because | ||
// Glimmer VM is typing this too restrictively as a PathReference when it |
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.
Can you cross link to the issue in glimmer-vm that you will be opening to track removal of the coercion?
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.
This API no longer exists in Glimmer VM, so I don't think I will be opening that issue.
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.
@tomdale - So a future update of glimmer-vm will remove this comment (and what it is doing)? Can we link to anything that will help us understand this when we come back to this code in 6 months? I fear without any pointers to additional things to dig into, this will become yet another murder mystery for our future selves to solve. 🤔
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.
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.
Awesome, thank you (sorry for the run around).
|
||
if (type === Ops.Get || type === Ops.MaybeLocal) { | ||
let getExp = values[index]; | ||
let getExp = expectTupleExpression(values[index]); |
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.
Would it be better to use @glimmer/util
‘s expect
?
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.
expect
asserts truthiness, but I need to assert arrayiness.
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.
Gotcha, thank you!
Superseded by #15828. |
This PR adds annotations for the various Ember features implemented as Glimmer VM "macros" (i.e. they tap into the low-level opcode builder API). Previously these were mostly typed as
any
s. I skipped typing thecomponent
helper implementation due to time constraints, but it should be straightforward to derive its types from the others I've done here.