Skip to content

assertNoUnits and assertUnit return null instead of the number called on when it passes the assertion #1685

@roydukkey

Description

@roydukkey

I've been trying to work with the JS API, but can seem to figure out why documented methods doesn't seem to be available. I've even tried some of the examples, but they don't seem to be working either.

https://github.com/sass/sass/blob/12cee2dab996a5424160e644ff56f040a42bc0e3/js-api-doc/options.d.ts#L37-L48

Tested using Dart Sass 1.51.0

NoSuchMethodError: method not found: 'assertNumber' on null
       ╷
    14 │         $assert: sum(1, 5)
       │                  ^^^^^^^^^
       ╵
      node_modules/@sass-fairy/math/test/_sum.sass 14:12  @content
      node_modules/sass-true/sass/test/_test.scss 50:5          @content
      node_modules/sass-true/sass/test/_test.scss 24:3          test()
      node_modules/sass-true/sass/test/_test.scss 49:3          it()
      node_modules/@sass-fairy/math/test/_sum.sass 13:2   @content
      node_modules/sass-true/sass/module/_modules.scss 68:5     @content
      node_modules/sass-true/sass/module/_modules.scss 36:3     test-module()
      node_modules/sass-true/sass/module/_modules.scss 67:3     describe()
      node_modules/@sass-fairy/math/test/_sum.sass 9:1    @use
      node_modules/@sass-fairy/math/test/index.sass 16:1      @use
      test/index.sass 24:1                                      root stylesheet

      18 |      functions: {
      19 |              "sum($arg1, $arg2)": (args) => {
    > 20 |                      const value1 = args[0].assertNumber('arg1').value;
         |                                             ^
      21 |                      const value2 = args[1].assertNumber('arg2').convertValueToMatch(arg1, 'arg2', 'arg1');
      22 |                      return new sass.SassNumber(value1 + value2).coerceToMatch(arg1);
      23 |              }

      at Object.sum($arg1, $arg2) (test/index.test.js:20:27)
      at LegacyJavaScriptObject.apply$2 (node_modules/sass/sass.dart.js:24984:23)
      at Object.apply$2$x (node_modules/sass/sass.dart.js:24521:43)
      at _parseFunctions__closure0.call$1 (node_modules/sass/sass.dart.js:85427:30)
      at _EvaluateVisitor1._evaluate0$_runBuiltInCallable$3 (node_modules/sass/sass.dart.js:80667:27)
      at _EvaluateVisitor1._evaluate0$_runFunctionCallable$3 (node_modules/sass/sass.dart.js:80605:55)
      at _EvaluateVisitor_visitFunctionExpression_closure4.call$0 (node_modules/sass/sass.dart.js:82365:25)
      at _EvaluateVisitor1._evaluate0$_addErrorSpan$1$2 (node_modules/sass/sass.dart.js:81186:23)
      at _EvaluateVisitor1._evaluate0$_addErrorSpan$2 (node_modules/sass/sass.dart.js:81204:19)
      at _EvaluateVisitor1.visitFunctionExpression$1 (node_modules/sass/sass.dart.js:80571:22)

Metadata

Metadata

Assignees

Labels

JavaScriptIssues particular to the Node.js distributionbug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions