刚刚安装了Eclipse LUNA,并转换了我的旧JUNO工作区.它在我的一台计算机上工作得很好(win7),但在我的另一台计算机上使用相同的项目(win8,通过dropbox同步)为所有打开的文件创建了这个问题,并且我的包浏览器中没有显示任何内容.总是和JUNO一起工作.
我想将具有常量类型的两者结合起来,并使用它“作为常量”来获取文字类型作为类型:
type MyType = {name: string};
const x:MyType = {
name: 'test' // Autocompleted, typesafe. But Type is {name: string}, not
// what I want, {name: 'test'}
}
const x = { name: 'test' } as const; // Gives correct type, but no type check...
Run Code Online (Sandbox Code Playgroud)
这该怎么做?
我正在转换这个类
public class MyClass
{
public IEnumerable<string> Strings { get; }
public MyClass(IEnumerable<string>? strings = null)
{
Strings = strings ?? new List<string>();
}
}
Run Code Online (Sandbox Code Playgroud)
到一个记录。目前我有这个:
public record MyRecord(IEnumerable<string>? strings = null);
Run Code Online (Sandbox Code Playgroud)
但是,我找不到默认将 初始化IEnumerable
为空可枚举的方法,因为它必须是编译时常量。我尝试静态初始化只读数组,但同样的问题。
c# ×1
constants ×1
default ×1
eclipse ×1
eclipse-luna ×1
enumerable ×1
literals ×1
path ×1
project ×1
record ×1
types ×1
typesafe ×1
typescript ×1