execa
execa copied to clipboard
TypeScript `<3.4` support
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?
- Do nothing
- Add a
typesVersionsfield to declare that we only support>=3.4 - Add a second fallback
index.d.tsfor lower versions, and use thetypesVersionsfield to distinguish it.
Do nothing.
typeVersions is meant to add fallbacks.
Is there a way for us to document our minimal TypeScript supported version?
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.
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.
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.
👍
Issue at https://github.com/microsoft/TypeScript/issues/32166
Let's see what happens there first.
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.
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 https://github.com/microsoft/TypeScript/issues/32166#issuecomment-506851601 sounds like another way. Having empty notsupported.d.ts is just close enough to having an untyped package.
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.
No, I mean for example this line ...
https://github.com/sindresorhus/execa/blob/071a8154f882d13116a6a91d8691ea150de31753/index.d.ts#L116
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.
Yes sorry you're right. Still would need some feedback from @sindresorhus on this.
TypeScript 3.4 is old now, so we can close this.