我想解决这个问题已经超过6-8个小时了。我想问题之一是我的英语。=)
我用原子编辑器,电子,打字稿,反应
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"noImplicitUseStrict": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts"
],
"compileOnSave": true,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}app.ts:
import {hello} from "./func";
hello("TypeScript");func.ts
export function hello(name: string){
console.log(`Hello, ${name}`);
}启动电子并获得错误:
Uncaught SyntaxError: Unexpected token import然后,创建文件react-test.ts:
import * as React from "react";原子编辑器中的获取错误:
Cannot find module 'react'问题:,我不想要更多的理论。有一个具体的例子。请帮我解决这个问题。顺便说一句,我对babel没有任何问题
更新#1:
电子运行命令:
npm startgithub项目
发布于 2016-07-19 00:31:16
首先,您需要使用TypeScript命令将JavaScript转换为JavaScript,而在index.html文件中则需要app.js而不是app.ts。然后用npm start运行电子
https://stackoverflow.com/questions/38446239
复制相似问题