You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtypeBallfrom"./ball";exportclassPaddleextendsArea2D{_ball_dir: int;constructor(){super();this._ball_dir=1;}_on_area_entered(area: Area2D){if(area.name.begins_with("Ball")){// would be better expressed with a type guard, but nevermind that for now(areaasunknownasBall).direction=Vector2(this._ball_dir,randf()*2-1).normalized()}}}
ts2gd errors out with the following:
<nodepath>/node_modules/ts2gd/js/parse_node/parse_import_declaration.js:64
throw new Error("Unsupported import type!");
^
Error: Unsupported import type!
at Object.parseImportDeclaration (<nodepath>/node_modules/ts2gd/js/parse_node/parse_import_declaration.js:64:15)
at Object.parseNode (<nodepath>/node_modules/ts2gd/js/parse_node.js:169:47)
at <nodepath>/node_modules/ts2gd/js/parse_node/parse_source_file.js:33:73
at Array.map (<anonymous>)
at Object.parseSourceFile (<nodepath>/node_modules/ts2gd/js/parse_node/parse_source_file.js:33:41)
at Object.parseNode (<nodepath>/node_modules/ts2gd/js/parse_node.js:167:40)
at AssetSourceFile.compile (<nodepath>/node_modules/ts2gd/js/project/assets/asset_source_file.js:266:41)
at <nodepath>/node_modules/ts2gd/js/project/project.js:203:79
at Array.map (<anonymous>)
at TsGdProjectClass.compileAllSourceFiles (<nodepath>/node_modules/ts2gd/js/project/project.js:203:58)
Expected behaviour: import type statements (all forms, including import type X, import type { X }, and import { type X }) are erased, as in normal TypeScript.
A workaround is to write the following:
--- import type Ball from "./ball";+++ type Ball = import("./ball").default;
EDIT: actually, it seems to be more than import type -- import appears to be broken outright. Support isn't documented at all in the README and there aren't any examples, but from other issues (like #66) I get that sense that it didn't formerly crash even if not all use cases were supported. Is this a regression?
The text was updated successfully, but these errors were encountered:
lostfictions
changed the title
import type doesn't seem to be supportedimport seems to be broken
May 25, 2022
Current version does not support default imports (import A from "...") and for named imports (like import { A, B } from "...") type keyword should be ignored (but still it will generate code in .gd files because it is not handled what needs to be fixed). Support for default imports will come at some point after merging #61.
Given this code:
ts2gd
errors out with the following:Expected behaviour:
import type
statements (all forms, includingimport type X
,import type { X }
, andimport { type X }
) are erased, as in normal TypeScript.A workaround is to write the following:
EDIT: actually, it seems to be more than
import type
--import
appears to be broken outright. Support isn't documented at all in the README and there aren't any examples, but from other issues (like #66) I get that sense that it didn't formerly crash even if not all use cases were supported. Is this a regression?The text was updated successfully, but these errors were encountered: