vardas
June 21, 2016, 5:03pm
1
I am trying to create a JS starter project but ‘ionic start xxx --v2’ creates a transcript project.
I need to create a JS starter project so I can copy across an existing JS ionic 2 app to a clean installation (my old installation has gotten corrupted).
I did try renaming all of my JS files to TS but a get a shed load of error messages of the type “Property xxx does not exist on type yyy”
AFAIK JavaScript is not supported by the CLI anymore, here’s the official comment about it:
JS option has been removed, since we are going to focus our efforts to support Typescript.
Since TS is a superset of JS, it is up to developers to use the new features or not.
We strongly recommend to give TS a try, decorators and types help a lot while using angular 2.
You might need to install typings
and the required type definitions to get rid of the error messages.
If there are no type definitions for some libraries then you could use ambient declarations:
I guess that there are no typing definitions for this plugin then, you could try using an ambient declaration to get rid of the error message (untested, but it should work):
declare var networkinterface: any;
vardas
June 21, 2016, 5:26pm
3
Ouch!
I thought JS was supposed to be a subset of TS?
I thought I ought to be able to slip my JS code into a TS ionic app simply by changing the js extension to ts.
Yes, it’s supposed so, but according to the following issue the compiler is not working this way ATM:
opened 04:06AM - 06 Jan 16 UTC
closed 06:56PM - 06 Jan 16 UTC
Duplicate
I have the following ES6 class
``` javascript
class MyClass {
constructor()… {
this.myclassvar = 'abc';
}
}
```
When compiled/transpiled through TypeScript it generates error TS2339: Property 'myclassvar' does not exist on type 'MyClass'.
If the above code snippet is valid ES6 then TypeScript should not generate the error. The generated javascript it valid. It's just that the error scares the developers trying to use ES6 without typings.
The same ES6 class transpiles properly in BabelJS.
I know I can fix the error by declaring the variable.
``` javascript
class MyClass {
myclassvar;
constructor(){
this.myclassvar = 'abc';
}
}
```
Since TypeScript is a superset of Javascript, it should be able to handle valid ES6 without errors.
My compiler settings are
``` json
"compilerOptions": {
"target": "es5",
"module": "amd",
"declaration": true,
"noImplicitAny": false,
"noResolve": true,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
```
vardas
June 21, 2016, 6:27pm
5
Ah ok. So hopefully this will get fixed in a day or two