lifeart / els-addon-typed-templates

Ember templates linting / autocomplete, based on Typescript language server
30 stars 3 forks source link

Ability to cast value to different type #81

Open wagenet opened 3 years ago

wagenet commented 3 years ago

Almost every situation that causes an issue for us could be resolved if we could use TypeScript's as. I'm not really sure how feasible it is to do this, but something like the following would be super nice:

{{!--
interface Value {
  someProp: string
}
interface Args {
  valueOrUndefined: Value | undefined;
}
--}}
{{#if @valueOrUndefined}}
  {{!-- @typed-override @valueOrUndefined as Value }}
  {{@valueOrUndefined.someProp}}
{{/if}}
lifeart commented 3 years ago

Oh, seems easier to add true branching :) We could start with transform prototype (how branching will look like in “transformed” case)

with marks support (to map it to actual positions in case of error)

also, we could figure out how to use real source maps for out case to simplify marking