While trying to pick out the first character of a computed property I used charAt() function on it, but I am getting a little warning from VSCode that it is a wrong usage, although it is working.
computed: {
...mapGetters({
firstname: 'user/firstname',
lastname: 'user/lastname',
}),
initials () {
return (this.firstname.charAt(0).toUpperCase() + this.lastname.charAt(0).toUpperCase());
}
},
Property 'charAt' does not exist on type 'Computed'.Vetur(2339) - This is the warning I get. Could not find much on this over the web
This is a warning caused by vetur.validation.interpolation which validate interpolations in region using TypeScript language service.
Setting vetur.experimental.templateInterpolationService: false in your settings.json file will solved this issue for you.
Related
My pouchdb-find queries are failing because there are some bad data objects: they are undefined, actually stored undefineds in the database. They are not {} or {_id: 'something'}, they are actually undefineds.
Details
I discovered it while trying to query for a field being not-null. When I query for {$eq: null} to find those records, I found something strange.
Query:
await db.find({ selector: {text: {$gt: null}} });
// or
await db.find({ selector: {text: {$exists: true}} });
Results:
{
docs: [
undefined,
undefined,
undefined,
undefined,
{
_id: 'test-id-1618443059797',
_rev: '3-251568304e939d8d5b688af8c09eaa13'
},
{
_id: 'test-id-1618443082960',
_rev: '3-a60c1dde0e11e14d0a14cd86d2478140'
}
]
}
This seems to explain why I'm getting errors like the following. (The slightly different formatting is from tslog).
TypeError Cannot read property 'text' of undefined
error stack:
• index.js:14 getFieldFromDoc
node_modules/.pnpm/pouchdb-selector-core#7.2.2/node_modules/pouchdb-selector-core/lib/index.js:14:18
• index.js:345 <anonymous>
node_modules/.pnpm/pouchdb-selector-core#7.2.2/node_modules/pouchdb-selector-core/lib/index.js:345:25
• index.js:342 rowFilter
node_modules/.pnpm/pouchdb-selector-core#7.2.2/node_modules/pouchdb-selector-core/lib/index.js:342:25
• index.js:319 <anonymous>
node_modules/.pnpm/pouchdb-selector-core#7.2.2/node_modules/pouchdb-selector-core/lib/index.js:319:12
• index.js:318 filterInMemoryFields
node_modules/.pnpm/pouchdb-selector-core#7.2.2/node_modules/pouchdb-selector-core/lib/index.js:318:15
• index.js:1307 <anonymous>
node_modules/.pnpm/pouchdb-find#7.2.2/node_modules/pouchdb-find/lib/index.js:1307:40
The same kind of error happens for other queries involving fields, since null.<anything> will keep causing errors like that.
What I think is going on
I figure these are corrupted writes, and I'm trying to figure out how to clean those up without doing a destroy(). The state seems corrupt overall because there are multiple of these undefined records.
What I've tried
Thoroughly debugging, through the library code. Helped me clarify the issue but I don't have a fix yet.
For good measure, I tried each way to delete a record detailed in the PouchDB docs. They hit the same error (which makes sense to me)
Because they are undefined, I cannot set _deleted property. And even if I could change properties, there's no _id to pass to remove etc.
Working around with .destroy(), i.e. loading data from allDocs, calling destroy, and putting it all back. This seems hacky because more data corruption could happen in the process.
Environment
My current usage is in a nodejs environment. Executing via ts-node but I doubt that matters.
Dependency versions
pouchdb 7.2.2
pouchdb-find 7.2.2
How do I remove these undefined documents?
Is there any way to handle this besides destroying? (Meaning, I would copy the data out, destroy, then put all the non-corrupt data back; but that could cause new issues
I have a jhipster project with a sonarqube task defined in the project. We have built a react UI under the directory /src/main/ui/src/... and tests under /src/main/ui/src/test/... . Our sonarqube properties are as follows:
sonarqube {
properties {
property "sonar.host.url", "https://our_sonar_server"
property "sonar.projectKey", "MyProjectGroup:MyProject"
property "sonar.projectName", "MyProject"
property "sonar.login", sonarLogin
property "sonar.password", sonarPassword
property "sonar.links.scm", "https://mygithub/myProject.git"
property "sonar.links.scm_dev", "https://mygithub/MyProject.git"
property "sonar.links.ci", ciLink
if (pullRequest != null) {
property "sonar.analysis.mode", "preview"
property "sonar.github.pullRequest", pullRequest
property "sonar.github.repository", "MyProjectGroup/MyProject"
property "sonar.github.oauth", "my_oauth_hash"
property "sonar.github.endpoint", "https://mygithubapi/v3"
}
}
}
I currently, sonar only picks up the java which is under the standard /src/main/java. I have tried adding
property "sonar.sources", "src/main/ui/src/*.js"
property "sonar.test", "src/main/ui/src/test/**"
As well as a few variations. However, the jenkin build which invokes this via a shell step calling "./gradlew sonar -Pprod -x test" fails with an error like "invalid value" or similar. I have not been able to find an example for the correct syntax.
Edit: I was able to get the sonar build to pass in the PR using
property "sonar.sources", "src/main/ui/src"
property "sonar.test", "src/main/ui/src/test"
However, when checking the project on the sonar server, I'm still not seeing any of the javascript files being referenced.
After merging my last edit, the js files show up in sonarqube. The js tests are showing up as well, though they do not show any coverage percentage. Just the number of unit tests and how many pass. There's probably some more config necessary for that, but that wasn't really part of the original question.
After speaking with my manager, we decided to narrow the source sets to two subdirectories, "src/main/ui/src/app" and "src/main/ui/src/layouts" so that tests will not show up under source sets. The documentation suggests that you can add a comma separated list, so I created an external property and referenced those in the actual property:
ext.jsAppSrc = "src/main/ui/src/app, src/main/ui/src/layout"
ext.jsLayoutSrc = "src/main/ui/src/layout"
ext.jsTest = "src/main/ui/test"
...
property "sonar.sources", jsAppSrc, jsLayoutSrc
property "sonar.test", jsTest
The props evaluate correctly, but the sonar task fails with the error
Could not find method property() for arguments [sonar.sources, src/main/ui/src/app, src/main/ui/src/layout on org.sonarqube.gradle.SonarQubeProperties.
I then refactored to put the comma separated list in a single property, which then completed successfully.
ext.jsAppSrc = "src/main/ui/src/app, src/main/ui/src/layout"
ext.jsTest = "src/main/ui/test"
...
property "sonar.sources", jsAppSrc
property "sonar.test", jsTest
What is (<any>window) when used in Angular2?
I found it while researching the Stripe payment library:
(<any>window).Stripe.card.createToken({
number: this.cardNumber,
exp_month: this.expiryMonth,
exp_year: this.expiryYear,
cvc: this.cvc
}, (status: number, response: any) => {
if (status === 200) {
this.message = `Success! Card token ${response.card.id}.`;
} else {
this.message = response.error.message;
}
});
http://blog.mgechev.com/2016/07/05/using-stripe-payment-with-angular-2/
Looks like it's something that lets you use global objects inside a controller, but I don't really understand the details. Can't seem to find other answers on this.
Sometimes you’ll end up in a situation where you’ll know more about a
value than TypeScript does. Usually this will happen when you know the
type of some entity could be more specific than its current type.
Type assertions are a way to tell the compiler “trust me, I know what I’m
doing.”
It might be in two forms:
(<any>window)
or
(window as any)
See also https://www.typescriptlang.org/docs/handbook/basic-types.html#type-assertions
Another way to do the same thing is using Square bracket syntax
window['Stripe'].card...
In this case typescript compiler will work as well
<any> indicates a cast in TypeScript, so converting window to an any indicates that you are no longer bound by the compiler to what it thinks the window object is and what properties it has.
(<any>window) is preventing compile time type error checking from flagging the call as invalid.
I have created some unit tests for my firebase security rules. Part of this testing is trying to do illegal operations and asserting that they fail.
My problem has to do with noise; when I run the tests using nodeunit, the firebase client spits out several logs similar to this:
FIREBASE WARNING: set at /user failed: permission_denied
I do not want this output when intentionally doing illegal operations as it just results in noise and confusion.
These days there is an option to set the log level on the global firebase object:
import firebase from 'firebase/app';
firebase.setLogLevel('silent')
In our testing suite, we rewrite process.stderr.write to only ignore firebase warnings like so:
Javascript
process.stderr.write = (function(write) {
return function() {
if (!arguments[0].includes("FIREBASE WARNING"))
write.apply(process.stderr, arguments);
};
}(process.stderr.write));
Typescript (including tslint fix)
process.stderr.write = (() => {
// tslint:disable-next-line:no-unbound-method
const write = process.stderr.write;
return function () {
if (!(arguments[0] as string).includes("FIREBASE WARNING")) {
return write.apply(process.stderr, arguments);
}
};
})();
There is no way to disable the security warnings as they are emitted asynchronously by the Firebase SDK. I worked around this by adding a message before the errors:
>>> An intentional security error should be printed after this line...
As Kato said, there doesn't appear to be an official way to disable it. That said, if you really want to, it takes 2 seconds to go into the source, Ctrl+F for "WARNING", and comment out this line:
"undefined"!==typeof console.warn?console.warn(b):console.log(b)
I've been using the Google Closure Compiler for a few years but I haven't played with the actual Closure Library that much.
When I compile my app, I get the following warnings. The referenced code is in the library itself, not in my files. I'm wondering whether I should do something to fix them or just wait for the Closure Library contributors to do that.
/Users/Jan/.../closure-library/closure/goog/dom/dom.js:673:
WARNING - Property type never defined on attributes
delete attributes.type;
^
/Users/Jan/.../closure-library/closure/goog/dom/dom.js:2396:
WARNING - assignment to property getFrameContentDocument of goog.dom.DomHelper.prototype
found : function ((Element|null)): Document
required: function (this:goog.dom.DomHelper, (HTMLFrameElement|HTMLIFrameElement|null)): HTMLDocument
goog.dom.DomHelper.prototype.getFrameContentDocument =
^
/Users/Jan/.../closure-library/closure/goog/fx/animation.js:255:
WARNING - mismatch of the stop property type and the type of the property it overrides from superclass goog.fx.TransitionBase
original: function (this:goog.fx.TransitionBase, boolean=): ?
override: function (this:goog.fx.Animation, boolean): ?
goog.fx.Animation.prototype.stop = function(gotoEnd) {
^
Nothing breaks as far as I can tell. The warnings do not pop for just one project but I do use the library the same way for all.