Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to TypeScript v5.2 #6476

Merged
merged 17 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions config/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
{
"version": "4.5.4",
"version": "5.2.2",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"importHelpers": true,
"importsNotUsedAsValues": "error",
"jsx": "react",
"lib": ["dom", "dom.iterable", "es5", "es2015.collection", "es2015.iterable"],
"module": "es2020",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
Expand All @@ -21,7 +16,7 @@
"sourceMap": true,
"strict": true,
"stripInternal": true,
"target": "es5",
"typeRoots": ["../node_modules/@types"]
"typeRoots": ["../node_modules/@types"],
"verbatimModuleSyntax": true
}
}
11 changes: 11 additions & 0 deletions config/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.base",
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"lib": ["ES2015"],
"module": "node16",
"moduleResolution": "node16",
"target": "ES2015",
"verbatimModuleSyntax": false
}
}
10 changes: 10 additions & 0 deletions config/tsconfig.web.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.base",
"compilerOptions": {
"jsx": "react",
"lib": ["dom", "dom.iterable", "es5", "es2015.collection", "es2015.iterable"],
"module": "es2020",
"moduleResolution": "node",
"target": "es5"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"sinon": "^17.0.0",
"stylelint-config-palantir": "^6.0.1",
"stylelint-scss": "^5.2.1",
"typescript": "~4.9.5",
"typescript": "~5.2.2",
"yargs": "^17.7.2",
"yarn-deduplicate": "^6.0.2"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/colors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"clean": "rm -rf lib/*",
"compile": "run-p \"compile:*\"",
"compile:esm": "tsc -p ./src",
"compile:cjs": "tsc -p ./src -m commonjs --outDir lib/cjs",
"compile:cjs": "tsc -p ./src -m commonjs --verbatimModuleSyntax false --outDir lib/cjs",
"compile:esnext": "tsc -p ./src -t esnext --outDir lib/esnext",
"compile:css": "sass-compile ./src",
"compile:css-colors": "generate-css-variables --retainDefault true --outputFileName colors _colors.scss",
Expand All @@ -26,12 +26,12 @@
"verify": "npm-run-all compile -p dist lint"
},
"dependencies": {
"tslib": "~2.5.0"
"tslib": "~2.6.2"
},
"devDependencies": {
"@blueprintjs/node-build-scripts": "^8.0.4",
"mocha": "^10.2.0",
"typescript": "~4.9.5"
"typescript": "~5.2.2"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/colors/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../config/tsconfig.base",
"extends": "../../../config/tsconfig.web",
"compilerOptions": {
"outDir": "../lib/esm"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"clean": "rm -rf dist/* && rm -rf lib/*",
"compile": "run-p \"compile:*\"",
"compile:esm": "tsc -p ./src",
"compile:cjs": "tsc -p ./src -m commonjs --outDir lib/cjs",
"compile:cjs": "tsc -p ./src -m commonjs --verbatimModuleSyntax false --outDir lib/cjs",
"compile:esnext": "tsc -p ./src -t esnext --outDir lib/esnext",
"compile:css": "sass-compile ./src",
"dev": "run-p \"compile:esm -- --watch\" \"compile:css -- --watch\"",
Expand Down Expand Up @@ -56,7 +56,7 @@
"normalize.css": "^8.0.1",
"react-popper": "^2.3.0",
"react-transition-group": "^4.4.5",
"tslib": "~2.5.0"
"tslib": "~2.6.2"
},
"peerDependencies": {
"@types/react": "^16.14.32 || 17 || 18",
Expand All @@ -80,7 +80,7 @@
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-test-renderer": "^16.14.0",
"typescript": "~4.9.5",
"typescript": "~5.2.2",
"webpack-cli": "^5.0.1"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../config/tsconfig.base",
"extends": "../../../config/tsconfig.web",
"compilerOptions": {
"outDir": "../lib/esm"
}
Expand Down
1 change: 0 additions & 1 deletion packages/core/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"declaration": false,
"downlevelIteration": true,
"lib": ["dom", "dom.iterable", "es5", "es2015.collection", "es2015.iterable", "es2015.promise"],
"module": "commonjs",
"noEmit": true
}
}
6 changes: 3 additions & 3 deletions packages/datetime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"clean": "rm -rf dist/* && rm -rf lib/*",
"compile": "run-p \"compile:*\"",
"compile:esm": "tsc -p ./src",
"compile:cjs": "tsc -p ./src -m commonjs --outDir lib/cjs",
"compile:cjs": "tsc -p ./src -m commonjs --verbatimModuleSyntax false --outDir lib/cjs",
"compile:esnext": "tsc -p ./src -t esnext --outDir lib/esnext",
"compile:css": "sass-compile ./src",
"dev": "run-p \"compile:esm -- --watch\" \"compile:css -- --watch\"",
Expand Down Expand Up @@ -48,7 +48,7 @@
"date-fns-tz": "^2.0.0",
"lodash": "^4.17.21",
"react-day-picker": "7.4.9",
"tslib": "~2.5.0"
"tslib": "~2.6.2"
},
"peerDependencies": {
"@types/react": "^16.14.32 || 17",
Expand All @@ -73,7 +73,7 @@
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-test-renderer": "^16.14.0",
"typescript": "~4.9.5",
"typescript": "~5.2.2",
"webpack-cli": "^5.0.1"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/datetime/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../config/tsconfig.base",
"extends": "../../../config/tsconfig.web",
"compilerOptions": {
"outDir": "../lib/esm",
"strictNullChecks": false
Expand Down
1 change: 0 additions & 1 deletion packages/datetime/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../src/tsconfig",
"compilerOptions": {
"declaration": false,
"module": "commonjs",
"noEmit": true
}
}
6 changes: 3 additions & 3 deletions packages/datetime2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"clean": "rm -rf dist/* && rm -rf lib/*",
"compile": "run-p \"compile:*\"",
"compile:esm": "tsc -p ./src",
"compile:cjs": "tsc -p ./src -m commonjs --outDir lib/cjs",
"compile:cjs": "tsc -p ./src -m commonjs --verbatimModuleSyntax false --outDir lib/cjs",
"compile:esnext": "tsc -p ./src -t esnext --outDir lib/esnext",
"compile:css": "sass-compile ./src",
"dev": "run-p \"compile:esm -- --watch\" \"compile:css -- --watch\"",
Expand All @@ -43,7 +43,7 @@
"date-fns": "^2.28.0",
"react-day-picker": "^8.5.1",
"react-innertext": "^1.1.5",
"tslib": "~2.5.0"
"tslib": "~2.6.2"
},
"peerDependencies": {
"@types/react": "^16.14.32 || 17 || 18",
Expand All @@ -67,7 +67,7 @@
"npm-run-all": "^4.1.5",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"typescript": "~4.9.5",
"typescript": "~5.2.2",
"webpack-cli": "^5.0.1"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/datetime2/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../config/tsconfig.base",
"extends": "../../../config/tsconfig.web",
"compilerOptions": {
"module": "es2020",
"outDir": "../lib/esm"
Expand Down
1 change: 0 additions & 1 deletion packages/datetime2/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../src/tsconfig",
"compilerOptions": {
"declaration": false,
"module": "commonjs",
"noEmit": true
}
}
2 changes: 1 addition & 1 deletion packages/demo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-transition-group": "^4.4.5",
"tslib": "~2.5.0"
"tslib": "~2.6.2"
},
"devDependencies": {
"@blueprintjs/node-build-scripts": "^8.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/demo-app/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../config/tsconfig.base.json",
"extends": "../../../config/tsconfig.web.json",
"compilerOptions": {
"declaration": false,
"lib": ["dom", "es5", "es6"],
Expand Down
4 changes: 2 additions & 2 deletions packages/docs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@blueprintjs/select": "^5.0.16",
"@blueprintjs/table": "^5.0.16",
"@blueprintjs/test-commons": "^2.1.2",
"@documentalist/client": "^4.0.0",
"@documentalist/client": "^5.0.0",
"chroma-js": "^2.4.2",
"classnames": "^2.3.1",
"date-fns": "^2.28.0",
Expand All @@ -41,7 +41,7 @@
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-transition-group": "^4.4.5",
"tslib": "~2.5.0"
"tslib": "~2.6.2"
},
"devDependencies": {
"@blueprintjs/node-build-scripts": "^8.0.4",
Expand Down
10 changes: 5 additions & 5 deletions packages/docs-app/src/components/blueprintDocs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { type IHeadingNode, type IPageData, isPageNode, type ITsDocBase } from "@documentalist/client";
import { type HeadingNode, isPageNode, type PageData, type TsDocBase } from "@documentalist/client";
import classNames from "classnames";
import * as React from "react";

Expand Down Expand Up @@ -45,7 +45,7 @@ const COMPONENTS_PATTERN = /\/components(\.[\w-]+)?$/;
const CONTEXT_PATTERN = /\/context(\.[\w-]+)?$/;
const HOOKS_PATTERN = /\/hooks(\.[\w-]+)?$/;
const LEGACY_PATTERN = /\/legacy(\.[\w-]+)?$/;
const isNavSection = ({ route }: IHeadingNode) =>
const isNavSection = ({ route }: HeadingNode) =>
COMPONENTS_PATTERN.test(route) ||
CONTEXT_PATTERN.test(route) ||
HOOKS_PATTERN.test(route) ||
Expand Down Expand Up @@ -94,7 +94,7 @@ export class BlueprintDocs extends React.Component<BlueprintDocsProps, { themeNa
onToggleDark={this.handleToggleDark}
useDarkTheme={this.state.themeName === DARK_THEME}
useNextVersion={this.props.useNextVersion}
packageData={this.getNpmPackage("@blueprintjs/core")}
packageInfo={this.getNpmPackage("@blueprintjs/core")}
/>
);
return (
Expand Down Expand Up @@ -140,7 +140,7 @@ export class BlueprintDocs extends React.Component<BlueprintDocsProps, { themeNa
return <NavMenuItem {...props} />;
};

private renderPageActions = (page: IPageData) => {
private renderPageActions = (page: PageData) => {
return (
<AnchorButton
href={`${GITHUB_SOURCE_URL}/${page.sourcePath}`}
Expand Down Expand Up @@ -178,7 +178,7 @@ export class BlueprintDocs extends React.Component<BlueprintDocsProps, { themeNa
);
}

private renderViewSourceLinkText = (entry: ITsDocBase) => {
private renderViewSourceLinkText = (entry: TsDocBase) => {
return `@blueprintjs/${entry.fileName.split("/", 2)[1]}`;
};

Expand Down
6 changes: 3 additions & 3 deletions packages/docs-app/src/components/navHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { INpmPackage } from "@documentalist/client";
import type { NpmPackageInfo } from "@documentalist/client";
import * as React from "react";

import { Classes, HotkeysTarget2, type Intent, Menu, MenuItem, NavbarHeading, Popover, Tag } from "@blueprintjs/core";
Expand All @@ -26,7 +26,7 @@ export interface NavHeaderProps {
onToggleDark: (useDark: boolean) => void;
useDarkTheme: boolean;
useNextVersion: boolean;
packageData: INpmPackage;
packageInfo: NpmPackageInfo;
}

export class NavHeader extends React.PureComponent<NavHeaderProps> {
Expand Down Expand Up @@ -75,7 +75,7 @@ export class NavHeader extends React.PureComponent<NavHeaderProps> {

private renderVersionsMenu() {
const { useNextVersion } = this.props;
const { version, nextVersion, versions } = this.props.packageData;
const { version, nextVersion, versions } = this.props.packageInfo;
if (versions.length === 1) {
return <div className={Classes.TEXT_MUTED}>v{versions[0]}</div>;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docs-app/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../config/tsconfig.base.json",
"extends": "../../../config/tsconfig.web.json",
"compilerOptions": {
"declaration": false,
"lib": ["dom", "es5", "es6"],
Expand Down
31 changes: 23 additions & 8 deletions packages/docs-data/compile-docs-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ import semver from "semver";

import { Classes } from "@blueprintjs/core";

import { markedRenderer } from "./markdownRenderer.mjs";
import { hooks, markedRenderer } from "./markdownRenderer.mjs";

/** Run Documentalist on Sass, TypeScript, and package.json files in these packages */
const LIBRARY_PACKAGES = ["core", "datetime", "datetime2", "icons", "select", "table"];

/** This package is expected to have the markdown "navPage" */
const DOCS_PACKAGE = "docs-app";

/** Run Documentalist on Markdown files in these packages */
const LIBRARY_AND_DOCS_PACKAGES = [...LIBRARY_PACKAGES, DOCS_PACKAGE];

console.info(`[docs-data] compiling documentation for library packages: ${LIBRARY_PACKAGES.join(", ")}`);

// assume we are running from packages/docs-app
const monorepoRootDir = resolve(cwd(), "../../");
Expand All @@ -41,7 +52,10 @@ console.info(`[docs-data] successfully generated docs.json`);
*/
async function generateDocumentalistData() {
const documentalist = new Documentalist({
markdown: { renderer: markedRenderer },
markdown: {
renderer: markedRenderer,
hooks,
},
sourceBaseDir: monorepoRootDir,
// must mark our @Decorator APIs as reserved so we can use them in code samples
reservedTags: ["import", "ContextMenuTarget", "HotkeysTarget", "param", "returns"],
Expand All @@ -56,18 +70,19 @@ async function generateDocumentalistData() {
.use(
/\.tsx?$/,
new TypescriptPlugin({
excludeNames: [/I.+State$/],
excludePaths: ["node_modules/", "-app/", "test-commons/", "-build-scripts/"],
tsconfigPath: resolve(monorepoRootDir, "./config/tsconfig.base.json"),
excludeNames: [/.+State$/],
excludePaths: ["node_modules/", "-app/", "test-commons/", "-build-scripts/", "test/"],
verbose: true,
}),
)
.use(".scss", new KssPlugin())
.use("package.json", new NpmPlugin());

const docs = await documentalist.documentGlobs(
"../*/src/**/*.{scss,md}",
"../*/src/index.{ts,tsx}",
"../*/package.json",
`../{${LIBRARY_AND_DOCS_PACKAGES.join(",")}}/src/**/*.md`,
`../{${LIBRARY_PACKAGES.join(",")}}/src/**/*.scss`,
`../{${LIBRARY_PACKAGES.join(",")}}/src/index.ts`,
`../{${LIBRARY_PACKAGES}}/package.json`,
Comment on lines +80 to +83
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filtering to only the relevant packages saves a lot of time (about 70 seconds, or 40% on my machine)

);

const content = JSON.stringify(docs, transformDocumentalistData, 2);
Expand Down
Loading