我有以下内容:
interface IEngine {
    type():string;
    type(type:string):void;
}
class Engine implements IEngine {
    private _type: string;
    get type():string {
        return this._type;
    }
    set type(type:string) {
        this._type = type;
    }
}
var engine = new Engine();
engine.type = 'foo';
Run Code Online (Sandbox Code Playgroud)
界面看起来我要实现,但是,运行tsc会抛出异常:
F:\>tsc interfaces.ts --target "es5"
interfaces.ts(11,7): error TS2420: Class 'Engine' incorrectly implements interface 'IEngine'.
  Types of property 'type' are incompatible.
    Type 'string' is not assignable to type '{ (): string; (type: string): void; }'.
Run Code Online (Sandbox Code Playgroud) 我正在向 DOM 添加相当多的元素。我不希望浏览器在添加所有元素之前尝试重绘页面。
这可能吗?
我编写了这个程序,但是当我尝试编译它时,我遇到了语法错误.我找不到语法错误的位置.
它应该计算不同气体中的第二声音传播次数,用户给出的信息.
include <iostream>
#include <fstream>
using namespace std;
   int main()
         {
          int choice, gascount=0,i,sec;
          string gas[10],type;
          double speed[10],speedd;
          ifstream input;
   input.open("input.txt"); 
   if(input.fail())            
          cout<<"file did not open please check it\n";
          cin >> gas[gascount++];
      while(input)
          {
              input>>speed[gascount];
              input>>gas[++gascount];
          }
           while(choice!=5)  
               {cout<<"Choose gas would you like to use\n";
                cout<<"1  CarbonDioxide\n";
                cout<<"2  Air\n";
                cout<<"3  Helium\n";
                cout<<"4  Hydrogen\n";
                cout<<"5  Exit\n";  //5th cout for exiting program
                cin >>choice;
     switch(choice)    //use swich for user selection of gases 
        {case 1:    type="CarbonDioxide";
                    break;
         case 2:    type="Air";
                    break;
         case …Run Code Online (Sandbox Code Playgroud) 例如:
100M is decimal
100l is long
Run Code Online (Sandbox Code Playgroud)
我想找一个单元,所以我不必一直打字(uint) 123,我意识到我不知道要搜索什么单词.
javascript ×2
.net ×1
c# ×1
c++ ×1
dom ×1
html ×1
keyword ×1
performance ×1
reflow ×1
string ×1
syntax-error ×1
typescript ×1