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

TypeScript <3.4 support #336

Closed
ehmicky opened this issue Jun 27, 2019 · 12 comments
Closed

TypeScript <3.4 support #336

ehmicky opened this issue Jun 27, 2019 · 12 comments

Comments

@ehmicky
Copy link
Collaborator

ehmicky commented Jun 27, 2019

The types do not work with TypeScript 3.3 (see #335) and below notably because of the changes to the readonly keyword brought by TypeScript 3.4. What should we do about it?

  1. Do nothing
  2. Add a typesVersions field to declare that we only support >=3.4
  3. Add a second fallback index.d.ts for lower versions, and use the typesVersions field to distinguish it.
@sindresorhus
Copy link
Owner

Do nothing.

typeVersions is meant to add fallbacks.

@ehmicky
Copy link
Collaborator Author

ehmicky commented Jun 27, 2019

Is there a way for us to document our minimal TypeScript supported version?

@sindresorhus
Copy link
Owner

Not in a way that warns the user I think. We could note it in the readme, but we both know that will not help much.

@ehmicky
Copy link
Collaborator Author

ehmicky commented Jun 28, 2019

I've done some quick search and it does not seem like TypeScript supports specifying minimal TypeScript version. As you say typesVersions is only meant for fallbacks.

I don't think we can assume users will always use the latest TypeScript version (major+minor+patch). New TypeScript versions are generally mostly compatible with older ones, but they also introduce new features that won't work on older versions.

Should we add a comment on top of the index.d.ts? Many users experiencing issues with tsc will probably look up that file.

I am also going to check if it's among the 3862 opened issues in the TypeScript repo, and post an issue there otherwise.

If there is really no solution to that problem (which I am surprised of), I would consider creating a package to solve it.

@sindresorhus
Copy link
Owner

Should we add a comment on top of the index.d.ts? Many users experiencing issues with tsc will probably look up that file.

Sure

I am also going to check if it's among the 3862 opened issues in the TypeScript repo, and post an issue there otherwise.

👍

@ehmicky
Copy link
Collaborator Author

ehmicky commented Jun 28, 2019

Issue at microsoft/TypeScript#32166

Let's see what happens there first.

@ehmicky
Copy link
Collaborator Author

ehmicky commented Jun 28, 2019

The guys at TypeScript are saying that supporting a minimal TypeScript version should be specified by using:

  "typesVersions": {
    ">=3.4": { "*": ["index.d.ts"] }
  }

This should produce an error message for users of older TypeScript versions: "'package.json' does not have a 'typesVersions' entry that matches version '3.1'.".

However there seems to be a bug there.

@danielkcz
Copy link

danielkcz commented Jul 29, 2019

Just got burned by this. We cannot afford to upgrade to 3.4 as there are other changes that break our code. Wish there was some way to simply ignore that index.d.ts and treat package untyped.

In my opinion as much as nicer it makes the code, would be really that bad to replace all readonly with regular ReadonlyArray? It's not like rewriting a whole type declaration. Just wait a bit more before people can catch up. It's quite silly to be forced to 1.x because of TypeScript and missing out tons of bugfixes and features.

Or at least the workaround microsoft/TypeScript#32166 (comment) sounds like another way. Having empty notsupported.d.ts is just close enough to having an untyped package.

@ehmicky
Copy link
Collaborator Author

ehmicky commented Jul 29, 2019

I would like @sindresorhus input on this.

I think you meant Readonly<T> not ReadonlyArray<T> since we are using readonly on an interface not an array.

@danielkcz
Copy link

danielkcz commented Jul 29, 2019

No, I mean for example this line ...

readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[];

The readonly StdioOption[] should be ReadonlyArray<StdioOption> to be supported prior TS 3.4.

But yea, there is a need for a bunch of Readonly<T> as well. It has produced 33 errors in total.

@ehmicky
Copy link
Collaborator Author

ehmicky commented Jul 29, 2019

Yes sorry you're right. Still would need some feedback from @sindresorhus on this.

TooTallNate added a commit to vercel/fun that referenced this issue Oct 17, 2019
Also requires updating TypeScript to v3.4+
(See: sindresorhus/execa#336)
TooTallNate added a commit to vercel/vercel that referenced this issue Oct 18, 2019
Also requires updating TypeScript to v3.4+
(See: sindresorhus/execa#336)
TooTallNate added a commit to vercel/fun that referenced this issue Oct 23, 2019
Also requires updating TypeScript to v3.4+
(See: sindresorhus/execa#336)
TooTallNate added a commit to vercel/vercel that referenced this issue Nov 11, 2019
Also requires updating TypeScript to v3.4+
(See: sindresorhus/execa#336)
TooTallNate added a commit to vercel/vercel that referenced this issue Nov 11, 2019
* [now-cli] Update `execa` to v3.2.0

Also requires updating TypeScript to v3.4+
(See: sindresorhus/execa#336)

* Fix tests: code -> exitCode

* code -> exitCode

* More .code to .exitCode

* Update `@zeit/fun` to v0.10.3
@ehmicky
Copy link
Collaborator Author

ehmicky commented Mar 9, 2023

TypeScript 3.4 is old now, so we can close this.

@ehmicky ehmicky closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants