-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
2.2.2 breaking change: globals are now 'not in scope' for templates? #38
Comments
LIke #38, this was intentional because in general there's no way to statically disambiguate between javascript globals and future ember keywords. That is the tradeoff of not making people import keywords. We do support We can decide to support a standard list of platform-provided globals, including The thing we don't want to do is support arbitrary globals. Like, if somebody decides they don't like importing their component all the time and tries |
Another (IMO more important) consideration is html tags, or rather, for the scoping rule to work consistently across all positions ( |
Not to say that I am against supporting |
I would like common casts added to the list: Boolean, String (helpful for glint) And utility namespaces: Math, JSON, Date, URL And Common globals: window, document, navigator, localStorage Tho, given the congern ef4 raises, i can deal with destructuring globalThis, as awkward as it is. Tho, elements must all be lowercase, so the namespaces and casts seem safe |
breaking but marked as a patch? Was wanting to consume this 2.2.2 patch to fix ember-cli/ember-template-imports#229 but as Simon mentions it's got other regressions like this. Likely related, I'm also having issues with enums that _are_ named and imported (click to expand)// app/components/alert.gts
export enum AlertType {
Information = 'information',
Warning = 'warning',
Critical = 'critical',
Success = 'success',
NewFeature = 'new-feature',
}
export component Alert: TOC = <template>
{{#if (eq @type AlertType.Warning)}}
...
{{else if ...}}
...
{{/if}}
</template> results in error at runtime
EDIT: opened issue for enums #65 |
Globals were not supposed to work, it was a bug that they worked, the bug is dangerous because if people come to rely on it, Ember is prevented from ever adding a new keyword again, because the template compiler has no way of distinguishing it from an in-scope global. Enums may be a different bug, please file a separate issue for that one. |
Thanks, I've put the bug example behind an expand block for the time being (and simplified the example as well) |
That's news to me, and IMO likely not known by anyone outside of the core devs 😅 I think anyone using any number of GTS files are likely to be using globals all over the place. Especially so given typescript is totally happy with it.
I agree, though it being a patch (and without mentioning it in the changelog at all......) might have been misguided. But having now looked over other GH issues on the repo regarding 2.2.2, I suspect that has already been made clear by the number of issues reported, and I shouldn't have brought it up. |
I just saw a colleague use |
Woah, yes |
turns out our work around doesn't work for so I have to do |
Wouldn't |
it would, yes |
There appears to be a breaking change between
2.2.1
and2.2.2
. Previously, in gjs files, we could reference JS globals directly as helpers. For example, we were using@something=(Boolean this.blah)
to cast a value to a boolean.Now, we get the error:
Adding
const Boolean = window.Boolean
to the file works around the problem.This problem is not limited to helpers. Something like
{{document.title}}
previously worked, but now throws a 'not in scope' error.The text was updated successfully, but these errors were encountered: