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
chore: TypeScript to JavaScript + JSDoc for tests #8526
Conversation
@baseballyama is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
const exports = []; | ||
|
||
let code = fs.readFileSync(filename, 'utf-8') | ||
.replace(/^import \* as (\w+) from ['"]([^'"]+)['"];?/gm, 'var $1 = require("$2");') | ||
.replace(/^import (\w+) from ['"]([^'"]+)['"];?/gm, 'var {default: $1} = require("$2");') | ||
.replace(/^import \* as (\S+) from ['"]([^'"]+)['"];?/gm, 'var $1 = require("$2");') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove ESM -> CJS logic after we convert all TS files to JS.
test/types/actions.js
Outdated
@@ -0,0 +1,221 @@ | |||
const nullAsAny = /** @type {any} */(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed TS to JS + JSDoc for this file, But GitHub doesn't recognize file renaming🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep typescript for everything in test/types
. They are only internal for tests and not transformed or bundled in any way, so it doesn't affect the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought the same thing.
I don't have a strong opinion but we can get almost the same type checking between TS and JSDoc, so "Let's use JSDoc always" is super simple to recognize how to write tests.
And we can execute these type tests also if we want.
That's why I converted to JSDoc for type tests also.
(On the other hand, JSDoc has a limitation, so using TS for type tests can implement more tests.)
Anyway, I'm not against reverting to TS!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dummdidumm I reverted type tests!
By the way, why CI can not pass... |
I fixed CI. |
I tried to add
strict: true
attsconfig.json
, but it needs a lot of work. So for now just I converted TS to JS.After converting production code, we can remove handy ESM converting logic from tests. But I didn't do this for now.
This PR just converts TS to JS.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests
npm test
and lint the project withnpm run lint