我有一个类型:
export type Example = ExampleOne | ExampleTwo | ExampleThree;
Run Code Online (Sandbox Code Playgroud)
如何创建ExampleX仅包含ExampleOneor的新类型ExampleTwo?
我试过:
export type ExampleX = Omit<Example, 'ExampleThree'>;
Run Code Online (Sandbox Code Playgroud)
但这不起作用吗?
我尝试7.4使用 brew将我的 PHP 版本更新到macOS Catalina。
我做了 brew install php@7.4
如果我检查我的版本php -v,我仍然看到旧版本PHP 7.3.11?
我需要做什么?
更新:
之后brew doctor,我得到:
警告:在您的 PATH 中找不到 Homebrew 的 sbin,但您已经安装了将可执行文件放在 /usr/local/sbin 中的公式。例如,考虑像这样设置 PATH:echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.profile
我有2个分支本地回购master和develop.
develop分支我有我的所有Drupal 8核心代码master分支我有1提交(初始提交)在我的远程仓库中,我将所有Drupal 8核心代码放在分支中develop.如何在远程主分支中获取此代码?我如何合并这些回购?
更新:
当我这样做时,git status我得到:
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
griffioenrotterdam.sublime-project
griffioenrotterdam.sublime-workspace
sites/
nothing added to commit but untracked files present (use "git add" to track)
Run Code Online (Sandbox Code Playgroud)
我需要做什么?
更新2:
当我这样做时,git checkout develop我得到:
error: The following untracked working tree files would be overwritten by checkout:
sites/default/default.services.yml
sites/default/default.settings.php …Run Code Online (Sandbox Code Playgroud) 在我的天蓝色管道中,我收到错误:
semver <7.5.2 严重性:中等 semver 容易受到正则表达式拒绝服务的影响 - https://github.com/advisories/GHSA-c2qf-rxjj-qqgw
当我添加semver我的决议时package.json:
"resolutions": {
"semver": "7.5.2"
}
Run Code Online (Sandbox Code Playgroud)
然后我在管道中遇到另一个错误:
npm ERR! path /my-path-to/node_modules/semver/bin/semver
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/my-path-to/node_modules/semver/bin/semver'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Run Code Online (Sandbox Code Playgroud)
为什么我必须这样做?我知道我必须更新软件包,但我需要先添加该功能。
当我执行 npm 时,outdated我得到一个大列表:
Package Current Wanted Latest Location Depended by
@apollo/client 3.3.19 3.7.16 3.7.16 node_modules/@apollo/client myrepo
@babel/cli 7.14.3 7.22.5 7.22.5 node_modules/@babel/cli …Run Code Online (Sandbox Code Playgroud) 我尝试使用赫斯基pre-commit和lint-staged.
安装了这些:
"husky": "^5.1.3",
"lint-staged": "^10.5.4",
Run Code Online (Sandbox Code Playgroud)
在 package.json 我有:
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
"start": "npm run develop",
"serve": "gatsby serve",
"clean": "gatsby clean",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1",
"lint": "eslint --ext .js,.jsx,.ts,.tsx src --color",
"isready": "npm run format && npm run lint && npm run build"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "npm test",
}
},
"lint-staged": {
"./src/*.{js,jsx,ts,tsx}": [
"npm run …Run Code Online (Sandbox Code Playgroud) 我有一个搜索框组件:
function SearchBox({ search, setSearch }) {
return (
<div>
<div>
<input onChange={e => setSearch(e.target.value)} type="text" placeholder="Search..." value={search} />
</div>
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法:
describe('Input value', () => {
it('updates on change', () => {
const { queryByPlaceholderText } = render(<SearchBox />)
const searchInput = queryByPlaceholderText('Search...')
fireEvent.change(searchInput, { target: { value: 'test' } })
expect(searchInput.value).toBe('test')
})
})
Run Code Online (Sandbox Code Playgroud)
但后来我得到一个错误:
错误:未捕获 [TypeError:setSearch 不是函数]
我可以如何测试此 SearchBox 组件以及测试什么内容?
在我的 React 应用程序中,我有一个嵌入 Instagram 帖子的组件。
它呈现以下 HTML 结构:
<div data-testid="instagram"><iframe class="instagram-media instagram-media-rendered" id="instagram-embed-3" //etc....
Run Code Online (Sandbox Code Playgroud)
我正在使用React 测试库。
如何编写一个测试来检查iframe元素是否存在,例如使用 CSS 类instagram-media?
我在导航菜单中使用Material UI 选项卡。
我想在导航到另一条路线时禁用指示器的动画。
我知道有一个对象 prop TabIndicatorProps。但是它里面禁用动画的键是什么呢?或者它不存在,我必须用 CSS 来做吗?
<Tabs
value={value}
TabIndicatorProps={{ ?? }}
>
Run Code Online (Sandbox Code Playgroud) 我尝试在我的 Gatsby 和 Typescript 项目中创建导入别名。我使用 npm 包eslint-import-resolver-alias。
所以我能够使用:
import Layout from '@components/Layout';
Run Code Online (Sandbox Code Playgroud)
在gatsby-node.js我有:
const 路径 = require('路径');
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
alias: {
@components: path.resolve(__dirname, 'src/components'),
@static: path.resolve(__dirname, 'static'),
},
},
});
};
Run Code Online (Sandbox Code Playgroud)
在.eslintrc.js我有:
alias: [['@components', './src/components']]
Run Code Online (Sandbox Code Playgroud)
在我有:
"baseUrl": "./src",
"paths": {
"@components": ["/components"]
Run Code Online (Sandbox Code Playgroud)
现在我在 VSCode 中收到此错误:
无法解析模块“组件/布局”的路径。eslintimport/no-unresolved
typescript gatsby eslint-config-airbnb typescript-eslintparser
我使用 Cypress 和 Cucumber 进行端到端测试。
我有以下 Cypress 结构:
page-one/
another-page/
cypress/integration/page-one/check-hero.js
cypress/integration/page-one/check-custom-block.js
cypress/integration/page-one.feature
cypress/integration/another-page.feature
Run Code Online (Sandbox Code Playgroud)
在这两个文件中check-hero.js,check-custom-block.js我有:
Given('I navigate to page one', () => {
cy.visit(`${Cypress.env('baseUrl')}/page-one`);
});
Run Code Online (Sandbox Code Playgroud)
我可以改进这个结构以使其更加干燥并在多个文件中重用此给定步骤吗?
reactjs ×5
typescript ×2
cucumber ×1
cypress ×1
dependencies ×1
eslint ×1
gatsby ×1
git ×1
homebrew ×1
husky ×1
jestjs ×1
lint-staged ×1
macos ×1
material-ui ×1
merge ×1
npm ×1
package.json ×1
php ×1
php-7.4 ×1
pre-commit ×1
tabs ×1
unit-testing ×1