-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to import *.ts file from *.js file? #1045
Comments
As a test, I converted Property.js to Property.ts and everything worked OK except for Webstorm navigation from files that import Property.js. Maybe the best path forward for this issue is to create a minimal reproducible case and submit as a bug report to Webstorm. |
I reported this to WebStorm and it is fixed in the latest EAP https://youtrack.jetbrains.com/issue/WEB-51357. It already works fine in Sublime. This issue can be closed. |
Confirmed fixed in WebStorm 2021.2 |
In phetsims/tasks#987 (comment) I mentioned problems in importing TypeScript files from JavaScript. @jonathanolson mentioned we would like to use TypeScript in central common-code files early on. I mentioned one approach to address that problem (Option 1), but I think it warrants elaboration and discussion:
Options:
// @ts-nocheck
so we don't have 50,000 errors all at once. I'm not sure what other implications may come with this large batch change.import ControlPanel from './ControlPanel.js';
(even though ControlPanel is a *.ts file). That works but WebStorm doesn't know how to highlight/autocomplete/navigate it. I opened a WebStorm issue here: https://youtrack.jetbrains.com/issue/WEB-51357 and I observed that Sublime (with the TypeScript plugin) works properly for this case.import ControlPanel from './ControlPanel';
. That works but only if you have your web server set to default to serve *.js for missing files. For instance, http-server can specify--ext js
to get this to work. Not sure how to fix that for all servers we use, or to push that requirement to all users of the phet codebase.https://github.com/microsoft/TypeScript/issues/16577
, and there are some 3rd party tools for it.For a learning/ramping-up phase, would it be best to mix file types for a while?
The text was updated successfully, but these errors were encountered: