codesandbox-client
codesandbox-client copied to clipboard
Configuring which TypeScript version is used?
Can we make it so that I can configure which version of TypeScript to use? Can I (for instance) install typescript@next
and use that?
It would be great if changing the "typescript"
version in package.json
worked as expected. 😎
Is this deployed yet? I can't seem to get CodeSandbox to use any TypeScript version other then 3.3.3
@bengry From #1843:
This doesn't change which version is used by the editor yet, I'm meaning to change this later by introducing a BrowserFS backend that can handle UNPKG.
@aleclarson so what does this change?
I guess the issue is that the new syntax cannot be used on the online editor, so this change did not really fix the issue, just prepared for the fix if I understand correctly.
Shouldn't this be re-opened again then?
Could this be re-opened? :pray:
What's the current status? I see that changing typescript
in devDependencies
doesn't work?
It only changes the TypeScript version used by the bundler right now. It's not in the editor yet, as it would require us to dynamically update the VSCode Extensions. I can tackle that one this weekend, it slipped my todo.
@CompuIves voicing my support for this as well and checking to see if you have any updates on this issue? Cheers
@CompuIves voicing my support for this as well and checking to see if you have any updates on this issue? Cheers
Bump: same =). I have a library that depends on TS 4.0+ and would like to demo it but it's pretty awkward having lots of type errors there.
I think this one can be closed since https://github.com/codesandbox/codesandbox-client/pull/4583 is merged. Can anybody check this out? I’m currently not on my laptop
This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.
@MichaelDeBoey if I interpret this right, adding
{
"dependencies": {
"typescript": "4.1.2"
},
}
to the package.json
should make the editor use TS 4.1, correct?
Because right now, it seemingly doesn't :disappointed:
(Quick CSB for checking: link)
Oh that's right, we don't dynamically set it based on dependencies, but rather based on a string in our code. That's what the mentioned PR fixed. I took a look at the time to see if we could initialize it based on the sandbox config, but I wasn't able to make it work yet as the extension host starts before we fetch the sandbox.
That's the most challenging part, it surely is possible, but we need to restart the extension host whenever the TypeScript version changes (eg. you add it as dependency) or when you change sandbox. Because of this we make the extension host dependent on the sandbox, which will slow the editor initialization for a bit (first we need to fetch the sandbox before we can load the editor). It's something that I think should happen, but it's not implemented yet.
Oh that's right, we don't dynamically set it based on dependencies, but rather based on a string in our code. That's what the mentioned PR fixed. I took a look at the time to see if we could initialize it based on the sandbox config, but I wasn't able to make it work yet as the extension host starts before we fetch the sandbox.
That's the most challenging part, it surely is possible, but we need to restart the extension host whenever the TypeScript version changes (eg. you add it as dependency) or when you change sandbox. Because of this we make the extension host dependent on the sandbox, which will slow the editor initialization for a bit (first we need to fetch the sandbox before we can load the editor). It's something that I think should happen, but it's not implemented yet.
Thank you for your clarify. The stackblitz also has this problem. We just confusing and thought it could be "dynamic" updated cause this issue closed and a fixed pr linked to this...
@CompuIves in the long run, it would be great if we had this option of switching, especially for new TS betas etc. In the meantime: could you please bump the CS TS version up to TypeScript 4.1? That would be a very big short-time win :)
Yes! PR is here: https://github.com/codesandbox/codesandbox-client/pull/5257
This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.
This issue has been automatically closed because there wasn't any activity after the previous notice or the stale label wasn't removed.
I cannot change the version from 4.1.2 to anything else, despite I have 4.2.4 defined in my package.json.
When I click 4.1.2 label in the bottom bar, I see a dialog where I can select only one option: Use VS Code's version: 4.1.2
.
So how to change the version?
Duplicate of #5598
@JamesACS This is not a duplicate. #5598 was about updating TypeScript for all CodeSandboxes of all users to 4.2, this is a request to be able to configure the TS version per SandBox.
@phryneas Apologies if I'm misunderstanding - it should be possible to add a new Typescript version through the dependencies on a sandbox by sandbox basis
@JamesACS if you're saying that's a feature in place today or there's workarounds for this, it's not true from my experience.
The problem is that the codesandbox doesn't let you choose which TS to have the IDE evaluation code against (even if you manually add the ts version), which leads to those false positives.
Ah @barrymay I'm with you now - I'll raise this as a feature request
Thanks! By the way I think that https://github.com/codesandbox/codesandbox-client/issues/5598 and this are in the same vein.
If a new Sandbox used the currently latest stable TS and (if possible) let users switch the version for ide evaluation (in the same vein that VSCode does natively) it would solve both issues. It only started out at 4.2 because that's how long this has been going on.
I've added it as a sub-feature request on our end. The main topic being upgrading the TS version, then as a side making the version selectable in the client if possible :)
I use Codesandbox primarily to reproduce issues to share on Github. It happens often enough that I run into a type error with a particular version of Typescript, but not in another. This is my usecase for needing to be able to select an arbitrary Typescript version. Just wanted to add this in case it helps.
Hi there, it's a shame that https://github.com/stackblitz/core/issues/337 had to be locked due to poor behavior from a user. But the last status update on that thread was:
I’m happy to share that there’s a big upgrade coming out later this year that will enable this.
I'm just wondering if there's
- a way to find the TypeScript version being used
- a way to change that version
It's a bit confusing to see typescript errors in a project that specifies a version of typescript that supports the syntax I'm using, so I think it would help avoid a lot of confusion if it was clear what version of TS is being used, at least.