首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >输入输入不起作用

输入输入不起作用
EN

Stack Overflow用户
提问于 2016-07-18 21:23:51
回答 1查看 3.1K关注 0票数 0

我想解决这个问题已经超过6-8个小时了。我想问题之一是我的英语。=)

我用原子编辑器,电子,打字稿,反应

tsconfig.json

代码语言:javascript
复制
{
    "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:

代码语言:javascript
复制
import {hello} from "./func";
hello("TypeScript");

func.ts

代码语言:javascript
复制
export function hello(name: string){
    console.log(`Hello, ${name}`);
}

启动电子并获得错误:

代码语言:javascript
复制
Uncaught SyntaxError: Unexpected token import

然后,创建文件react-test.ts:

代码语言:javascript
复制
import * as React from "react";

原子编辑器中的获取错误:

代码语言:javascript
复制
Cannot find module 'react'

问题:,我不想要更多的理论。有一个具体的例子。请帮我解决这个问题。顺便说一句,我对babel没有任何问题

更新#1:

电子运行命令:

代码语言:javascript
复制
npm start

github项目

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-19 00:31:16

首先,您需要使用TypeScript命令将JavaScript转换为JavaScript,而在index.html文件中则需要app.js而不是app.ts。然后用npm start运行电子

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38446239

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档