8000 Simplify typescript definition files (#1854) · immutable-js/immutable-js@351f9e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 351f9e6

Browse files
authored
Simplify typescript definition files (#1854)
This removes the build step which converts an "ambient" type definition file into a "non-ambient" one. Since our local tests all run against the source file, this ensures the tested file is exactly the same as the exported one, and updates the exports to support all "UMD" use cases, both ambient (sourced file with a `/// <reference>` and non-ambient module exports. As a result, we no longer need to explicity mark each type within the exported module I'm ~90% sure this is the correct way to set up the module and UMD exports, but would be very happy to have a second set of eyes on this. This also changes the upper-case source files to lower-case so they can be directly copied during build. Tested by creating a new vanilla typescript project and importing the built npm directory and tested a bunch of imports of Immutable to ensure the types were being correctly referenced.
1 parent e80d8fa commit 351f9e6

File tree

9 files changed

+168
-209
lines changed

9 files changed

+168
-209
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ Range(1, Infinity)
618618

619619
[Read the docs](https://immutable-js.com) and eat your vegetables.
620620

621-
Docs are automatically generated from [Immutable.d.ts](https://github.com/immutable-js/immutable-js/blob/main/type-definitions/Immutable.d.ts).
621+
Docs are automatically generated from [immutable.d.ts](https://github.com/immutable-js/immutable-js/blob/main/type-definitions/immutable.d.ts).
622622
Please contribute!
623623

624624
Also, don't miss the [Wiki](https://github.com/immutable-js/immutable-js/wiki) which

__tests__/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"target": "esnext",
88
"moduleResolution": "node",
99
"paths": {
10-
"immutable": ["../type-definitions/Immutable.d.ts"],
10+
"immutable": ["../type-definitions/immutable.d.ts"],
1111
"jasmine-check": ["../resources/jasmine-check.d.ts"]
1212
}
1313
}

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
"main": "dist/immutable.js",
1919
"module": "dist/immutable.es.js",
2020
"sideEffects": false,
21-
"typings": "dist/immutable-nonambient.d.ts",
22-
"typescript": {
23-
"definition": "dist/immutable.d.ts"
24-
},
21+
"types": "dist/immutable.d.ts",
2522
"publishKeys": [
2623
"name",
2724
"version",
@@ -34,8 +31,7 @@
3431
"main",
3532
"module",
3633
"sideEffects",
37-
"typings",
38-
"typescript",
34+
"types",
3935
"files",
4036
"keywords"
4137
],
@@ -48,7 +44,7 @@
4844
"clean:dist": "rimraf dist",
4945
"bundle:dist": "rollup -c ./resources/rollup-config.js",
5046
"bundle:es": "rollup -c ./resources/rollup-config-es.js",
51-
"copy:dist": "node ./resources/copy-dist-typedefs.js",
47+
"copy:dist": "cp ./type-definitions/immutable.* dist",
5248
"stats:dist": "node ./resources/dist-stats.js",
5349
"prepare:dist": "./resources/prepare-dist.sh",
5450
"format": "npm run lint:format -- --write",

resources/copy-dist-typedefs.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0