Skip to content

variable-exists should be migrated as well #270

Open
@Krathegon

Description

@Krathegon

The migrator changes @import with @use. I'm using the function variable-exists which only checks for variables in the current scope. With @use everything inside this file will be moved to its own namespace, so the check fails.

Example before migration (variable theme is declared nested inside './styles/themes/new/palette/scss'):

@use '@angular/material' as mat;
@import './app/app.theme';
@import './styles/core';
@import './styles/theme';

@if variable-exists(theme) {
  @include mat.all-component-themes($theme);
  @include app-theme(palette.$theme);
}

After migration:

@use '@angular/material' as mat;
@use 'sass:meta';
@use 'app/app.theme';
@use 'styles/core';
@use 'styles/theme';
@use 'styles/themes/new/palette';

@if meta.variable-exists(theme) { // <--- this check fails
  @include mat.all-component-themes(palette.$theme);
  @include app.app-theme(palette.$theme);
}

Expected:

@use '@angular/material' as mat;
@use 'sass:meta';
@use 'app/app.theme';
@use 'styles/core';
@use 'styles/theme';
@use 'styles/themes/new/palette';

@if meta.global-variable-exists(theme, palette) { 
  @include mat.all-component-themes(palette.$theme);
  @include app.app-theme(palette.$theme);
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions