小编Chi*_*eam的帖子

esModuleInterop 标志已设置,仍然出现默认导入错误

我有一个使用 TypeScript 的 React 项目,在主 tsx 文件中,该import React from 'react'行工作正常。但是在我的测试文件中,它仍然触发 TS1259 错误。我猜我的 TS/Jest/Babel 配置有些奇怪,但似乎无法确定。

有人知道问题是什么吗?

tsconfig.json

{
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "target": "ES2019",
        "moduleResolution": "node",
        "module": "ESNext",
        "allowJs": true,
        "noEmit": true,
        "strict": true,
        "isolatedModules": true,
        "esModuleInterop": true,
        "strictNullChecks": true,
        "jsx": "react",
        "baseUrl": "./",
        "types": []
    },
    "include": [
        "index.d.ts",
        "src/*.ts",
        "src/*.tsx",
        "src/**/*.ts",
        "src/**/*.tsx"
    ]
}
Run Code Online (Sandbox Code Playgroud)

笑话配置.js

module.exports = {
    collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/index.ts'],
    moduleNameMapper: {'^.+\\.s?css$': 'identity-obj-proxy'},
    transform: {'^.+\\.tsx?$': 'babel-jest'},
    testRegex: '/__tests__/.*\\.test\\.tsx?$',
    testURL: 'http://localhost',
    setupFilesAfterEnv: ['<rootDir>/__tests__/setup.ts'],
    setupFiles: [],
    testPathIgnorePatterns: [ …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs jestjs

8
推荐指数
1
解决办法
8729
查看次数

CORS 预检在 Firefox 中失败,但在 Chrome for Apache CXF 中有效

我正在向 Java Web 应用程序添加对 CORS 请求的支持,但由于某些未知原因,Firefox 未正确发送(或接收)Content-Type标头。该应用程序在 Jetty Web 服务器上运行,但在 Chrome 中一切正常。

我不确定问题是否出在 Firefox、Jetty 或我们的前端应用程序中,但发生了一些奇怪的事情。

根据 Firefox 的请求和响应标头:

要求

Host: localhost:8889
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: POST
Access-Control-Request-Headers: authorization,content-type
Origin: http://localhost:7778
DNT: 1
Connection: keep-alive
Run Code Online (Sandbox Code Playgroud)

回复

Access-Control-Allow-Origin: http://localhost:7778
Content-Length: 0
Date: Wed, 14 Sep 2016 17:10:36 GMT, Wed, 14 Sep 2016 17:10:36 GMT
Server: Jetty(8.1.14.v20131031)
access-control-allow-credentials: true
access-control-allow-headers: authorization, -type
access-control-allow-methods: POST
Run Code Online (Sandbox Code Playgroud)

在 Chrome …

javascript firefox google-chrome cxf cors

5
推荐指数
1
解决办法
1369
查看次数

标签 统计

cors ×1

cxf ×1

firefox ×1

google-chrome ×1

javascript ×1

jestjs ×1

reactjs ×1

typescript ×1