#TSServer Syntax Error with Bun 1.0 Macros and TypeScript

1 messages · Page 1 of 1 (latest)

vital nacelle
#

I recently discovered in the Bun 1.0 announcement that Bun has a macro system that allows you to pre-calculate values during the build.
At the moment, I am a bit skeptical about whether this is good or not for my needs, but while trying out this feature, I encountered a small problem.
As stated here https://bun.sh/docs/bundler/macros, macros rely on with { type: 'macro' }; during the import for the import to be a macro. This specific syntax is part of the TC39 Stage 3 proposal.
So my issue is not that it's not 100% official in TypeScript, but rather that TSServer complains because it doesn't recognize this syntax.
I see no mention anywhere that the TypeScript server would be aware of this syntax, so I would like to know if I need to configure something or unfortunately there is no way to tell the TypeScript server that it's normal for the import to be strange?

eternal galleon
#

Yeah it'll take some time before this syntax is supported by all tools. Stage 3 is usually when support gets added but people might be a little more hesitant this time because the ealier incarnation of import attributes was demoted from Stage 3 to Stage 2: https://github.com/microsoft/TypeScript/issues/53656

GitHub

Suggestion 🔍 Search Terms import attributes, import assertions, esnext ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/Java...

#

you'll have to use // @ts-ignore for the moment

vital nacelle
#

Ok thank you that answers my question well.
I don't personally plan to use macros a lot like you can do in rust for example, but for things like reading a file during build (and not in dev).
It will help a lot ^^