Uh oh!
There was an error while loading. Please reload this page.
As operator - #3201
Conversation
There was a problem hiding this comment.
why do you need this token?
There was a problem hiding this comment.
Don't think we need to store the as token.
Can we have a few tests for templates in varx=`${123+456asnumber}`;vary=`leading ${123+456asnumber}`;vary=`${123+456asnumber} trailing`;declarefunctiontag(...x: any[]): any;varx=tag`Hello ${123} World`asstring;vary=tag`Hello`asstring; |
Yui (yuit)
commented
May 19, 2015
Should we add formating rule for varx=42asstring;will become varx=42asstring; |
Yui (yuit)
commented
May 19, 2015
Could we add some tests: vara=20;varb=aasstring;varas="hello";varas1=asasstring; |
Tingan Ho (tinganho)
commented
May 19, 2015
I'm just wondering if we can support inferred type assertions and if it is a good idea? Instead of: We could just use: And it will infer the type by looking at the last property. |
If by formatting rule, you mean a restriction, yes (good catch!), but not related to the example you just gave (nowhere else in the language do we differentiate whitespace on the same line). Consider the following: classFoo{}declarefunctionas(...args: any[]);// Example 1varx=10as`Hello world`// Example 2vary=20as(Foo);Example 1 is not as much of a problem; you can't use a template string as a type. Example 2 suffers from potentially the same problem as #2995. |
Yui (@yuit) Ah, by formatting rule, you meant in the LS - still, glad we caught this. |
Yui (yuit)
commented
May 19, 2015
Daniel Rosenwasser (@DanielRosenwasser) yes, I mean from LS side similar to: functionfoo(){}become functionfoo(){}Though you example will be a good one to add as well. |
There was a problem hiding this comment.
else on the next line.
Ryan Cavanaugh (RyanCavanaugh)
commented
May 20, 2015
Any other feedback? |
There was a problem hiding this comment.
just add a comment for this case.
There was a problem hiding this comment.
else on the next line
You're currently not contextually typing the left-hand side of the varx=(v=>v)as(x: number)=>number
varx=(v=>v)as(x: number)=>stringcurrently typechecks without a problem even though varx=<(x: number)=>string>(v=>v)gives an error. |
Can we also have the following tests to demonstrate left-associativity of
varx=10asnumberasanyasstring// should be okay
vary=10asstringasnumber;// should error |
Ryan Cavanaugh (RyanCavanaugh)
commented
May 22, 2015
Anything else? |
Are we leaving the services layer to a second pass? I can think of at least:
classC<T>{constructor(){// C, T, and U should show up below.letf=<U>(x: any)=>xas/**/typeA=any;namespacen{typeB=any;// A, B, T, and n should show up below.letf=<T>(x: any)=>xas/**/
|
I am working on a change such that keywords like But It seems like the appropriate thing to do is to treat it as an declaration named You'll have to account for this with some tests like: interfaceas{}interfaceas{}interfaceas({})namespaceas{}declareas{}typeas=number; |
There was a problem hiding this comment.
Can you just check scanner.hasPrecedingLineBreak instead? I don't really like canParseSemicolon that much.
Mohamed Hegazy (mhegazy)
commented
Jun 9, 2015
Ryan Cavanaugh (@RyanCavanaugh) is this ready to go in? |
Ryan Cavanaugh (RyanCavanaugh)
commented
Jun 10, 2015
I'm merging this up with the JSX work, which should have a PR in a day or so |
Mohamed Hegazy (mhegazy)
commented
Jun 19, 2015
closing in favor of #3564 |
Implements
asoperator as suggested in #296.