-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite
MergeParameters
to work with TS 4.9
Per microsoft/TypeScript#50831 , the existing implementation of `MergeParameters` broke with TS 49 due to a change in how "optional" and "undefined" arguments get interpreted Anders Hjelsberg himself supplied a new implementation that's actually much simpler, but only works with TS 4.7 and greater. Normally this would require shipping two entirely different sets of types, as we already do for TS <4.1. However, there's a trick we used with RTK where we: - Create a folder and put two different files with different impls of the same type inside - Add an index file and re-export one of those - Add a file named `package.dist.json` containing `typesVersions` that points to both of those `.d.ts` files - Copy that `package.dist.json` over to `dist/some/package.json` during the actual build/publish step That way during dev TS just imports the type as normal, but the built version sees that `some/package.json`, sees `typesVersions`, finds the right `.d.ts` file, and imports the right implementation for itself.
- Loading branch information
1 parent
5b83d04
commit 11ed107
Showing
11 changed files
with
298 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { MergeParameters } from './ts47-mergeParameters' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"typesVersions": { | ||
">=4.7": { | ||
"index": [ | ||
"./ts47-mergeParameters.d.ts" | ||
] | ||
}, | ||
"<4.7": { | ||
"index": [ | ||
"./ts46-mergeParameters.d.ts" | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.