我有带有 Typescript 和 React 环境的标准箭头映射 ES7 函数:
const getItemList: Function = (groups: any[]): JSX.Element =>
group.map((item: any, i: number) => {
const itemCardElemProps = { handleEvents: () => {}, ...item}
return <Item key={`${item.id}_${i}`} {...itemCardElemProps} />
})
Run Code Online (Sandbox Code Playgroud)
并得到错误:
TS2739: Type 'Element[]' is missing the following properties from type 'Element': type, props, key
Run Code Online (Sandbox Code Playgroud)
版本:打字稿 3.5.3
我有"jest": "^29.2.1"
。我的单元测试输出错误如下:
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
ts-jest[backports] (WARN) "[jest-config].globals.ts-jest.tsConfig" is deprecated, use "[jest-config].globals.ts-jest.tsconfig" instead.
ts-jest[backports] (WARN) Your Jest configuration is outdated. Use the CLI to help migrating it: ts-jest config:migrate <config-file>.
Run Code Online (Sandbox Code Playgroud)
我jest.config.ts
的如下:
const config = {
roots: ['<rootDir>/src'],
verbose: true,
globalSetup: './globalSetup.ts',
testEnvironmentOptions: {
url: 'http://localhost/',
},
setupFilesAfterEnv: [],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'], …
Run Code Online (Sandbox Code Playgroud) 我安装了webpack-bundle-analyzer并需要运行它.我该怎么做?我有几个错误.其中最常见的是
Could't analyze webpack bundle
Run Code Online (Sandbox Code Playgroud) 我正在构建一个浏览器应用程序,需要使用链接中概述的 OAuth 2.0/JWT 工作流程向 Google 进行身份验证。
在使用 Google OAuth 2.0 成功进行用户身份验证的情况下,Google API 会向应用程序 OAuth 发送如下响应:
{
"clientId": "xxx...apps.googleusercontent.com",
"credential": "yyy...123...zzz",
"select_by": "user"
}
Run Code Online (Sandbox Code Playgroud)
我有一个 client_id 并使用 NodeJS + JS。
用户通过身份验证后,如何向应用程序提供真实的用户数据?
ReactJS 官方文档建议在终端中运行以下命令来生成发布版 APK
cd android && ./gradlew assembleRelease
Run Code Online (Sandbox Code Playgroud)
响应此命令时出现异常:
cd android && ./gradlew assembleRelease '.' is not recognized as an internal or external command, operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
什么是问题?
我在文件./MyInput.react.js中有以下ReactJs组件
import React from 'react';
export default class MyInput extends React.Component {
constructor(props) {
super(props);
this.id = getNextId();
this.onChange = this.onChange.bind(this);
}
onChange(e) {
this.props.onChange(e.target.value);
}
render() {
return (
<label htmlFor={this.id}>
{this.props.label}
<input
id={this.id}
value={this.props.value}
onChange={this.onChange}
/>
</label>
);
}
}
Run Code Online (Sandbox Code Playgroud)
现在我尝试将它导入./index.js,如下所示:
import {MyInput} from './MyInput.react';
Run Code Online (Sandbox Code Playgroud)
控制台返回错误:
Error: Minified React error #130
Run Code Online (Sandbox Code Playgroud)
您刚刚遇到的错误的全文是:
Element type is invalid: expected a string (for built-in components) or
a class/function (for composite components) but got: undefined.
Run Code Online (Sandbox Code Playgroud)
这有什么问题?
我有一个 JSX 类的打字稿代码
export class SearchForm extends React.PureComponent<Props, State> {
public inputRef: React.RefObject<{}>;
constructor(props: any) {
super(props)
this.inputRef = React.createRef()
}
public componentDidMount(): void {
this.inputRef.current.focus()
this.inputRef.current.select()
...
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试编译这段代码时,出现了一堆错误:
ERROR in ...
TS2339: Property 'className' does not exist on type '{}'.
ERROR in ...
TS2339: Property 'focus' does not exist on type '{}'.
Run Code Online (Sandbox Code Playgroud)
什么是问题?
docker 和 dockerfile 是否有任何非常基本且仍然可行的示例来运行单个 html 文件并在 docker 的帮助下将其显示给其他人?
我开始使用NVIDIA GPU CLOUD深度学习平台.我尝试拉入控制台(命令提示符):
docker pull nvcr.io/nvidia/pytorch:17.10
Run Code Online (Sandbox Code Playgroud)
并得到消息:
Error response from daemon: Get https://nvcr.io/v2/: unauthorized: authentication required
Run Code Online (Sandbox Code Playgroud)
我的错是什么?
我的 webpack-dev-server 工作速度非常慢。我有以下 webpack.config.js 文件:
'use strict';
var path = require('path');
var webpack = require('webpack');
var glob = require("glob");
module.exports = {
entry: {
wit: [babel-polyfill',
'./index.js',
'./src/shared/styles.less']
},
output: {
path: path.resolve(__dirname, 'dist/'),
//publicPath: '/',
filename: 'bundle.[name].js'
},
module: {
rules: [
{
test: /(\.js[\S]{0,1})$/i,
exclude: /node_modules/,
loaders: ['babel-loader?presets[]=env&presets[]=react&presets[]=stage-0&presets[]=stage-2']
},
{
test: /\.(htm|html|xhtml|hbs|handlebars|php|ejs)$/i,
exclude: /node_modules/,
loader: "file?name=[name].[ext]",
},
{
test: /\.css$/i,
exclude: [/node_modules/],
loader: 'style-loader!css-loader'
},
{
test: /\.less$/i,
exclude: /node_modules/,
use: [{
loader: "style-loader" // creates style nodes …
Run Code Online (Sandbox Code Playgroud) 我升级了 Nestjs 服务器包并尝试启动我的服务器。这次我得到了以下错误:
`TypeError: (0 , apollo_server_core_1.ApolloServerPluginLandingPageGraphQLPlayground) is not a function`
Run Code Online (Sandbox Code Playgroud)
我疑惑了...
使用 Mongoose 中间件使用 ExpressJS 的 Jest 端点进行测试时,我遇到了以下错误:
Mongoose: looks like you're trying to test a Mongoose app with Jest's default jsdom test environment. Please make sure you read Mongoose's docs on configuring Jest to test Node.js apps: http://mongoosejs.com/docs/jest.html
Run Code Online (Sandbox Code Playgroud)
问题是什么?
reactjs ×4
jestjs ×2
typescript ×2
webpack ×2
webpack-2 ×2
android ×1
apollo ×1
docker ×1
dockerfile ×1
ecmascript-6 ×1
es6-class ×1
express ×1
google-oauth ×1
javascript ×1
mongoose ×1
node.js ×1
nvidia ×1
oauth ×1
oauth-2.0 ×1
react-native ×1
ts-jest ×1
unit-testing ×1