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 5.0+ and drop support for React 16 #287

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"presets": [
"@babel/preset-typescript",
"@babel/preset-env",
"@babel/preset-react"
["@babel/preset-react", { "runtime": "automatic" }]
]
}
5 changes: 5 additions & 0 deletions .changeset/react-16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'playroom': minor
---

Drop support for React 16. Consumers are encouraged to upgrade to React 17+, which is a drop-in replacement.
5 changes: 5 additions & 0 deletions .changeset/typescript-5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'playroom': minor
---

Support TypeScript 5.0+
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ yarn.lock
.DS_Store
.vscode/
.idea/
.eslintcache
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cypress/plugins/
cypress/fixtures/
dist
pnpm-lock.yaml
2 changes: 1 addition & 1 deletion @types/babel__standalone.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interface TransformResponse {
}

declare module '@babel/standalone' {
import { TransformOptions } from '@babel/core';
import type { TransformOptions } from '@babel/core';

function transform(
code: string,
Expand Down
File renamed without changes.
12 changes: 0 additions & 12 deletions cypress/.eslintrc

This file was deleted.

4 changes: 2 additions & 2 deletions cypress/e2e/toolbar.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Toolbar', () => {
});
})
.get('[data-testid="copyToClipboard"]')
.click()
.then(() => expect(copySpy).to.have.been.called);
.click();
cy.then(() => expect(copySpy).to.have.been.called);
});
});
1 change: 1 addition & 0 deletions cypress/placeholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This is a placeholder file that provides for at least one TypeScript file in the project
1 change: 0 additions & 1 deletion cypress/projects/basic/components.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import PropTypes from 'prop-types';

const withPropTypes = (component) => {
Expand Down
1 change: 0 additions & 1 deletion cypress/projects/themed/components.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import PropTypes from 'prop-types';

const withPropTypes = (component) => {
Expand Down
28 changes: 13 additions & 15 deletions cypress/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ export const gotoPreview = () => {
export const toggleSnippets = () =>
cy.get('[data-testid="toggleSnippets"]').click();

export const filterSnippets = (search) =>
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy
.get('[data-testid="filterSnippets"]')
.type(search, { force: true })
.wait(200);
export const filterSnippets = (search) => {
cy.get('[data-testid="filterSnippets"]').type(search, { force: true });
// eslint-disable-next-line @finsit/cypress/no-unnecessary-waiting
cy.wait(200);
};

export const assertSnippetsListIsVisible = () =>
cy.get('[data-testid="snippets"]').should('be.visible');
Expand All @@ -82,7 +81,7 @@ export const assertSnippetCount = (count) =>

export const assertFirstFrameContains = (text) => {
getFirstFrame().then(($el) =>
// eslint-disable-next-line cypress/no-unnecessary-waiting
// eslint-disable-next-line @finsit/cypress/no-unnecessary-waiting
cy
.wrap($el.contents().find('body'))
.wait(WAIT_FOR_FRAME_TO_RENDER)
Expand Down Expand Up @@ -120,14 +119,13 @@ export const selectLines = (numLines, direction = 'down') => {
export const assertCodePaneContains = (text) => {
getCodeEditor().within(() => {
const lines = [];
cy.get('.CodeMirror-line')
.each(($el) => lines.push($el.text()))
.then(() => {
const code = lines.join('\n');
// removes code mirrors invisible last line character placeholder
// which is inserted to preserve prettiers new line at end of string.
expect(code.replace(/[\u200b]$/, '')).to.eq(text);
});
cy.get('.CodeMirror-line').each(($el) => lines.push($el.text()));
cy.then(() => {
const code = lines.join('\n');
// removes code mirrors invisible last line character placeholder
// which is inserted to preserve prettiers new line at end of string.
expect(code.replace(/[\u200b]$/, '')).to.eq(text);
});
});
};

Expand Down
9 changes: 9 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"isolatedModules": false,
"types": ["cypress"]
},
"include": ["**/*"], // override the include from the root tsconfig
"exclude": [] // override the exclude from the root tsconfig
}
4 changes: 1 addition & 3 deletions lib/defaultModules/FrameComponent.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import React, { Fragment } from 'react';

export default ({ children }) => <Fragment>{children}</Fragment>;
export default ({ children }) => <>{children}</>;
5 changes: 4 additions & 1 deletion lib/makeDefaultWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ module.exports = (playroomConfig) => ({
options: {
presets: [
require.resolve('@babel/preset-env'),
require.resolve('@babel/preset-react'),
[
require.resolve('@babel/preset-react'),
{ runtime: 'automatic' },
],
],
},
},
Expand Down
10 changes: 8 additions & 2 deletions lib/makeWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ module.exports = async (playroomConfig, options) => {
require.resolve('@babel/preset-env'),
{ shippedProposals: true },
],
require.resolve('@babel/preset-react'),
[
require.resolve('@babel/preset-react'),
{ runtime: 'automatic' },
],
require.resolve('@babel/preset-typescript'),
],
},
Expand All @@ -109,7 +112,10 @@ module.exports = async (playroomConfig, options) => {
require.resolve('@babel/preset-env'),
{ shippedProposals: true },
],
require.resolve('@babel/preset-react'),
[
require.resolve('@babel/preset-react'),
{ runtime: 'automatic' },
],
],
},
},
Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
"build:all": "concurrently 'npm:build:basic' 'npm:build:themed'",
"serve:all": "concurrently 'npm:serve:basic' 'npm:serve:themed'",
"build-and-serve:all": "pnpm build:all && pnpm serve:all",
"lint": "eslint . && prettier --list-different '**/*.{js,md,ts,tsx}' && tsc --noEmit",
"lint": "concurrently 'npm:lint:*'",
"lint:eslint": "eslint --cache .",
"lint:prettier": "prettier --list-different '**/*.{js,md,ts,tsx}'",
"lint:tsc": "tsc --noEmit",
"lint:cypress": "tsc --project cypress/tsconfig.json",
"format": "prettier --write '**/*.{js,md,ts,tsx}'",
"version": "changeset version",
"release": "changeset publish",
Expand Down Expand Up @@ -97,7 +101,7 @@
"react-use": "^17.4.0",
"read-pkg-up": "^7.0.1",
"scope-eval": "^1.0.0",
"typescript": "^4.5.4",
"typescript": ">=5.0.0",
"use-debounce": "^9.0.2",
"webpack": "^5.75.0",
"webpack-dev-server": "^4.11.1",
Expand All @@ -110,8 +114,8 @@
"@types/jest": "^29.2.4",
"concurrently": "^7.6.0",
"cypress": "^12.0.2",
"eslint": "^8.29.0",
"eslint-config-seek": "^10.1.2",
"eslint": "^8.44.0",
"eslint-config-seek": "^11.3.1",
"husky": "^8.0.2",
"jest": "^29.3.1",
"lint-staged": "^13.1.0",
Expand All @@ -122,8 +126,8 @@
"surge": "^0.23.1"
},
"peerDependencies": {
"react": "^16.8 || ^17 || ^18",
"react-dom": "^16.8 || ^17 || ^18"
"react": "^17 || ^18",
"react-dom": "^17 || ^18"
},
"packageManager": "pnpm@7.18.1",
"volta": {
Expand Down