Skip to content

TypeScript v6: Property 'language' does not exist on type 'never' #3822

@ocavue

Description

@ocavue

What version of starlight are you using?

0.38.3

What version of astro are you using?

6.1.6

What package manager are you using?

pnpm

What operating system are you using?

mac

What browser are you using?

N/A

Describe the Bug

After updating TypeScript to v6, I got the following error when running tsc --noEmit:

> tsc --noEmit

node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_/node_modules/@astrojs/starlight/utils/i18n.ts:196:38 - error TS2339: Property 'language' does not exist on type 'never'.

196  return wellKnownRTL.includes(locale.language) ? 'rtl' : 'ltr';
                                         ~~~~~~~~


Found 1 error in node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_/node_modules/@astrojs/starlight/utils/i18n.ts:196

It seems that this is caused by the fact that TypeScript v6 has a newer DOM library; thus, locale becomes never in this line after the two if statements above.

For a short-term workaround, we can just add a @ts-ignore comment for this line; In the long term, #3572 should be the correct path to avoid such issues.

Link to Minimal Reproducible Example

https://github.com/issueset/starlight-ts-6-issue.git

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🌟 coreChanges to Starlight’s main package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions