Skip to content

linter: oxc incorrectly emits oxc(eslint(no-var)) for declare global block in TypeScript code #15503

@hamirmahal

Description

@hamirmahal

What version of Oxlint are you using?

1.25.0

What command did you run?

npx oxlint

What does your .oxlintrc.json config file look like?

{
	"categories": {
		"restriction": "deny"
	}
}

What happened?

oxc incorrectly emits

Unexpected var, use let or const instead.
help: Replace var with let or const

oxc eslint(no-var)

for a declare global block in TypeScript code, like

declare global {
	var __SPECIAL_VALUE__: boolean | undefined;
}

If we update that code to

declare global {
	const __SPECIAL_VALUE__: boolean | undefined;
}

and try accessing

globalThis.__SPECIAL_VALUE__

later, we get

Property '__SPECIAL_VALUE__' does not exist on type 'typeof globalThis'.ts(2339)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions