From ed3b5ac018ac4288d8e27b4a218f5c1ad8cb4550 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 15 Apr 2020 20:47:16 -0400 Subject: [PATCH] Proof of concept TypeScript theme support with auto-generated human readable js --- .../docusaurus-theme-classic/babel.config.js | 10 ++++++++ .../docusaurus-theme-classic/package.json | 6 +++++ .../src/theme/{NotFound.js => NotFound.tsx} | 4 ++-- yarn.lock | 23 ++++++++++++++++++- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 packages/docusaurus-theme-classic/babel.config.js rename packages/docusaurus-theme-classic/src/theme/{NotFound.js => NotFound.tsx} (90%) diff --git a/packages/docusaurus-theme-classic/babel.config.js b/packages/docusaurus-theme-classic/babel.config.js new file mode 100644 index 000000000000..a6b570f38777 --- /dev/null +++ b/packages/docusaurus-theme-classic/babel.config.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +module.exports = { + presets: [['@babel/preset-typescript', {isTSX: true, allExtensions: true}]], +}; diff --git a/packages/docusaurus-theme-classic/package.json b/packages/docusaurus-theme-classic/package.json index 45f8da069513..00695269440f 100644 --- a/packages/docusaurus-theme-classic/package.json +++ b/packages/docusaurus-theme-classic/package.json @@ -27,5 +27,11 @@ }, "engines": { "node": ">=10.9.0" + }, + "scripts": { + "strip-ts-types": "babel src -d lib --extensions '.tsx'" + }, + "devDependencies": { + "@babel/cli": "^7.8.4" } } diff --git a/packages/docusaurus-theme-classic/src/theme/NotFound.js b/packages/docusaurus-theme-classic/src/theme/NotFound.tsx similarity index 90% rename from packages/docusaurus-theme-classic/src/theme/NotFound.js rename to packages/docusaurus-theme-classic/src/theme/NotFound.tsx index 955f51e2b4f7..4b7b8ff01e27 100644 --- a/packages/docusaurus-theme-classic/src/theme/NotFound.js +++ b/packages/docusaurus-theme-classic/src/theme/NotFound.tsx @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -import React from 'react'; +import React, {ReactElement} from 'react'; import Layout from '@theme/Layout'; -function NotFound() { +function NotFound(): ReactElement { return (
diff --git a/yarn.lock b/yarn.lock index 236513bed4ea..c7ad096f9235 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,22 @@ # yarn lockfile v1 +"@babel/cli@^7.8.4": + version "7.8.4" + resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.8.4.tgz#505fb053721a98777b2b175323ea4f090b7d3c1c" + integrity sha512-XXLgAm6LBbaNxaGhMAznXXaxtCWfuv6PIDJ9Alsy9JYTOh+j2jJz+L/162kkfU1j/pTSxK1xGmlwI4pdIMkoag== + dependencies: + commander "^4.0.1" + convert-source-map "^1.1.0" + fs-readdir-recursive "^1.1.0" + glob "^7.0.0" + lodash "^4.17.13" + make-dir "^2.1.0" + slash "^2.0.0" + source-map "^0.5.0" + optionalDependencies: + chokidar "^2.1.8" + "@babel/code-frame@7.5.5": version "7.5.5" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.5.5.tgz#bc0782f6d69f7b7d49531219699b988f669a8f9d" @@ -5153,7 +5169,7 @@ conventional-recommended-bump@^5.0.0: meow "^4.0.0" q "^1.5.1" -convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0: +convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA== @@ -7459,6 +7475,11 @@ fs-minipass@^2.0.0: dependencies: minipass "^3.0.0" +fs-readdir-recursive@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" + integrity sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA== + fs-write-stream-atomic@^1.0.8: version "1.0.10" resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9"