脚本参考上的JSX错误

时间:2018-08-02 18:05:09

标签: javascript visual-studio-code

最近两个月我一直在为SharePoint编程JavaScript,并希望从Notepad ++转到VS Code。在默认安装的代码中打开JavaScript时,我遇到[JSX]和[TS]错误,希望有人可以帮助我。

即使创建一个非常简单的js文件,我也会得到这些。

例如,如果我创建此文件,则没有错误。

#A ton of imports
def unload_cache(file: str):
    return open("cache/" + file, "r").read()

def reload_cache(file: str, new):
    cache = open("cache/" + file, "w")
    cache.write(str(new))
    cache.close()

def add_xp(server_id, user_id, xp: int):
    dicts = unload_cache("server_xp.txt")
    try:
        data = dicts[server_id]
        try:
            data[user_id] = data[user_id] + xp
            dicts[server_id] = data
        except KeyError:
            data[user_id] = xp
            dicts[server_id] = data
    except:
        dicts[server_id] = {user_id:xp}
    reload_cache("server_xp.txt", dicts)

@bot.event
async def on_message(message):
    server_id = int(message.server.id)
    add_xp(server_id, message.author.id, 1)
    print(message.author.name + " gaind 1 xp at " + message.server.id)

我没有错误。但是,当我将对JQuery的脚本引用(通过手写或复制和粘贴)放置到托管库中时,出现以下错误:

{ServerID:{Player1ID:xp, Player2ID:xp, etc}, etc}
  

[ts] JSX表达式必须具有一个父元素。

这指向第二个结束脚本标记之后的空格。我在VS Code中制作并查看的每个文件中都会出现这种情况。由于找不到答案,这真让我发疯。我是否错过了有助于设置的设置?

感谢您提供的任何帮助。我喜欢使用VS Code比Notepad ++更好,但这让我很沮丧地看到我打开的每个文件都出现此错误。

0 个答案:

没有答案