#@babel/parser error on type assertion

4 messages · Page 1 of 1 (latest)

hollow swallow
#

The @babel/parser currently does not accept any type assertion in the following format:

const obj = <MyType>{
  key: value
}

When defining it like:

const obj = {
  key: value
} as MyType

the parser is not complaining anymore. Is there a plan to support the alternative syntax?

cunning sage
#

I've not seen that first format and don't think it's valid TypeScript. Did you perhaps mean this?

const obj: MyType = {
  key: value
}
hollow swallow
cunning sage
#

Oh! Today I learned. 📚 Thanks for the link!

I noticed that it says it won't work in *.tsx files. Is that the case here?