Search code examples
sassnativescript

Nativescript angular DEPRECATION WARNING: Using / for division is deprecated


During a build of a nativescript-angular app I get a couple of scss warnings for using / for division because it seems it's going to be deprecated soon.

Example:

DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.
    
Recommendation: math.div(blue($color) * 114, 1000)
    
More info and automated migrator: https://sass-lang.com/d/slash-div
    
       ╷
    75 │     $color-brightness: round((red($color) * 299) + (green($color) * 587) + (blue($color) * 114) / 1000);
       │                                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
       ╵
        node_modules\@nativescript\theme\scss\mixins\_utilities.scss 75:76  check-contrast()
        node_modules\@nativescript\theme\scss\mixins\_utilities.scss 84:49  alternate()
        node_modules\@nativescript\theme\scss\variables\_index.scss 56:11   @import
        node_modules\@nativescript\theme\scss\core\_index.scss 2:9          @import
        node_modules\@nativescript\theme\core.scss 8:9                      @import
        src\_app-common.scss 1:9                                            @import
        src\app.android.scss 2:9                                            root stylesheet

NOTE: This warning appears on a couple of places. The warning can be seen on a fresh project generated by the nativescript CLI.

As suggested in the warning message - the divisions could be re-written using math.div.


Solution

  • I solved this issue using the automatic migration from here: https://sass-lang.com/documentation/breaking-changes/slash-div

    done on the node_modeules folder.

    So Idid following:

    1. Install the migrator

    npm install -g sass-migrator

    1. Go to node_modules

    cd node_modules

    1. Migrate (all the scss from node_modules folder)

    sass-migrator division **/*.scss