Skip to content
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

Merged
merged 3 commits into from Apr 26, 2023
Merged

chore: TypeScript to JavaScript + JSDoc for tests #8526

merged 3 commits into from Apr 26, 2023

Conversation

baseballyama
Copy link
Member

I tried to add strict: true at tsconfig.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

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with npm test and lint the project with npm run lint

@vercel
Copy link

vercel bot commented Apr 22, 2023

@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");')
Copy link
Member Author

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.

@@ -0,0 +1,221 @@
const nullAsAny = /** @type {any} */(null);
Copy link
Member Author

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🤷

Copy link
Member

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.

Copy link
Member Author

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!

Copy link
Member Author

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!

@baseballyama
Copy link
Member Author

By the way, why CI can not pass...
I think this is not related to this PR...

@benmccann benmccann changed the title [chore] TypeScript to JavaScript + JSDoc for tests chore: TypeScript to JavaScript + JSDoc for tests Apr 22, 2023
@baseballyama
Copy link
Member Author

I fixed CI.
#8528

@benmccann benmccann added this to the 4.x milestone Apr 24, 2023
test/helpers.js Outdated Show resolved Hide resolved
@dummdidumm dummdidumm merged commit 384927d into sveltejs:version-4 Apr 26, 2023
13 of 14 checks passed
@gtm-nayan gtm-nayan mentioned this pull request Jun 17, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants