Questions tagged [strict-mode]

According to Mozilla Developer Network, ECMAScript 5's strict mode is a way to opt in to a restricted variant of JavaScript. Strict mode isn't just a subset: it intentionally has different semantics from normal code.

According to Mozilla Developer Network, ECMAScript 5's strict mode is a way to opt in to a restricted variant of JavaScript. Strict mode isn't just a subset: it intentionally has different semantics from normal code.

112 questions
2
votes
0 answers

Angular strict mode, Ngrx, Jamsmine: mock selector with props

I am currently trying to remove the deprecated selectors in my application. This github issue telling us to declare selector with props as a function. Old way (deprecated): export const getCurrentScope = createSelector(getContextState, (state:…
pred
  • 185
  • 1
  • 14
2
votes
2 answers

Issue with Material-UI Select onChange

I'm using Material-UI select and unable to access select value as I am getting the warning: index.js:1 Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode. Instead, add a ref…
tonyf
  • 34,479
  • 49
  • 157
  • 246
2
votes
1 answer

Why filtering objects which has undefined key gives error in TypeScript strict mode

I have this piece of code written in TypeScript with strict mode enabled. const arr: ({ name?: string })[] = [ { name: 'foo' }, {}, { name: 'bar' } ] function select(): string[] { return arr .filter(e => e.name !==…
Duc Nguyen
  • 836
  • 6
  • 12
2
votes
0 answers

I need help understanding JavaScript "strict mode"

I'm writing a lot more JavaScript these days than I used to. I'm writing a bunch of JavaScript libraries for our product. Wanting to be as careful as possible I'm doing full jsdoc comments, etc. I also have 'use strict'; in all of my libraries and…
Scott Gartner
  • 862
  • 14
  • 22
2
votes
0 answers

SyntaxError: Use of const in strict mode in package loaded with Meteor.npmRequire

I have a Meteor app that requires an NPM package via Meteor.npmRequire that is provided by meteorhacks:npm package. The problem is that this package uses latest ES6 features and npmRequire doesn't, so what I get is Exception while invoking method…
rishat
  • 8,206
  • 4
  • 44
  • 69
2
votes
1 answer

meteor package with coffeescript (and inheritance and strict mode)

I'm trying to build a meteor package in strict mode with coffeescript. The main problem is the use of share as described in the coffeescript meteor package. It seems that I misunderstood the explanation in the link because I get the following…
TC827
  • 31
  • 6
2
votes
0 answers

Why does this not log undefined to the console when run in Chrome's console window?

(function (){ 'use strict'; function Foo() { this.foo = function() { setTimeout(function(){ console.log(this); }, 0); } } new Foo().foo(); }()) If I had not declared strict mode then the global object would be printed to…
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
2
votes
3 answers

There exists a use of arguments.callee with no good alternative?

There is a lot of fallacies about arguments.callee and I'm trying to understand if exists use cases where it really can't be replaced by a viable ES5 strict mode alternative. In the MDN arguments.callee documentation they point a use of…
sergiogarciadev
  • 2,061
  • 1
  • 21
  • 35
2
votes
2 answers

No exception when read-only property set on prototype (Object.defineProperty)

I created a read only property on an object and the appropriate unit tests. //works as expected function OnSelf() { this._val = 'test'; Object.defineProperty(this, 'test', { enumerable: true, configurable: false, get:…
pgreen2
  • 3,601
  • 3
  • 32
  • 59
2
votes
1 answer

What does it mean when I get a strict violation when using the this keyword in javascript?

Can someone give me advice with this. I just started using jslint and I got an error message "strict violation" pointing to the line with "dialog(this)" - function accessLinkClick(e) { e.preventDefault(); $('.accessLink') …
Alan2
  • 23,493
  • 79
  • 256
  • 450
2
votes
2 answers

strict mode return this w/o violation

I want to have my cake and eat it too: I want to have a method that returns this for chaining when it is bound to an object but returns undefined when it is called with a null|undefined scope. This seems to work fine but if you put it into JSLint…
ryanve
  • 50,076
  • 30
  • 102
  • 137
1
vote
0 answers

Semantic-ui-react Dimmer warning: findDOMNode is deprecated in StrictMode

When I use Dimmer from semantic-ui-react I got this warrning: Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of RefFindNode which is inside StrictMode. Instead, add a ref directly to the element you want to…
Evgeny
  • 791
  • 7
  • 15
1
vote
1 answer

'[Symbol.iterator]()' method that returns an iterator

I'm facing this error in my code when using strict mode and I'm not managing it. "message": "Type 'MyType[] | undefined' must have a '[Symbol.iterator]()' method It is happenning in this line of code: const [optionAll, ...options] = await…
cucuru
  • 3,456
  • 8
  • 40
  • 74
1
vote
2 answers

How to detect if code runs in browser in TypeScript?

I'm rewriting ES5 JavaScript code into TypeScript and have code like this: var is_browser = (function() { try { return this === window; } catch (e) { return false; } })(); First thing is that I've got an error from TS…
jcubic
  • 61,973
  • 54
  • 229
  • 402
1
vote
0 answers

Warning: A string ref, ".$.$.$1", has been found within a strict mode tree

I have a simple react app created using create-react-app and I am using react-stonecutter for my Grid. Getting this error in console when I try to pass data into a list item. Also if I don't use a button I can't see anything on the screen (the list…
aahmed31
  • 39
  • 1
  • 7