Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

tomdale
Copy link
Member

@tomdale tomdale commented Nov 18, 2017

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 anys. I skipped typing the component helper implementation due to time constraints, but it should be straightforward to derive its types from the others I've done here.

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';
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

@rwjblue It is already removed in @smfoote's upgrade branch.

Copy link
Member

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]);
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, thank you!

@tomdale
Copy link
Member Author

tomdale commented Feb 6, 2018

Superseded by #15828.

@tomdale tomdale closed this Feb 6, 2018
@rwjblue rwjblue deleted the annotate-macro-types branch February 16, 2018 15:04
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