我有打字稿编译的问题。smbd 遇到过吗?
node_modules/@types/node/index.d.ts(20,1): 错误 TS1084: 无效的“引用”指令语法。
tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./app",
"target": "es6",
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"listFiles": false,
"skipLibCheck": true
},
"include": [
"./app/**/*.ts"
]
}
Run Code Online (Sandbox Code Playgroud)
package.json 中的打字稿版本: "typescript": "^2.6.1"
对于以下代码:
public class StaticFinal
{
private final static int i ;
public StaticFinal()
{}
}
Run Code Online (Sandbox Code Playgroud)
我得到编译时错误:
StaticFinal.java:7: variable i might not have been initialized
{}
^
1 error
Run Code Online (Sandbox Code Playgroud)
这符合JLS8.3.1.2,其中说:
如果空白的final(§4.12.4)类变量未被声明它的类的静态初始化程序(第8.7节)明确赋值(第16.8节),则为编译时错误.
所以,完全理解上述错误.
但现在考虑以下内容:
public class StaticFinal
{
private final static int i ;
public StaticFinal()throws InstantiationException
{
throw new InstantiationException("Can't instantiate"); // Don't let the constructor to complete.
}
}
Run Code Online (Sandbox Code Playgroud)
这里,构造函数永远不会完成,因为它InstantiationException是在构造函数的中间抛出的.这段代码编译得很好!!
为什么?为什么这段代码没有显示关于final变量非初始化的编译时错误i?
编辑
我正在使用javac 1.6.0_25命令提示符编译它(不使用任何IDE)
什么是ffreestandinggcc?它是干什么用的 ?我遇到了以下情况:
gcc -ffreestanding -m32 -c kernel.c -o kernel.o
Run Code Online (Sandbox Code Playgroud)
并且不明白,它究竟意味着什么.
我已经从Linux Mint的源代码编译了Python 3.4,但由于某种原因它没有复制pip到它的最终编译文件夹(之后make install).
有任何想法吗?
我刚刚下载了新的Visual Studio Code,我的第一印象非常积极.对于打字稿,intellisense工作得很漂亮.
但是,有一个奇怪的问题:VS Code似乎无法编译typescript模块.
这段代码:
/// <reference path="../definitions/react.d.ts"/>
import React = require("react");
Run Code Online (Sandbox Code Playgroud)
在cmd上编译完全正常
tsc --module commonjs main.ts
但在VS Code中,第二行以红色突出显示,编辑抱怨:
除非提供"-module"标志,否则无法编译外部模块
当然,任何使用模块的打字稿代码都必须使用此标志进行编译.但是如果IDE知道模块的用法,为什么不设置标志呢?没有模块的打字稿代码在保存时编译,没有问题.
我想我错过了一些编译器设置配置文件.有这样的事吗?我在哪里可以找到它?
我添加了tsconfig.json文件:
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true
}
}
Run Code Online (Sandbox Code Playgroud)
这实际上消除了错误.不幸的是,IDE不再编译我的代码.起初我以为config.json只会使错误消息静音,但它确实不止于此.Intellisense现在可以在示例文件中使用.如果我键入React自动完成被触发并且显然知道React,因为显示了有意义的建议.
现在,为什么VS Code没有将文件编译为js?我已经尝试配置任务运行器来完成这项工作,但它似乎不起作用:
{
"version": "0.1.0",
// The command is tsc.
"command": "tsc",
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Under windows use tsc.exe. This ensures we don't need a shell.
"windows": {
"command": "tsc.exe"
}, …Run Code Online (Sandbox Code Playgroud) 有没有办法在Perl中预编译正则表达式?我有一个在程序中多次使用它并且它在使用之间没有变化.
我正试图找到一种方法来更快地编译Go程序.目前大约30秒,这使得项目工作变得缓慢.
当我运行时go build -v,我发现大部分时间都花在编译go-sqlite3(链接到C sqlite lib)上.但是,由于这个lib永远不会改变,我想知道是否有可能阻止构建工具每次都重新编译它?
可能令人惊讶的是,这个C++代码打印出来1.
#include <iostream>
std::string x();
int main() {
std::cout << "x: " << x << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
x 是一个函数原型,它似乎被视为一个函数指针,而C++标准部分4.12布尔转换说:
4.12布尔转换[conv.bool] 1算术,无范围枚举,指针或指向成员类型的指针的prvalue可以转换为bool类型的prvalue.零值,空指针值或空成员指针值转换为false; 任何其他值都转换为true.对于直接初始化(8.5),std :: nullptr_t类型的prvalue可以转换为bool类型的prvalue; 结果值为false.
但是,x永远不会绑定一个函数.正如我所料,C链接器不允许这样做.但是在C++中,这根本不是问题.谁能解释这种行为?
compilation ×10
c++ ×2
typescript ×2
64-bit ×1
c ×1
c# ×1
conditional ×1
final ×1
gcc ×1
go ×1
java ×1
linker ×1
node.js ×1
performance ×1
perl ×1
pip ×1
python ×1
python-3.4 ×1
regex ×1
sqlite ×1
static ×1
tsconfig ×1
xaml ×1