Questions tagged [strict]
Mode used in languages such as Javascript and Perl to be able to code with a restricted version of those languages.
492
questions
-3
votes
3
answers
74
views
Enforcing strict comparison for bool return type functions in PHP [closed]
Given:
if ($var) is a loose comparison as in if ($var == true)
strict comparison will be
if ($var === true)
should also bool return type function be explicitly enforced?
es:
if (isset($var) === true) ...
1
vote
1
answer
25
views
TypeScript Argument Error with strictNullChecks when Checking Nested Object Property
I am facing an issue with TypeScript's strictNullChecks setting. I have a function handleAction which expects an argument of type MyType.
type MyType = {
prop: MyEnum;
// ... other properties
};
...
0
votes
1
answer
44
views
How to make ANTLR parser strict?
Below is a simple ANTLR grammar:
grammar EXAMPLE;
document
: Name+ EOF ;
Name
: 'k'+ ;
The generated antlr parser accepts any string that contains substring 'k'.
However, I ...
2
votes
0
answers
52
views
PHP why is array_filter ignoring strict_types? [duplicate]
per 3v4l: https://3v4l.org/qeU8s , In every version of PHP between 7.0.0 and 8.2.9, why is this code
<?php
declare(strict_types=1);
$arr = ["1"];
$filtered = array_filter($arr, function (...
0
votes
0
answers
5
views
Script to automate the strict compiler option
I want to write a script that generates the strict compiler errors. The output should be similar to the results as in
Save complete complier output to txt or csv with "strict":true compiler ...
0
votes
1
answer
22
views
Save complete complier output to txt or csv with "strict":true compiler option in typescript
I have the following code in tsconfig.json which is opened in visual studio.
{
"CompileOnSave":false,
"CompilerOptions":{
"strict": true,
"skipLibCheck":true
},
...
0
votes
1
answer
43
views
in perl, get() works with string, but not with a variable containing the string [closed]
Why can't I pass the URL string to "get" in a variable?
#use strict; use warnings;
use LWP::Simple;
my $hxUrl;
my $Page;
$hxUrl="https://finance.yahoo.com/quote/SPY/history?period1=...
0
votes
1
answer
44
views
MatMenuTrigger while using strict settings
Edit: We want to use strict alongside more compiler flags
Original:
For some background info, we are trying to cleanup our huge internal angular system, some of the choices we made were to setup ...
0
votes
0
answers
26
views
Wijmo FlexGrid component is blank react 18 strict mode
Using react 18.2.0 in strict mode and the newer runtime, the FlexGrid component from wijmo shows the table as blank, even the click handlers are working, at least once u click on the rows, no matter ...
0
votes
1
answer
145
views
React issue. Rendering twice with strictMode
first of all im new in react and i've read the documentation, the rules of hooks. https://reactjs.org/docs/hooks-rules.html#explanation
I know the component es mounted and unmounted with the ...
0
votes
0
answers
227
views
why am I getting javascript error: use strict: not found and Syntax error: word unexpected (expecting ")")
Compiling Script files using npm start, getting errors: use strict: not found
Syntax error: "(" unexpected or Syntax error: word unexpected (expecting ")")
Here is my code, index....
0
votes
2
answers
211
views
Where to set angular strictness flags that configure how strict strictTemplates is?
I am currently converting our application to strictTemplates, and we are comming up with a huge amount of errors, some of them are more relevant than others.
So i wanted to configure the strictness of ...
0
votes
1
answer
27
views
Strict mode in recycler view adapter -> inflate method
I've activated strict mode in my APP, and I find a strange thing:
when I create a new adapter for my recycler view, the system logs a [StrictMode policy violation; ~duration=352 ms: android.os....
1
vote
0
answers
35
views
Selected value being read with lag
I am trying to learn React by doing. Somehow, I am missing something very silly here.
I have 2 calendars in my code. And I have used console logging to debug, as can be seen in the code.
import React, ...
0
votes
1
answer
55
views
How do you check for undefined when using an expression as the property name of object in Typescript strict mode?
Consider the following code:
type Props = 'foo' | 'bar';
type ParRec = Partial<Record<Props, string>>;
function doSomething (item: ParRec) {
const props: Props[] = ['foo', 'bar'];
...
2
votes
1
answer
2k
views
TypeScript complains «'callee' may not be accessed on strict mode functions» even with alwaysStrict set to false
I'd like to be able to pepper an app with a custom log function when debugging, profiling or just familiarizing myself with the code, using arguments.callee.name so I don't have to type the enclosing ...
1
vote
1
answer
436
views
strict mode typescript checks fails from tsconfig.json [duplicate]
I have a simple typing error detected with cli flag --strict
$ ./node_modules/.bin/tsc --strict main.ts
main.ts:6:5 - error TS2322: Type 'null' is not assignable to type 'Person'.
6 return null;
...
0
votes
1
answer
91
views
strictNullChecks: true in my tsconfig.json vs. not null assertion operator usage
The strictNullChecks: true in the tsconfig.json!
Is it allowed to use a not null assertion operator if we are sure the object is not null and undefined?
In the following example, where the type ...
0
votes
1
answer
944
views
JS strict mode enabling in Visual Studio Code
To enable strict mode in JavaScript it's needed to insert 'use strict' to a script.
If I have several scripts, I need to add it to all.
Maybe it can be added only once in settings?
Not found any ...
1
vote
1
answer
924
views
Mediawiki error: Lua error in package.lua at line 80: module 'strict' not found
I'm try to install Mediawiki on local host, and working with Lua. I try to export one page from Wikipedia, for example: https://en.wikipedia.org/wiki/Maize, and re-import it into the local system.
...
0
votes
0
answers
61
views
Nested Object States With React Strict Mode
I just wonder what's the best practice here. I noticed that React strict mode calls a state setter twice, so if I have e.g.
setArray(function(arr){
arr.push(arr.length);
return [...arr];
})
it ...
0
votes
1
answer
203
views
Map data structure in strict mode
I am using strict mode for the following code.
Trying to assign an object value from a Map.
It is granted that the value I am getting from the Map isn't undefined but strict mode giving the following ...
1
vote
1
answer
291
views
Why typescript enum is seen as possibly undefined in strict mode? How to fix?
I'm getting an error from Typescript (4.8.2) STRICT:
Argument of type 'State | undefined' is not assignable to parameter of type 'State'.
Type 'undefined' is not assignable to type 'State'. ts(2345)
...
0
votes
0
answers
306
views
Efficient type checking for multiple values in an object in TypeScript (TS2322)
I'm working on implementing strict type checking in TypeScript (TS2322). When writing the code like this, the IDE (IntelliJ) correctly validates that these variables are defined as strings:
if (typeof ...
1
vote
1
answer
183
views
How do I use Set-StrictMode to only set strict mode for the private scope?
My script needs to call third party scripts that do not work under strict mode. Right now I explicitly disable the strict mode in my script for these calls:
Set-StrictMode -Version 3
…my script here…
...
0
votes
1
answer
28
views
Typescript create uber-strict types
If I create a custom type such as:
type LowercaseString = string
And then use it in a function like this:
function displayLowercaseString(input: LowercaseString) {
...
}
displayLowercaseString('...
0
votes
1
answer
96
views
Strict Properties Without Option Strict On
When Option Strict is turned Off, which is the default for my application, VB will automatically convert the value when property is String. It appears to call the toString() of the incoming value's ...
0
votes
1
answer
193
views
Constructor in Strict Mode [closed]
I've been searching a lot for an answer to this REALLY simple question, but I cannot find it:
" How to create constructors in strict mode ? "
fetch(`https://restcountries.com/v3.1/name/${...
1
vote
1
answer
438
views
Why does code inside useEffect run twice for the first render? [duplicate]
Console.log runs twice. Underneath said it is to reason Strict Mode:
React Hooks: useEffect() is called twice even if an empty array is used as an argument
StrictMode renders components twice (on dev ...
2
votes
1
answer
58
views
How to use `our` class variables with `UNITCHECK` correctly with `use strict`?
As Perl constants are somewhat strange to use, I decided to implement my "class variables" as our variables, just like:
our $foo = '...';
However when I added a UNITCHECK block using the ...
0
votes
1
answer
880
views
PHP typed class members array of string [duplicate]
What is the proper syntax to declare a type string[] attribute in php?
protected string[] $array_of_strings;
does gives an error at '['
0
votes
0
answers
447
views
Type 'unknown' is not assignable to other type, when strict mode is true
I have type error.
Exists child component Pagination with type of props:
interface BaseProps {
url: string;
rowKey: string;
renderItem: (item: unknown) => React.ReactNode;
params?: Record&...
4
votes
2
answers
2k
views
How to make existing angular application "fully strict" step by step?
I have an existing Angular Application that started development at the time of Angular 4, now it's on Angular 12. But at the time of development, the strict mode was not enabled. Now after the ...
6
votes
1
answer
2k
views
Strict Mode Issue with Binding Arguments
I have an issue with running a test on my files. Would love if someone more experienced could help me out here.
the following code gives me this error:
error Parsing error: Binding arguments in ...
0
votes
1
answer
69
views
PHP - create strict typed Map dynamically (multidimensional)?
I need to be able to create strict typed maps dynamically. Like this:
$map = new Map( 'string,array<string,int>', [
'foo' => [
'bar' => 1
]
];
I have seen a lot of solutions for ...
4
votes
2
answers
182
views
Stricter than strict mode?
I recently produced a stupid bug:
"use strict";
function doSomething() {
let testObject = {a: "foo", b: "bar", parent: "bla"};
if (parent in ...
1
vote
1
answer
522
views
Flutter SQLite Database enforcing strict data types
Traditionally sqlite allowed any data type to be submitted to any field in a database table for example you could submit an INTEGER to a TEXT field. However strict table data types are now officially ...
1
vote
1
answer
718
views
Datefinder.find_dates throws out dates for any number in the text, but "strict=True" does not work
I am trying to pull dates from news and government announcement texts I have scraped on Covid-19 in Hawaii. I have run a sample program on a dummy data set, and find dates generated for every number ...
1
vote
1
answer
135
views
How do I fix "Uncaught TypeError: can't access property "whenGET", $httpBackend is undefined"?
I am trying to use the following https://embed.plnkr.co/plunk/pWNOdA in a project that uses strict-DI.
In the app-mockbackend.js you can see the following setup -
angular.module('app').run(function($...
0
votes
0
answers
145
views
Global symbol "$global_var1" requires explicit package name (did you forget to declare "my $global_var1"?) at module1.pm [duplicate]
I have two module files, in module2 I have a global variable,
$global_var1 = 'global_var_sub';
sub global_var_sub
{
return something;
}
now, in module1, I do use module2; and then try to print ...
1
vote
3
answers
573
views
Angular and Local Storage in strict mode
I'm using Angular 12, which automatically adds strict mode to your projects. I was going through a tutorial to set up authentication in my project, but strict mode doesn't allow me to set it up as it ...
0
votes
0
answers
925
views
How can I run specific tests or everything without strict mode in jests
Is there a way to disable the strict mode (although I didn't turn it on) for the specific test?
I have a function that pushes the arguments object to an array.
In my test, I need to check the array ...
1
vote
1
answer
1k
views
how can I change a tsconfig property for a specific folder in my application?
This is the structure of my project
app/
|--src/
|--folder
|--tsconfig.json
here is my tsconfig file
{
"compilerOptions": {
"target": "es5",
&...
8
votes
2
answers
1k
views
Is this strict aliasing violation? Can any type pointer alias a char pointer?
I'm still struggling to understand what's allowed and not allowed with strict aliasing. With this concrete example is it violation of strict aliasing rule? If not, why? Is it because I placement new a ...
3
votes
3
answers
176
views
Access Fully Qualified Variable Name from Variable in Perl Strict Mode
I have a series of modules that perform output functions for my scripts. Sometimes the module is called directly -- it is called View -- and sometimes a child class that extends it is used instead (...
-2
votes
1
answer
1k
views
How to use typeof operator to check if function is a string
Task Instructions
Your task in this activity is to create a function called isString that takes three arguments (a, b, c). This function does the following:
It uses the typeof operator and strict ...
3
votes
1
answer
5k
views
Why is a Typescript project reference using the parent tsconfig file instead of the reference's own tsconfig file?
I have two projects: app and lib. app depends on lib.
app is a strict Typescript project, lib does not work with strict.
I've wired them together using Typescript Project References:
./tsconfig.json
...
0
votes
1
answer
469
views
Documentation for C# Project Property: `<Features>strict</Features>`
I want to develop C# with all possible warnings from Microsoft turned on, and I found this answer that says to add <Features>strict</Features> to my .csproj file.
However, before I start ...
0
votes
1
answer
27
views
Scalar type checking does not work in python
Scalar type checking does not work in Python (v 3.8.6).
def test(x: int) -> int:
print(type(x))
return x
a = test('a')
It doesn't matter at all that there is no int as an input parameter. ...
4
votes
1
answer
105
views
Why do some variables require initialization and some don't in the same script?
I am experimenting with Perl, and have written the following quadratic equation solver.
#! perl
use strict;
use Math::Complex;
use v5.22;
say "Quadratic Equation Solver";
print "Enter ...