1

I'm adding functions to this library that accessarugments.callee. Within the project's tsconfig.json I set "strict": false, causing this mini test to work:

    function check() {
        console.log(arguments.callee.name);
    }

That works. Now if I import the part of the library that I want to run tests on like this:

    import {isNumberInRange} from './is';

    function check() {
        console.log(arguments.callee.name);
    //    isNumberInRange(1,0,1);
    }
    check();

Even if I don't actually run the isNumberInRange function typescript still logs this:

TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at check (/home/ole/Github/is/src/test.ts:4:27)

What else do I need to do to enable calling arguments.callee.name?

Ole
  • 41,793
  • 59
  • 191
  • 359

1 Answers1

3

In addition to "strict": false also add "noImplicitUseStrict": true.

TypeScript will add strict mode in on it's own, and this needs to be disabled.

How to do this has been answered already here: prevent-use-strict-in-typescript

You can do that by compiling with the --noImplicitUseStrict compiler option—add "noImplicitUseStrict": true to "compilerOptions" in tsconfig.json. Doing so will prevent the compiler from emitting "use strict".

Ole
  • 41,793
  • 59
  • 191
  • 359
Steven Stark
  • 1,249
  • 11
  • 19