assemblyscript
assemblyscript copied to clipboard
Skip "type" keyword during import declarations
Support following declarations:
import type { Foo } from "./foo";
import type * as Foo from "./foo";
This will introduced in TS 4.5 so support this as well:
import { type Foo, Boo } from "./foo";
import { Boo, type Foo } from "./foo";
- [x] I've read the contributing guidelines
- [x] I've added my name and email to the NOTICE file
It may be worth to note that these behave differently in between TS and AS, in that TS will not include the respective source file, while AS always will. This can be unexpected, particularly since using the type
keyword is typically done for this exact purpose. So there seems to be a tension here, and I am not sure that the desire to support the syntax outweighs the risks.
Perhaps, a compromise could be to display a warning to inform the developer that the syntax is supported, but has different semantics?
In terms of TS, it's just speeding up type checking. Behaviour does not change much, just appear some restrictions. For AS, these restrictions do not make much sense. At least for now, but I wonder btw if we could also speedup / simplify / skip some checks with such notation? So I don't see much point in displaying a warning, as it's more of a constraint for TS, but not for AS.
Hmm, so is my understanding wrong that this is mainly there to force elision, i.e., that code / top-level statements etc. of the other file doesn't matter / execute? I believe I got that from the relevant announcement. In more familiar terms, it seems that import
preserves side effects, while import type
is deliberately used so it does not.
It not forces. It just hint which means imported name will uses only as type but not as object / class (for constructing, sub-classing or accessing to some static field / method).
closes #2317
Any news? :)
This PR has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions!
This PR has been automatically closed due to lack of recent activity, but feel free to reopen it as long as you merge in the main branch afterwards.