Hello, i am currently running a nativescript-angular project with the following version info
"nativescript": {
"tns-ios": {
"version": "2.4.0"
}
},
"dependencies": {
"@angular/common": "2.1.2",
"@angular/compiler": "2.1.2",
"@angular/core": "2.1.2",
"@angular/forms": "2.1.2",
"@angular/http": "2.1.2",
"@angular/platform-browser": "2.1.2",
"@angular/platform-browser-dynamic": "2.1.2",
"@angular/router": "3.1.2",
"email-validator": "^1.0.7",
"nativescript-angular": "1.1.3",
"nativescript-background-fetch": "^1.0.2",
"nativescript-background-geolocation-lt": "^1.2.5",
"nativescript-geolocation": "0.0.15",
"nativescript-plugin-firebase": "^3.8.2",
"nativescript-theme-core": "^0.2.1",
"reflect-metadata": "~0.1.8",
"rxjs": "5.0.0-beta.12",
"tns-core-modules": "2.4.0"
},
"devDependencies": {
"nativescript-dev-android-snapshot": "^0..",
"nativescript-dev-typescript": "^0.3.2",
"typescript": "^2.0.10",
"zone.js": "~0.6.21"
}
My application won't compile due to the error
Property 'ServerValue' does not exist on type 'typeof'
when i invoke
firebase.ServerValue.TIMESTAMP
The file that line is has the error reference as well.
I looked back on some old issues regarding this where a typings file was included but i see that step is no longer in the instructions for this plugin. Could you please advise what i can do to get rid of this error in order for the app to compile? i would very much like to timestamp the record so taking it out would be the last resort.
Thank you!
I see what you mean with the error, but is it a compiler warning or a runtime error? I tried with the following code and saw my editor complain, but runtime it works as expected:
console.log('Servervalue.TIMESTAMP ' + firebase.ServerValue.TIMESTAMP); resolves to ".sv" = timestamp; which is OK.
Hello, editor is complaining, and upon trying to compile with 'tns build ios', it exits with code 1
It says "error TS2339: Property 'ServerValue' does not exist on type 'typeof "~/project_name/node_
modules/nativescript-plugin-firebase/i...'"
(I believe it is index.d.ts; but when I look into it, I can see the exported interface ServerValue, containing a TIMESTAMP of type _any_)
I get the same error and am unable to build the app =(
I have managed to make a workaround for this. Just type "declare var ServerValue;" on top of "_[your_app_folder]_/node_modules/nativescript-plugin-firebase/index.d.ts" and it starts recognising ServeValue.TIMESTAMP.
@EddyVerbruggen I have seen this in your youtube video for ThreeDeeTouch but I doubt this is a feasible solution for this particular issue.
Let me know if this solves your issue.
@onurozansahin Thanks, declaring it like that will effectively ignore this TS error. Not a real solution but it doesn't hurt at all. I'm keeping this open and hope a TS guru can step in and point out what's wrong with the TS definition of this property.
@NikJaySix , @onurozansahin , @ullalaaron , @EddyVerbruggen
To avoid the build-time error in your code instead of firebase.ServerValue.TIMESTAMP
you can use the following syntax:
firebase["ServerValue"].TIMESTAMP
@EddyVerbruggen changing this to enum (with removing the casting to any) also worked out for me (still not so sure if this is tyhe right way to handle this TS case)
Ah! Very cool @nickiliev!
@NickIliev Thanks for that! I'll add that to the readme.
Not sure if you're an expert on this, but do you also have an idea how the TS declaration can be changed in a way it's accepted with the firebase.ServerValue.TIMESTAMP syntax?
@EddyVerbruggen using enum instead of interface is allowing me to use the dot syntax.Still I am not a TS expert so I can not guarantue this is the proper way (it seems to works just as expected with firebase.ServerValue.TIMESTAMP)
@NickIliev Of course! You're right, that works perfectly for me as well, I'll change that!
Most helpful comment
@EddyVerbruggen using enum instead of interface is allowing me to use the dot syntax.Still I am not a TS expert so I can not guarantue this is the proper way (it seems to works just as expected with
firebase.ServerValue.TIMESTAMP)