-
Notifications
You must be signed in to change notification settings - Fork 10
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
TypeError: _extends.endsWith is not a function in utils.js when using extends property as an array in TypeScript 5+ #14
Comments
Thank you for the report! For the second solution, I didn't use Typescript as a dependency because it was too large for the file loading requirements. However, now I believe it is more promising as you pointed out; we can make it a peer dependency since every project with a |
While I agree that TypeScript is a large dependency, I believe it is reasonable to assume that anyone using However, with this new dependency, the package will also need to clearly state what versions of TS it supports and be able to handle changes in the API for backward compatibility. Quickly crunching some numbers from NPM downloads over the last 7 days, it's pretty safe to assume that if the package supports TS v3+, it will cover the majority of users. This would be a large package refactor and a robust test suite to ensure backward compatibility. However, I think the effort is worth the reward, as I have not found a package that does tsconfig to swc well, and seeing as swc has no desire to do this, feels worth it. |
Could you please take a look at PR #15? I also released I just checked out the |
Hi @songkeys, This looks great - on inspection, it seems to operate the way you intend. Unfortunately, this approach/package didn't work for our company and so we decided to go in a different direction to create a package that wasn't dependent on anything except the users' environment. We've also added a number of other features to the conversion process. However - I do believe that your fix will resolve the original issue. If you wanted to checkout how we solved the issue see -> https://github.com/ConvertibleCo/tswig |
When using TypeScript 5+ and configuring the tsconfig property "extends" as an array in the tsconfig.json file, the following error is thrown in the utils.js file:
This error occurs because the code expects "extends" to be a string. In TypeScript 5+, the extends property in the tsconfig.json file can now be a string or an array.
You can see the update here: microsoft/TypeScript#29118
Steps to reproduce:
Expected behavior:
The project should run without any errors.
Actual behavior:
The error mentioned above is thrown in the utils.js file.
Possible solution:
This solution is dependent on the desired direction for the package:
1. Manual approach
To address the issue, you can manually check if the extends property is an array or string in the tsconfig.json file. If it is a string, maintain the current behavior. If it is an array, you can do the following:
2. Use typescript
The previous solution may not be future-proof, as it tries to mimic the expected behavior of typescript rather than relying on TypeScript to compile the tsconfig and using the output to generate the swcconfig.
You can rely on TypeScript's inner workings to generate the complete tsconfig without worrying about compiling it, as follows:
This code generates the complete tsconfig as expected, without compiling it manually. You can leverage the inner workings of TypeScript to resolve the tsconfig and then use it to map the swcconfig.
Affected Package:
tsconfig-to-swcconfig
Version:
2.2.0
Platform:
The text was updated successfully, but these errors were encountered: