From ea516863191f3aed68854b4b53be2813eca715e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dudak?= Date: Mon, 29 Jan 2024 13:03:43 +0100 Subject: [PATCH] Publish @mui-internal/typescript-to-proptypes to npm --- .codesandbox/ci.json | 6 +- docs/package.json | 2 +- docs/scripts/formattedTSDemos.js | 5 +- package.json | 2 +- packages/typescript-to-proptypes/CHANGELOG.md | 176 +---------------- .../typescript-to-proptypes/CHANGELOG.old.md | 179 ++++++++++++++++++ packages/typescript-to-proptypes/README.md | 12 +- packages/typescript-to-proptypes/package.json | 36 ++-- .../src/getPropTypesFromFile.ts | 4 +- .../tsconfig.build.json | 15 ++ .../typescript-to-proptypes/tsconfig.json | 14 +- pnpm-lock.yaml | 14 +- scripts/generateProptypes.ts | 2 +- tsconfig.json | 2 +- webpackBaseConfig.js | 5 +- 15 files changed, 260 insertions(+), 214 deletions(-) create mode 100644 packages/typescript-to-proptypes/CHANGELOG.old.md create mode 100644 packages/typescript-to-proptypes/tsconfig.build.json diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json index 04e30677f9fb1c..c086cfc1cc843a 100644 --- a/.codesandbox/ci.json +++ b/.codesandbox/ci.json @@ -19,7 +19,8 @@ "packages/mui-system", "packages/mui-types", "packages/mui-utils", - "packages/docs-utils" + "packages/docs-utils", + "packages/typescript-to-proptypes" ], "publishDirectory": { "@mui/base": "packages/mui-base/build", @@ -38,7 +39,8 @@ "@mui/system": "packages/mui-system/build", "@mui/types": "packages/mui-types/build", "@mui/utils": "packages/mui-utils/build", - "@mui-internal/docs-utils": "packages/docs-utils" + "@mui-internal/docs-utils": "packages/docs-utils", + "@mui-internal/typescript-to-proptypes": "packages/typescript-to-proptypes" }, "sandboxes": [ "material-ui-issue-latest-s2dsx", diff --git a/docs/package.json b/docs/package.json index 445bb4edaea388..52445aab867592 100644 --- a/docs/package.json +++ b/docs/package.json @@ -119,6 +119,7 @@ "@babel/preset-typescript": "^7.23.3", "@mui-internal/docs-utils": "workspace:^", "@mui-internal/test-utils": "workspace:^", + "@mui-internal/typescript-to-proptypes": "workspace:^", "@types/autosuggest-highlight": "^3.2.3", "@types/chai": "^4.3.11", "@types/css-mediaquery": "^0.1.4", @@ -139,7 +140,6 @@ "playwright": "^1.41.1", "prettier": "^2.8.8", "tailwindcss": "^3.4.1", - "typescript-to-proptypes": "workspace:^", "yargs": "^17.7.2" } } diff --git a/docs/scripts/formattedTSDemos.js b/docs/scripts/formattedTSDemos.js index ebc2f5a1b9dc06..818bd67e6c4159 100644 --- a/docs/scripts/formattedTSDemos.js +++ b/docs/scripts/formattedTSDemos.js @@ -15,7 +15,10 @@ const path = require('path'); const fse = require('fs-extra'); const babel = require('@babel/core'); const prettier = require('prettier'); -const { getPropTypesFromFile, injectPropTypesInFile } = require('typescript-to-proptypes'); +const { + getPropTypesFromFile, + injectPropTypesInFile, +} = require('@mui-internal/typescript-to-proptypes'); const { createTypeScriptProjectBuilder, } = require('@mui-internal/api-docs-builder/utils/createTypeScriptProject'); diff --git a/package.json b/package.json index 529b97e2f2be42..86277485ebb7ac 100644 --- a/package.json +++ b/package.json @@ -104,6 +104,7 @@ "@mui-internal/api-docs-builder-core": "workspace:^", "@mui-internal/docs-utils": "workspace:^", "@mui-internal/test-utils": "workspace:^", + "@mui-internal/typescript-to-proptypes": "workspace:^", "@mui/joy": "workspace:*", "@mui/material": "workspace:^", "@mui/utils": "workspace:^", @@ -180,7 +181,6 @@ "tsx": "^4.7.0", "tsup": "^8.0.1", "typescript": "^5.3.3", - "typescript-to-proptypes": "workspace:^", "webpack": "^5.90.0", "webpack-bundle-analyzer": "^4.10.1", "webpack-cli": "^5.1.4", diff --git a/packages/typescript-to-proptypes/CHANGELOG.md b/packages/typescript-to-proptypes/CHANGELOG.md index 05bcc91e529f42..9a611104556b62 100644 --- a/packages/typescript-to-proptypes/CHANGELOG.md +++ b/packages/typescript-to-proptypes/CHANGELOG.md @@ -1,176 +1,10 @@ # Changelog -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +This file documents changes in the `@mui-internal/typescript-to-proptypes` package. +For changes before the package was forked, while it was and published as `typescript-to-proptypes`, see [CHANGELOG.old.md](./CHANGELOG.old.md). -## [2.0.1](https://github.com/merceyz/typescript-to-proptypes/compare/v2.0.0...v2.0.1) (2020-06-02) +Unfortunately changes done between forking the `typescript-to-proptypes` and publishing `@mui-internal/typescript-to-proptypes` are not documented. -### Bug Fixes +## 1.0.0 -- Use symbol type when there's no baseconstraint ([#23](https://github.com/merceyz/typescript-to-proptypes/issues/23)) ([0b170af](https://github.com/merceyz/typescript-to-proptypes/commit/0b170afb02a2edd1ea0b80406f1a86375c3a13f3)) - -## [2.0.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.5.0...v2.0.0) (2020-05-31) - -### ⚠ BREAKING CHANGES - -- Support for Node versions less than 10.3.0 has been dropped - -### Features - -- consider squashed call signatures of function components ([#20](https://github.com/merceyz/typescript-to-proptypes/issues/20)) ([514d8ed](https://github.com/merceyz/typescript-to-proptypes/commit/514d8ed55375406a70640d64c4a166aa52e24ae2)) - -### Bug Fixes - -- allow non-string literals ([#21](https://github.com/merceyz/typescript-to-proptypes/issues/21)) ([546e7ad](https://github.com/merceyz/typescript-to-proptypes/commit/546e7addc86198e641d3bfd3dd08ecb55c970600)) - -### Build System - -- drop support for node versions less than 10.3.0 ([2fbca64](https://github.com/merceyz/typescript-to-proptypes/commit/2fbca64e0964509e1a74d29f564be41a78e9fa29)) - -## [1.5.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.4.2...v1.5.0) (2020-04-06) - -### Features - -- **injector:** add reconcilePropTypes ([#10](https://github.com/merceyz/typescript-to-proptypes/issues/10)) ([7b0bff9](https://github.com/merceyz/typescript-to-proptypes/commit/7b0bff9666d1beb1bde445e92fbb702cf1fb3d89)) -- add `filenames` to component and proptype nodes ([#9](https://github.com/merceyz/typescript-to-proptypes/issues/9)) ([ce9a700](https://github.com/merceyz/typescript-to-proptypes/commit/ce9a7002c7fda27965b50e0b1af3ecef540a90e5)) -- **injector:** add `component` to `shouldInclude` ([#8](https://github.com/merceyz/typescript-to-proptypes/issues/8)) ([18a7fce](https://github.com/merceyz/typescript-to-proptypes/commit/18a7fcee1b3f7d64541fb0f9bd1de72e0ea0db5b)) -- **injector:** allow providing babel options ([2ab6f43](https://github.com/merceyz/typescript-to-proptypes/commit/2ab6f43ef4b785d20dd6f951b2f4b928a5521b53)) - -### Bug Fixes - -- check nodeType for dom elements ([#13](https://github.com/merceyz/typescript-to-proptypes/issues/13)) ([fd028e6](https://github.com/merceyz/typescript-to-proptypes/commit/fd028e639bb28383d6e4f925368b6e2afacdbf23)) -- replace existing propTypes when removeExistingPropTypes ([#15](https://github.com/merceyz/typescript-to-proptypes/issues/15)) ([3166104](https://github.com/merceyz/typescript-to-proptypes/commit/3166104889d4f58fc22f85800664d2bb1fce6aff)) -- **injector:** always call injectPropTypes to allow shouldInclude to run ([277258d](https://github.com/merceyz/typescript-to-proptypes/commit/277258ddc73c3da816aba6fccb739c69dfe8e83a)) -- handle all props getting ignored by shouldInclude ([b69112e](https://github.com/merceyz/typescript-to-proptypes/commit/b69112e1011f089b6d5cb60f88ce75b6394252be)) -- **parser:** export ParserOptions ([3a5d55e](https://github.com/merceyz/typescript-to-proptypes/commit/3a5d55e68a723208a4b76e79d4bafe92ddf4f85a)) - -## [1.4.2](https://github.com/merceyz/typescript-to-proptypes/compare/v1.4.1...v1.4.2) (2020-03-27) - -### Bug Fixes - -- build had a broken output ([97b0326](https://github.com/merceyz/typescript-to-proptypes/commit/97b0326c8b3b811fd5167cefa95a5dc1aa22a212)) - -## [1.4.1](https://github.com/merceyz/typescript-to-proptypes/compare/v1.4.0...v1.4.1) (2020-03-27) - -### Bug Fixes - -- include string literal object keys as used ([#5](https://github.com/merceyz/typescript-to-proptypes/issues/5)) ([3fd7b70](https://github.com/merceyz/typescript-to-proptypes/commit/3fd7b703d30e650e6692f87d3929d4ae67314cb6)) -- unknown can be optional ([#7](https://github.com/merceyz/typescript-to-proptypes/issues/7)) ([c5e8ca3](https://github.com/merceyz/typescript-to-proptypes/commit/c5e8ca31e2cae20216b1f7e45c9f3ef5198b2f93)) - -## [1.4.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.3.0...v1.4.0) (2019-11-16) - -### Bug Fixes - -- **parser:** handle prop of type ReactElement ([adfcca4](https://github.com/merceyz/typescript-to-proptypes/commit/adfcca4)) - -### Features - -- **parser:** support forwardRef ([3f5c0c9](https://github.com/merceyz/typescript-to-proptypes/commit/3f5c0c9)), closes [#2](https://github.com/merceyz/typescript-to-proptypes/issues/2) - -## [1.3.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.5...v1.3.0) (2019-09-03) - -### Features - -- **generator:** add comment to proptype blocks ([2c5627e](https://github.com/merceyz/typescript-to-proptypes/commit/2c5627e)) - -### [1.2.5](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.4...v1.2.5) (2019-09-03) - -### Bug Fixes - -- **parser:** use doctrine to unwrap comments ([53a9d43](https://github.com/merceyz/typescript-to-proptypes/commit/53a9d43)) - -### Tests - -- add missing test config ([d00c7f2](https://github.com/merceyz/typescript-to-proptypes/commit/d00c7f2)) - -## [1.2.4](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.3...v1.2.4) (2019-08-16) - -### Bug Fixes - -- **injector:** use require.resolve ([b9d04ea](https://github.com/merceyz/typescript-to-proptypes/commit/b9d04ea)) - -## [1.2.3](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.2...v1.2.3) (2019-07-24) - -### Bug Fixes - -- **parser:** handle return type of JSX.Element | null ([cbe5564](https://github.com/merceyz/typescript-to-proptypes/commit/cbe5564)) - -## [1.2.2](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.1...v1.2.2) (2019-07-23) - -### Bug Fixes - -- **parser:** remove leftover asterisk ([2e720df](https://github.com/merceyz/typescript-to-proptypes/commit/2e720df)) - -## [1.2.1](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.0...v1.2.1) (2019-07-23) - -### Bug Fixes - -- **parser:** handle single line comments ([0025d53](https://github.com/merceyz/typescript-to-proptypes/commit/0025d53)) - -## [1.2.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.1.0...v1.2.0) (2019-07-23) - -### Bug Fixes - -- **generator:** multiline comments ([d576597](https://github.com/merceyz/typescript-to-proptypes/commit/d576597)) -- **generator:** sort interface correctly ([f88c5fb](https://github.com/merceyz/typescript-to-proptypes/commit/f88c5fb)) -- **generator:** wrap prop name in quotes ([709a819](https://github.com/merceyz/typescript-to-proptypes/commit/709a819)) -- **parser:** don't modify comments ([95cd63e](https://github.com/merceyz/typescript-to-proptypes/commit/95cd63e)) -- **parser:** fallback to object if element is undefined ([eadaf3f](https://github.com/merceyz/typescript-to-proptypes/commit/eadaf3f)) -- **parser:** handle comments with just tags ([d0b0a82](https://github.com/merceyz/typescript-to-proptypes/commit/d0b0a82)) -- **parser:** handle comments with tags ([ad4dddd](https://github.com/merceyz/typescript-to-proptypes/commit/ad4dddd)) -- **parser:** handle optional any ([30f56ec](https://github.com/merceyz/typescript-to-proptypes/commit/30f56ec)) -- **parser:** handle optional React.ElementType ([c7a87fd](https://github.com/merceyz/typescript-to-proptypes/commit/c7a87fd)) -- **parser:** treat ComponentType as elementType ([53f1e21](https://github.com/merceyz/typescript-to-proptypes/commit/53f1e21)) -- export typescript as ts ([ba90e22](https://github.com/merceyz/typescript-to-proptypes/commit/ba90e22)) - -### Features - -- **generator:** support instanceOf ([6bd563a](https://github.com/merceyz/typescript-to-proptypes/commit/6bd563a)) -- **injector:** control included props ([4f8eaa1](https://github.com/merceyz/typescript-to-proptypes/commit/4f8eaa1)) -- **injector:** remove existing proptypes ([d2a978c](https://github.com/merceyz/typescript-to-proptypes/commit/d2a978c)) -- **parser:** check const declarations of React.ComponentType ([cbd2eb6](https://github.com/merceyz/typescript-to-proptypes/commit/cbd2eb6)) -- **parser:** handle React.Component and Element instanceOf ([570d73b](https://github.com/merceyz/typescript-to-proptypes/commit/570d73b)) -- **parser:** support elementType ([448d5a6](https://github.com/merceyz/typescript-to-proptypes/commit/448d5a6)) - -## [1.1.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.4...v1.1.0) (2019-07-15) - -### Bug Fixes - -- **generator:** don't pass shouldInclude on interfaceNode ([1302502](https://github.com/merceyz/typescript-to-proptypes/commit/1302502)) - -### Features - -- **parser:** circular references ([7de51cc](https://github.com/merceyz/typescript-to-proptypes/commit/7de51cc)) -- **parser:** control included proptypes ([2952e78](https://github.com/merceyz/typescript-to-proptypes/commit/2952e78)) -- **parser:** objects / shapes ([81f1a82](https://github.com/merceyz/typescript-to-proptypes/commit/81f1a82)) - -## [1.0.4](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.3...v1.0.4) (2019-07-10) - -### Bug Fixes - -- **generator:** omit null if proptype is optional ([21351a4](https://github.com/merceyz/typescript-to-proptypes/commit/21351a4)) -- **parser:** reactnode should make proptype optional ([c84b611](https://github.com/merceyz/typescript-to-proptypes/commit/c84b611)) - -## [1.0.3](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.2...v1.0.3) (2019-07-10) - -### Bug Fixes - -- export types ([7583291](https://github.com/merceyz/typescript-to-proptypes/commit/7583291)) - -## [1.0.2](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.1...v1.0.2) (2019-07-09) - -### Bug Fixes - -- **injector:** don't visit FunctionDeclarations more than once ([236276b](https://github.com/merceyz/typescript-to-proptypes/commit/236276b)) - -## [1.0.1](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.0...v1.0.1) (2019-07-09) - -### Bug Fixes - -- **injector:** don't import prop-types if it's already imported ([9d4dfd1](https://github.com/merceyz/typescript-to-proptypes/commit/9d4dfd1)) -- **injector:** insert import after the first one ([6cb31a0](https://github.com/merceyz/typescript-to-proptypes/commit/6cb31a0)) - -## 1.0.0 (2019-07-08) - -### Build System - -- disable incremental ([37b0277](https://github.com/merceyz/typescript-to-proptypes/commit/37b0277)) +Initial release as a `@mui-internal/typescript-to-proptypes` package. diff --git a/packages/typescript-to-proptypes/CHANGELOG.old.md b/packages/typescript-to-proptypes/CHANGELOG.old.md new file mode 100644 index 00000000000000..38d10c92ae4789 --- /dev/null +++ b/packages/typescript-to-proptypes/CHANGELOG.old.md @@ -0,0 +1,179 @@ +# Changelog + +This file documents changes in the @merceyz's `typescript-to-proptypes` package. +For changes after the package was forked and published as `@mui-internal/typescript-to-proptypes`, see [CHANGELOG.md](./CHANGELOG.md). + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [2.0.1](https://github.com/merceyz/typescript-to-proptypes/compare/v2.0.0...v2.0.1) (2020-06-02) + +### Bug Fixes + +- Use symbol type when there's no baseconstraint ([#23](https://github.com/merceyz/typescript-to-proptypes/issues/23)) ([0b170af](https://github.com/merceyz/typescript-to-proptypes/commit/0b170afb02a2edd1ea0b80406f1a86375c3a13f3)) + +## [2.0.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.5.0...v2.0.0) (2020-05-31) + +### ⚠ BREAKING CHANGES + +- Support for Node versions less than 10.3.0 has been dropped + +### Features + +- consider squashed call signatures of function components ([#20](https://github.com/merceyz/typescript-to-proptypes/issues/20)) ([514d8ed](https://github.com/merceyz/typescript-to-proptypes/commit/514d8ed55375406a70640d64c4a166aa52e24ae2)) + +### Bug Fixes + +- allow non-string literals ([#21](https://github.com/merceyz/typescript-to-proptypes/issues/21)) ([546e7ad](https://github.com/merceyz/typescript-to-proptypes/commit/546e7addc86198e641d3bfd3dd08ecb55c970600)) + +### Build System + +- drop support for node versions less than 10.3.0 ([2fbca64](https://github.com/merceyz/typescript-to-proptypes/commit/2fbca64e0964509e1a74d29f564be41a78e9fa29)) + +## [1.5.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.4.2...v1.5.0) (2020-04-06) + +### Features + +- **injector:** add reconcilePropTypes ([#10](https://github.com/merceyz/typescript-to-proptypes/issues/10)) ([7b0bff9](https://github.com/merceyz/typescript-to-proptypes/commit/7b0bff9666d1beb1bde445e92fbb702cf1fb3d89)) +- add `filenames` to component and proptype nodes ([#9](https://github.com/merceyz/typescript-to-proptypes/issues/9)) ([ce9a700](https://github.com/merceyz/typescript-to-proptypes/commit/ce9a7002c7fda27965b50e0b1af3ecef540a90e5)) +- **injector:** add `component` to `shouldInclude` ([#8](https://github.com/merceyz/typescript-to-proptypes/issues/8)) ([18a7fce](https://github.com/merceyz/typescript-to-proptypes/commit/18a7fcee1b3f7d64541fb0f9bd1de72e0ea0db5b)) +- **injector:** allow providing babel options ([2ab6f43](https://github.com/merceyz/typescript-to-proptypes/commit/2ab6f43ef4b785d20dd6f951b2f4b928a5521b53)) + +### Bug Fixes + +- check nodeType for dom elements ([#13](https://github.com/merceyz/typescript-to-proptypes/issues/13)) ([fd028e6](https://github.com/merceyz/typescript-to-proptypes/commit/fd028e639bb28383d6e4f925368b6e2afacdbf23)) +- replace existing propTypes when removeExistingPropTypes ([#15](https://github.com/merceyz/typescript-to-proptypes/issues/15)) ([3166104](https://github.com/merceyz/typescript-to-proptypes/commit/3166104889d4f58fc22f85800664d2bb1fce6aff)) +- **injector:** always call injectPropTypes to allow shouldInclude to run ([277258d](https://github.com/merceyz/typescript-to-proptypes/commit/277258ddc73c3da816aba6fccb739c69dfe8e83a)) +- handle all props getting ignored by shouldInclude ([b69112e](https://github.com/merceyz/typescript-to-proptypes/commit/b69112e1011f089b6d5cb60f88ce75b6394252be)) +- **parser:** export ParserOptions ([3a5d55e](https://github.com/merceyz/typescript-to-proptypes/commit/3a5d55e68a723208a4b76e79d4bafe92ddf4f85a)) + +## [1.4.2](https://github.com/merceyz/typescript-to-proptypes/compare/v1.4.1...v1.4.2) (2020-03-27) + +### Bug Fixes + +- build had a broken output ([97b0326](https://github.com/merceyz/typescript-to-proptypes/commit/97b0326c8b3b811fd5167cefa95a5dc1aa22a212)) + +## [1.4.1](https://github.com/merceyz/typescript-to-proptypes/compare/v1.4.0...v1.4.1) (2020-03-27) + +### Bug Fixes + +- include string literal object keys as used ([#5](https://github.com/merceyz/typescript-to-proptypes/issues/5)) ([3fd7b70](https://github.com/merceyz/typescript-to-proptypes/commit/3fd7b703d30e650e6692f87d3929d4ae67314cb6)) +- unknown can be optional ([#7](https://github.com/merceyz/typescript-to-proptypes/issues/7)) ([c5e8ca3](https://github.com/merceyz/typescript-to-proptypes/commit/c5e8ca31e2cae20216b1f7e45c9f3ef5198b2f93)) + +## [1.4.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.3.0...v1.4.0) (2019-11-16) + +### Bug Fixes + +- **parser:** handle prop of type ReactElement ([adfcca4](https://github.com/merceyz/typescript-to-proptypes/commit/adfcca4)) + +### Features + +- **parser:** support forwardRef ([3f5c0c9](https://github.com/merceyz/typescript-to-proptypes/commit/3f5c0c9)), closes [#2](https://github.com/merceyz/typescript-to-proptypes/issues/2) + +## [1.3.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.5...v1.3.0) (2019-09-03) + +### Features + +- **generator:** add comment to proptype blocks ([2c5627e](https://github.com/merceyz/typescript-to-proptypes/commit/2c5627e)) + +### [1.2.5](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.4...v1.2.5) (2019-09-03) + +### Bug Fixes + +- **parser:** use doctrine to unwrap comments ([53a9d43](https://github.com/merceyz/typescript-to-proptypes/commit/53a9d43)) + +### Tests + +- add missing test config ([d00c7f2](https://github.com/merceyz/typescript-to-proptypes/commit/d00c7f2)) + +## [1.2.4](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.3...v1.2.4) (2019-08-16) + +### Bug Fixes + +- **injector:** use require.resolve ([b9d04ea](https://github.com/merceyz/typescript-to-proptypes/commit/b9d04ea)) + +## [1.2.3](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.2...v1.2.3) (2019-07-24) + +### Bug Fixes + +- **parser:** handle return type of JSX.Element | null ([cbe5564](https://github.com/merceyz/typescript-to-proptypes/commit/cbe5564)) + +## [1.2.2](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.1...v1.2.2) (2019-07-23) + +### Bug Fixes + +- **parser:** remove leftover asterisk ([2e720df](https://github.com/merceyz/typescript-to-proptypes/commit/2e720df)) + +## [1.2.1](https://github.com/merceyz/typescript-to-proptypes/compare/v1.2.0...v1.2.1) (2019-07-23) + +### Bug Fixes + +- **parser:** handle single line comments ([0025d53](https://github.com/merceyz/typescript-to-proptypes/commit/0025d53)) + +## [1.2.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.1.0...v1.2.0) (2019-07-23) + +### Bug Fixes + +- **generator:** multiline comments ([d576597](https://github.com/merceyz/typescript-to-proptypes/commit/d576597)) +- **generator:** sort interface correctly ([f88c5fb](https://github.com/merceyz/typescript-to-proptypes/commit/f88c5fb)) +- **generator:** wrap prop name in quotes ([709a819](https://github.com/merceyz/typescript-to-proptypes/commit/709a819)) +- **parser:** don't modify comments ([95cd63e](https://github.com/merceyz/typescript-to-proptypes/commit/95cd63e)) +- **parser:** fallback to object if element is undefined ([eadaf3f](https://github.com/merceyz/typescript-to-proptypes/commit/eadaf3f)) +- **parser:** handle comments with just tags ([d0b0a82](https://github.com/merceyz/typescript-to-proptypes/commit/d0b0a82)) +- **parser:** handle comments with tags ([ad4dddd](https://github.com/merceyz/typescript-to-proptypes/commit/ad4dddd)) +- **parser:** handle optional any ([30f56ec](https://github.com/merceyz/typescript-to-proptypes/commit/30f56ec)) +- **parser:** handle optional React.ElementType ([c7a87fd](https://github.com/merceyz/typescript-to-proptypes/commit/c7a87fd)) +- **parser:** treat ComponentType as elementType ([53f1e21](https://github.com/merceyz/typescript-to-proptypes/commit/53f1e21)) +- export typescript as ts ([ba90e22](https://github.com/merceyz/typescript-to-proptypes/commit/ba90e22)) + +### Features + +- **generator:** support instanceOf ([6bd563a](https://github.com/merceyz/typescript-to-proptypes/commit/6bd563a)) +- **injector:** control included props ([4f8eaa1](https://github.com/merceyz/typescript-to-proptypes/commit/4f8eaa1)) +- **injector:** remove existing proptypes ([d2a978c](https://github.com/merceyz/typescript-to-proptypes/commit/d2a978c)) +- **parser:** check const declarations of React.ComponentType ([cbd2eb6](https://github.com/merceyz/typescript-to-proptypes/commit/cbd2eb6)) +- **parser:** handle React.Component and Element instanceOf ([570d73b](https://github.com/merceyz/typescript-to-proptypes/commit/570d73b)) +- **parser:** support elementType ([448d5a6](https://github.com/merceyz/typescript-to-proptypes/commit/448d5a6)) + +## [1.1.0](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.4...v1.1.0) (2019-07-15) + +### Bug Fixes + +- **generator:** don't pass shouldInclude on interfaceNode ([1302502](https://github.com/merceyz/typescript-to-proptypes/commit/1302502)) + +### Features + +- **parser:** circular references ([7de51cc](https://github.com/merceyz/typescript-to-proptypes/commit/7de51cc)) +- **parser:** control included proptypes ([2952e78](https://github.com/merceyz/typescript-to-proptypes/commit/2952e78)) +- **parser:** objects / shapes ([81f1a82](https://github.com/merceyz/typescript-to-proptypes/commit/81f1a82)) + +## [1.0.4](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.3...v1.0.4) (2019-07-10) + +### Bug Fixes + +- **generator:** omit null if proptype is optional ([21351a4](https://github.com/merceyz/typescript-to-proptypes/commit/21351a4)) +- **parser:** reactnode should make proptype optional ([c84b611](https://github.com/merceyz/typescript-to-proptypes/commit/c84b611)) + +## [1.0.3](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.2...v1.0.3) (2019-07-10) + +### Bug Fixes + +- export types ([7583291](https://github.com/merceyz/typescript-to-proptypes/commit/7583291)) + +## [1.0.2](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.1...v1.0.2) (2019-07-09) + +### Bug Fixes + +- **injector:** don't visit FunctionDeclarations more than once ([236276b](https://github.com/merceyz/typescript-to-proptypes/commit/236276b)) + +## [1.0.1](https://github.com/merceyz/typescript-to-proptypes/compare/v1.0.0...v1.0.1) (2019-07-09) + +### Bug Fixes + +- **injector:** don't import prop-types if it's already imported ([9d4dfd1](https://github.com/merceyz/typescript-to-proptypes/commit/9d4dfd1)) +- **injector:** insert import after the first one ([6cb31a0](https://github.com/merceyz/typescript-to-proptypes/commit/6cb31a0)) + +## 1.0.0 (2019-07-08) + +### Build System + +- disable incremental ([37b0277](https://github.com/merceyz/typescript-to-proptypes/commit/37b0277)) diff --git a/packages/typescript-to-proptypes/README.md b/packages/typescript-to-proptypes/README.md index 9e00c1692dadd0..4521bd893bca63 100644 --- a/packages/typescript-to-proptypes/README.md +++ b/packages/typescript-to-proptypes/README.md @@ -1,6 +1,9 @@ -# typescript-to-proptypes +# @mui-internal/typescript-to-proptypes -An API for converting [TypeScript](https://www.npmjs.com/package/typescript) definitions to [PropTypes](https://www.npmjs.com/package/prop-types) using the TypeScript Compiler API +An API for converting [TypeScript](https://www.npmjs.com/package/typescript) definitions to [PropTypes](https://www.npmjs.com/package/prop-types) using the TypeScript Compiler API. + +This package has been adapted for MUI needs. +It is not meant for general use. ## Support @@ -15,3 +18,8 @@ An API for converting [TypeScript](https://www.npmjs.com/package/typescript) def ## License This project is licensed under the terms of the [MIT license](/LICENSE). + +## Release + +1. Build the project: `pnpm build` +2. Publish the build artifacts to npm: `pnpm release:publish` diff --git a/packages/typescript-to-proptypes/package.json b/packages/typescript-to-proptypes/package.json index 6146ecaeedb2e1..1dd15c859acf5b 100644 --- a/packages/typescript-to-proptypes/package.json +++ b/packages/typescript-to-proptypes/package.json @@ -1,32 +1,34 @@ { - "name": "typescript-to-proptypes", - "version": "5.0.0", - "private": true, - "description": "Generate proptypes from TypeScript declarations", + "name": "@mui-internal/typescript-to-proptypes", + "version": "1.0.0", + "author": "MUI Team", + "description": "Generate proptypes from TypeScript declarations. This is a fork of the typescript-to-proptypes package adapted for MUI needs. This is an internal package not meant for general use.", + "main": "build/index.js", + "exports": { + ".": "./build/index.js" + }, + "types": "./build/index.d.ts", "repository": { "type": "git", "url": "https://github.com/mui/material-ui.git", "directory": "packages/typescript-to-proptypes" }, - "main": "src/index.ts", - "author": "merceyz ", "license": "MIT", - "keywords": [ - "proptypes", - "typescript", - "react" - ], "scripts": { + "prepublish": "rimraf ./build", + "build": "tsc -b tsconfig.build.json", + "release:publish": "pnpm publish --tag latest", + "release:publish:dry-run": "pnpm publish --tag latest --registry=\"http://localhost:4873/\"", "test": "cd ../../ && cross-env NODE_ENV=test mocha --config packages/typescript-to-proptypes/.mocharc.js 'packages/typescript-to-proptypes/**/*.test.ts'", - "typescript": "tsc -p tsconfig.json" + "typescript": "tsc -b tsconfig.json" }, "dependencies": { - "@babel/core": "^7.23.9", + "@babel/core": "^7.23.7", "@babel/plugin-syntax-class-properties": "^7.12.13", "@babel/plugin-syntax-jsx": "^7.23.3", "@babel/plugin-syntax-typescript": "^7.23.3", - "@babel/types": "^7.23.9", - "@mui-internal/api-docs-builder": "workspace:*", + "@babel/types": "^7.23.6", + "@mui-internal/docs-utils": "workspace:*", "doctrine": "^3.0.0", "lodash": "^4.17.21", "typescript": "^5.3.3", @@ -38,10 +40,10 @@ "@types/chai": "^4.3.11", "@types/doctrine": "^0.0.9", "@types/lodash": "^4.14.202", - "@types/node": "^18.19.10", + "@types/node": "^18.19.8", "@types/prettier": "^2.7.3", "@types/react": "^18.2.48", - "@types/uuid": "^9.0.8", + "@types/uuid": "^9.0.7", "chai": "^4.4.1", "fast-glob": "^3.3.2", "prettier": "^2.8.8", diff --git a/packages/typescript-to-proptypes/src/getPropTypesFromFile.ts b/packages/typescript-to-proptypes/src/getPropTypesFromFile.ts index 04214f5ca1290b..faecb397b603a4 100644 --- a/packages/typescript-to-proptypes/src/getPropTypesFromFile.ts +++ b/packages/typescript-to-proptypes/src/getPropTypesFromFile.ts @@ -3,8 +3,8 @@ import * as doctrine from 'doctrine'; import { GetPropsFromComponentDeclarationOptions, getPropsFromComponentNode, -} from '@mui-internal/api-docs-builder/utils/getPropsFromComponentNode'; -import { TypeScriptProject } from '@mui-internal/api-docs-builder/utils/createTypeScriptProject'; + TypeScriptProject, +} from '@mui-internal/docs-utils'; import { createUnionType, createUndefinedType, diff --git a/packages/typescript-to-proptypes/tsconfig.build.json b/packages/typescript-to-proptypes/tsconfig.build.json new file mode 100644 index 00000000000000..8992c3d55a7be0 --- /dev/null +++ b/packages/typescript-to-proptypes/tsconfig.build.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./build", + "declaration": true, + "noEmit": false, + "composite": true, + "tsBuildInfoFile": "./build/.tsbuildinfo", + "target": "ES2020", + "module": "commonjs", + "types": ["node"] + }, + "exclude": ["./test/*.ts"] +} diff --git a/packages/typescript-to-proptypes/tsconfig.json b/packages/typescript-to-proptypes/tsconfig.json index 9a70107eff7e6c..9939012a1f603f 100644 --- a/packages/typescript-to-proptypes/tsconfig.json +++ b/packages/typescript-to-proptypes/tsconfig.json @@ -1,12 +1,12 @@ { "compilerOptions": { - "module": "commonjs", - "esModuleInterop": true, - "lib": ["ES2018"], - "strict": true, + "noEmit": true, "moduleResolution": "node", - "types": ["node"], - "noEmit": true + "types": ["node", "mocha"], + "strict": true, + "esModuleInterop": true, + "isolatedModules": true }, - "include": ["src"] + "include": ["./src/*.ts", "./test/*.ts"], + "references": [{ "path": "../docs-utils/tsconfig.build.json" }] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6ec0447f53a22a..7379218aebf565 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -101,6 +101,9 @@ importers: '@mui-internal/test-utils': specifier: workspace:^ version: link:packages/test-utils + '@mui-internal/typescript-to-proptypes': + specifier: workspace:^ + version: link:packages/typescript-to-proptypes '@mui/joy': specifier: workspace:* version: link:packages/mui-joy/build @@ -329,9 +332,6 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 - typescript-to-proptypes: - specifier: workspace:^ - version: link:packages/typescript-to-proptypes webpack: specifier: ^5.90.0 version: 5.90.0(esbuild@0.19.11)(webpack-cli@5.1.4) @@ -836,6 +836,9 @@ importers: '@mui-internal/test-utils': specifier: workspace:^ version: link:../packages/test-utils + '@mui-internal/typescript-to-proptypes': + specifier: workspace:^ + version: link:../packages/typescript-to-proptypes '@types/autosuggest-highlight': specifier: ^3.2.3 version: 3.2.3 @@ -896,9 +899,6 @@ importers: tailwindcss: specifier: ^3.4.1 version: 3.4.1 - typescript-to-proptypes: - specifier: workspace:^ - version: link:../packages/typescript-to-proptypes yargs: specifier: ^17.7.2 version: 17.7.2 @@ -2293,7 +2293,7 @@ importers: specifier: ^18.2.48 version: 18.2.48 '@types/uuid': - specifier: ^9.0.8 + specifier: ^9.0.7 version: 9.0.8 chai: specifier: ^4.4.1 diff --git a/scripts/generateProptypes.ts b/scripts/generateProptypes.ts index ee997a89b83863..aa9d7d63766a14 100644 --- a/scripts/generateProptypes.ts +++ b/scripts/generateProptypes.ts @@ -15,7 +15,7 @@ import { getPropTypesFromFile, injectPropTypesInFile, InjectPropTypesInFileOptions, -} from 'typescript-to-proptypes'; +} from '@mui-internal/typescript-to-proptypes'; import { createTypeScriptProjectBuilder, TypeScriptProject, diff --git a/tsconfig.json b/tsconfig.json index f9346d8a8e44e9..991d9c8a764455 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -52,7 +52,7 @@ "@mui/zero-vite-plugin": ["./packages/zero-vite-plugin/src"], "@mui/zero-vite-plugin/*": ["./packages/zero-vite-plugin/src/*"], "@mui-internal/docs-utils": ["./packages/docs-utils/src"], - "typescript-to-proptypes": ["./packages/typescript-to-proptypes/src"] + "@mui-internal/typescript-to-proptypes": ["./packages/typescript-to-proptypes/src"] }, // Otherwise we get react-native typings which conflict with dom.lib. "types": ["node", "react"] diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index a1aebe9d413871..ac26167c3cabd7 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -26,7 +26,10 @@ module.exports = { '@mui/joy': path.resolve(__dirname, './packages/mui-joy/src'), '@mui/zero-runtime': path.resolve(__dirname, './packages/zero-runtime/src'), '@mui-internal/docs-utils': path.resolve(__dirname, './packages/docs-utils/src'), - 'typescript-to-proptypes': path.resolve(__dirname, './packages/typescript-to-proptypes/src'), + '@mui-internal/typescript-to-proptypes': path.resolve( + __dirname, + './packages/typescript-to-proptypes/src', + ), docs: path.resolve(__dirname, './docs'), }, extensions: ['.js', '.ts', '.tsx', '.d.ts'],