codesandbox-client icon indicating copy to clipboard operation
codesandbox-client copied to clipboard

Configuring which TypeScript version is used?

Open ffMathy opened this issue 6 years ago • 40 comments

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?

ffMathy avatar Jul 03 '18 09:07 ffMathy

It would be great if changing the "typescript" version in package.json worked as expected. 😎

aleclarson avatar Sep 20 '18 21:09 aleclarson

Is this deployed yet? I can't seem to get CodeSandbox to use any TypeScript version other then 3.3.3

bengry avatar Jun 11 '19 14:06 bengry

@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 avatar Jun 11 '19 14:06 aleclarson

@aleclarson so what does this change?

bengry avatar Jun 11 '19 15:06 bengry

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.

TPReal avatar Jun 11 '19 20:06 TPReal

Shouldn't this be re-opened again then?

ffMathy avatar Jun 12 '19 19:06 ffMathy

Could this be re-opened? :pray:

gaui avatar Aug 15 '19 01:08 gaui

What's the current status? I see that changing typescript in devDependencies doesn't work?

ackvf avatar May 14 '20 14:05 ackvf

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 avatar May 19 '20 14:05 CompuIves

@CompuIves voicing my support for this as well and checking to see if you have any updates on this issue? Cheers

uicowboy avatar Jul 02 '20 06:07 uicowboy

@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.

mikeplus64 avatar Jul 24 '20 03:07 mikeplus64

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

MichaelDeBoey avatar Jul 26 '20 13:07 MichaelDeBoey

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.

github-actions[bot] avatar Oct 25 '20 01:10 github-actions[bot]

@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)

phryneas avatar Nov 29 '20 21:11 phryneas

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.

CompuIves avatar Dec 09 '20 13:12 CompuIves

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...

tianzhich avatar Dec 09 '20 13:12 tianzhich

@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 :)

phryneas avatar Dec 09 '20 14:12 phryneas

Yes! PR is here: https://github.com/codesandbox/codesandbox-client/pull/5257

CompuIves avatar Dec 10 '20 13:12 CompuIves

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.

github-actions[bot] avatar Mar 12 '21 00:03 github-actions[bot]

This issue has been automatically closed because there wasn't any activity after the previous notice or the stale label wasn't removed.

github-actions[bot] avatar Mar 28 '21 00:03 github-actions[bot]

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?

OnkelTem avatar May 24 '21 09:05 OnkelTem

Duplicate of #5598

JamesACS avatar Oct 15 '21 08:10 JamesACS

@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 avatar Oct 15 '21 08:10 phryneas

@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 avatar Oct 15 '21 11:10 JamesACS

@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.

barrymay avatar Oct 15 '21 11:10 barrymay

Ah @barrymay I'm with you now - I'll raise this as a feature request

JamesACS avatar Oct 15 '21 11:10 JamesACS

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.

barrymay avatar Oct 15 '21 11:10 barrymay

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 :)

JamesACS avatar Oct 15 '21 13:10 JamesACS

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.

bstro avatar Oct 27 '21 17:10 bstro

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

  1. a way to find the TypeScript version being used
  2. 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.

IanVS avatar Mar 17 '23 17:03 IanVS