Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
roydukkey opened this issue Apr 27, 2022 · 2 comments · Fixed by #1686
Assignees
Labels
bug JavaScript Issues particular to the Node.js distribution

Comments

@roydukkey
Copy link

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)
@roydukkey
Copy link
Author

Here a runkit of the same issue as above. https://runkit.com/embed/kz2azdg8nhpz

@jathak jathak transferred this issue from sass/sass May 2, 2022
@jathak jathak added bug JavaScript Issues particular to the Node.js distribution labels May 2, 2022
@jathak
Copy link
Member

jathak commented May 3, 2022

The provided runkit doesn't actually report an error calling assertNumber on null, but it does reveal a bug in assertNoUnits where it's not returning the number in question. Re-targeting this issue for that bug.

@jathak jathak changed the title NoSuchMethodError: method not found: 'assertNumber' on null assertNoUnits and assertUnit return null instead of the number called on when it passes the assertion May 3, 2022
jathak added a commit that referenced this issue May 3, 2022
jathak added a commit that referenced this issue May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug JavaScript Issues particular to the Node.js distribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants