我在几乎空的反应组件中得到此错误:
"[ts]未终止的正则表达式字面量."
import * as React from 'react';
export default class EmptyComponent extends React.Component {
render() {
return (
<p>Hello</p>
);
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道我做错了什么!
我注意到,当我在YouTube上观看视频时,屏幕保护程序无法启动.我正在使用Windows 7.
这是测试:
我已经使用Firefox,Chrome和IE8进行了测试.我的Flash Player版本是10.3.(Youtube正在使用flash播放视频).无论我是否全屏观看视频,都会发生同样的情况.
有谁知道他们是怎么做到的?
我搜索过,但我发现的只是人们说这是不可能的,或者是用户在观看视频时禁用屏幕保护程序的提示.
请查看所有答案.不要坚持投票最多.
我正在尝试使用 cypress.io 测试我的 chrome 扩展
我可以通过将其添加到plugins/index.js以下内容来成功加载我的扩展:
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, args) => {
if (browser.name === 'chrome') {
args.push('--load-extension=../bananatabs/build')
return args
}
})
}
Run Code Online (Sandbox Code Playgroud)
我可以通过导航到在 cypress 浏览器上打开我的扩展的 index.html
chrome-extension://ewoifjflksdjfioewjfoiwe/index.html
但是当我尝试在测试中“访问”它时,如下所示:
context('visit bananatabs', () => {
beforeEach(() => {
cy.visit('chrome-extension://inbalflcnihklpnmnnbdcinlfgnmplfl/index.html')
})
it('does nothing', () => {
assert(true);
});
});
Run Code Online (Sandbox Code Playgroud)
它不起作用。页面如下:
抱歉,我们无法加载:chrome-extension://inbalflcnihklpnmnnbdcinlfgnmplfl/index.html
在文档中,所有示例都使用 http 或 https 协议,而不是 chrome-extension。
更新
我可以看到测试页面是http://localhost:54493/__/#/tests/integration/visit.spec.js,它包含一个带有我正在测试的页面的 iframe,它使用chrome-extension://协议。我不确定那会不会奏效。
这能做到吗?
使用 react 和 react-dom 16.9.0
我在测试 React 钩子时收到此警告:
console.error node_modules/react-dom/cjs/react-dom-test-utils.development.js:80
Warning: Do not await the result of calling act(...) with sync logic, it is not a Promise.
Run Code Online (Sandbox Code Playgroud)
我的测试代码(在@testing-library/react 中使用 jest)
...
await act( () => {
rerender(
<HookTester
promise={asyncFunction}
initialValue={'extra loading...'}
/>
);
});
expect(asyncFunction).toHaveBeenCalledTimes(2);
...
Run Code Online (Sandbox Code Playgroud)
但如果我不等待,那么我的expectation 就太早了。
我在JetBrains WebStorm中尝试使用TypeScript.
我在"person.ts"中有一个非常简单的课程:
export class Person {
constructor(public name:string, public age:number) {
}
toString() {
return this.name + ", " + this.age;
}
}
Run Code Online (Sandbox Code Playgroud)
然后,在我的应用程序上,我尝试像这样导入它:
import nsp = module("person");
export class App {
start() {
var my_user:nsp.Person;
my_user = new nsp.Person("Julian", 111);
console.log( my_user.toString() );
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎有效.我可以使用tsc编译为javascript:
tsc --module AMD .\public\script\app.ts
Run Code Online (Sandbox Code Playgroud)
我还在WebStorm中为TypeScript设置了FileWatcher.没关系.
但我收到这个恼人的错误/警告:"分配的表达式类型Person不能分配给exports.Person类型"

有任何想法吗?难道我做错了什么?这是WebStorm中的错误吗?
这是我在GitHub上的项目:https://github.com/JulianG/typescript-modularization-demo/,以防你想尝试一下.
我有一个 React - Typescript 创建的:
create-react-app my-app --scripts-version=react-scripts-ts
Run Code Online (Sandbox Code Playgroud)
它编译得很好,但每次我看到这条消息或警告时:
No valid rules have been specified for JavaScript files
Run Code Online (Sandbox Code Playgroud)
任何想法如何摆脱它?
> react-scripts-ts build
Creating an optimized production build...
Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
ts-loader: Using typescript@2.8.3 and /Users/julian/my-app/tsconfig.json
No valid rules have been specified for JavaScript files
Compiled successfully.
Run Code Online (Sandbox Code Playgroud)
我的 tscongif.json 和 tslint.json 文件可以在这里找到:https ://gist.github.com/JulianG/be82d9fa20f48f60ce10371fa5095230
reactjs ×3
typescript ×3
amd ×1
cypress ×1
flash ×1
javascript ×1
react-hooks ×1
screensaver ×1
testing ×1
tsconfig ×1
tslint ×1
warnings ×1
webstorm ×1
windows ×1
youtube ×1