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

noUndeclaredVariables not properly handling type import #2975

Closed
1 task done
KurtPreston opened this issue May 24, 2024 · 1 comment · Fixed by #3002
Closed
1 task done

noUndeclaredVariables not properly handling type import #2975

KurtPreston opened this issue May 24, 2024 · 1 comment · Fixed by #3002
Assignees
Labels
L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@KurtPreston
Copy link

Environment information

CLI:
  Version:                      1.7.3
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.12.2"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.5.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           true
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Linter:
  Recommended:                  false
  All:                          false
  Rules:                        a11y/noBlankTarget = "off"
                                complexity/noExtraBooleanCast = "off"
                                complexity/noForEach = "off"
                                complexity/noMultipleSpacesInRegularExpressionLiterals = "error"
                                complexity/noStaticOnlyClass = "off"
                                complexity/noUselessCatch = "error"
                                complexity/noUselessConstructor = "error"
                                complexity/noUselessLoneBlockStatements = "error"
                                complexity/noUselessSwitchCase = "off"
                                complexity/noWith = "error"
                                complexity/useFlatMap = "error"
                                correctness/noChildrenProp = "off"
                                correctness/noConstAssign = "error"
                                correctness/noConstantCondition = "off"
                                correctness/noEmptyCharacterClassInRegex = "error"
                                correctness/noEmptyPattern = "off"
                                correctness/noGlobalObjectCalls = "error"
                                correctness/noInnerDeclarations = "off"
                                correctness/noInvalidConstructorSuper = "error"
                                correctness/noNewSymbol = "error"
                                correctness/noNonoctalDecimalEscape = "error"
                                correctness/noPrecisionLoss = "error"
                                correctness/noSelfAssign = "error"
                                correctness/noSetterReturn = "error"
                                correctness/noSwitchDeclarations = "off"
                                correctness/noUndeclaredVariables = "error"
                                correctness/noUnreachable = "error"
                                correctness/noUnreachableSuper = "error"
                                correctness/noUnsafeFinally = "error"
                                correctness/noUnsafeOptionalChaining = "error"
                                correctness/noUnusedLabels = "error"
                                correctness/noUnusedVariables = "error"
                                correctness/useExhaustiveDependencies = "warn"
                                correctness/useHookAtTopLevel = "error"
                                correctness/useIsNan = "error"
                                correctness/useJsxKeyInIterable = "error"
                                correctness/useValidForDirection = "error"
                                correctness/useYield = "error"
                                security/noDangerouslySetInnerHtml = "off"
                                security/noGlobalEval = "error"
                                style/noCommaOperator = "error"
                                style/noImplicitBoolean = "off"
                                style/noNegationElse = "off"
                                style/noRestrictedGlobals = {"level":"error","options":{"deniedGlobals":["bbenchmark","alert","event","fdescribe","fit","isFinite","length","name","open","performance","setInterval","ssuite","status"]}}
                                style/noVar = "error"
                                style/useBlockStatements = "error"
                                style/useConst = "error"
                                style/useForOf = "off"
                                style/useNodejsImportProtocol = "off"
                                style/useNumberNamespace = "off"
                                suspicious/noAsyncPromiseExecutor = "off"
                                suspicious/noCatchAssign = "off"
                                suspicious/noClassAssign = "error"
                                suspicious/noCommentText = "error"
                                suspicious/noCompareNegZero = "error"
                                suspicious/noControlCharactersInRegex = "error"
                                suspicious/noDebugger = "error"
                                suspicious/noDoubleEquals = "error"
                                suspicious/noDuplicateCase = "error"
                                suspicious/noDuplicateClassMembers = "error"
                                suspicious/noDuplicateJsxProps = "error"
                                suspicious/noDuplicateObjectKeys = "error"
                                suspicious/noDuplicateParameters = "error"
                                suspicious/noEmptyBlockStatements = "off"
                                suspicious/noFallthroughSwitchClause = "error"
                                suspicious/noFunctionAssign = "error"
                                suspicious/noGlobalAssign = "error"
                                suspicious/noImportAssign = "error"
                                suspicious/noMisleadingCharacterClass = "error"
                                suspicious/noPrototypeBuiltins = "off"
                                suspicious/noRedeclare = "error"
                                suspicious/noShadowRestrictedNames = "off"
                                suspicious/noThenProperty = "off"
                                suspicious/noUnsafeNegation = "error"
                                suspicious/useGetterReturn = "off"
                                suspicious/useIsArray = "error"
                                suspicious/useValidTypeof = "error"

Workspace:
  Open Documents:               0

Rule name

noUndeclaredVariables

Playground link

https://biomejs.dev/playground/?lintRules=all&code=aQBtAHAAbwByAHQAIAB0AHkAcABlACAAewBHAHIAbwB1AHAAZQBkAEkAdABlAG0ALAAgAE0AWQBfAEEAVABUAFIASQBCAFUAVABFAH0AIABmAHIAbwBtACAAJwAuAC8AdAB5AHAAZQBzACcAOwAKAAoAZQB4AHAAbwByAHQAIAB0AHkAcABlACAARwByAG8AdQBwAEkAdABlAG0AVwBpAHQAaABEAGUAbgBzAGkAdAB5AFAAYQB0AGgAcwA8AFQAPgAgAD0AIABHAHIAbwB1AHAAZQBkAEkAdABlAG0APABUAD4AIAAmACAAewAKACAAIABbAE0AWQBfAEEAVABUAFIASQBCAFUAVABFAF0APwA6ACAAewBbAGsAOgAgAHMAdAByAGkAbgBnAF0AOgAgAGIAbwBvAGwAZQBhAG4AfQA7AAoAfQA7AA%3D%3D

Expected result

I have the following TypeScript code:

import type {GroupedItem, MY_ATTRIBUTE} from './types';

export type GroupItemWithExtraAttribute<T> = GroupedItem<T> & {
  [MY_ATTRIBUTE]?: {[k: string]: boolean};
};

This is valid TypeScript code, however, Biome reports two errors:

The MY_ATTRIBUTE variable is undeclared.
This import is unused.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Conaclos Conaclos added L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels May 25, 2024
@Conaclos
Copy link
Member

This is an issue coning from the semantic model. MY_ATTRIBUTE is declared as a type and its use is resolved as a variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants