assemblyscript
assemblyscript copied to clipboard
`import type` syntax
In some cases like importing an interface
, in portable mode, we don't want the output JS to include the type import. So for regular TypeScript projects we'd write this:
import type {SomeInterface} from 'somewhere'
but the import type
currently causes an error with asc
so we must write
import {SomeInterface} from 'somewhere'
which causes side effects when compiling to JS despite needing only a type.
When compiling to JS the import type
allows the tsc
compiler to strip the import statement (thus not instantiate everything in the module at JS runtime if only a type was needed).
asc
would need to allow the syntax, then treat it the same as it already does (because AS already does tree shaking, so it is no issue in AS).
I guess this PR may help with this: https://github.com/AssemblyScript/assemblyscript/pull/2150
Yeah, that seems perfect, since all mechanics for AS are in place