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

🐛 [Bug] v5.1.1 - Why are there always some weird ts-check issues? #12813

Closed
1 task
JakiChen opened this issue Dec 23, 2024 · 2 comments
Closed
1 task

🐛 [Bug] v5.1.1 - Why are there always some weird ts-check issues? #12813

JakiChen opened this issue Dec 23, 2024 · 2 comments
Labels
needs triage Issue needs to be triaged

Comments

@JakiChen
Copy link

JakiChen commented Dec 23, 2024

Astro Info

Astro                    v5.1.1
Node                     v20.18.0
System                   macOS (x64)
Package Manager          yarn
Output                   server
Adapter                  @astrojs/vercel
Integrations             @storyblok/astro
                         astro-robots
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

不能将类型“string”分配给类型“never”。
Type 'string' is not assignable to type 'never'.

截屏2024-12-23 18 06 05

What's the expected result?

It is expected that the following configuration will not cause ts-check errors in versions 3.0.0 and above and 4.0.0 and above.

// @ts-check
import { defineConfig } from 'astro/config';

import { env, vite } from './config';
import { storyblok, sitemap, robots } from './config/integrations';

// https://astro.build/config
export default defineConfig({
  site: env.SITE_URL,
  //
  scopedStyleStrategy: 'attribute',
  build: {
    inlineStylesheets: 'never',
    assets: '_app',
    format: 'file',
    // assetsPrefix: env.SITE_URL
  },
  image: {
    domains: ['a.storyblok.com'],
  },
  //
  i18n: {
    locales: ['en', 'zh-CN'],
    defaultLocale: 'zh-CN',
  },
  //
  vite,
  //
  ...(await import('./config/vercel/server')).default,
  //
  integrations: [
    storyblok,
    robots,
    sitemap,
  ]
});

Tip

I am beginning to wonder why astro check is removed by default in versions 5.0.0 and above, and what inexplicable changes have been made.

Link to Minimal Reproducible Example

See repository

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 23, 2024
@JakiChen JakiChen changed the title 🐛 [Bug] v5.1.1 - Why are there always some weird ts-check issues? 🐛 [Bug] v5.1.1 - Why are there always some weird ts-check issues? Dec 23, 2024
@sinskiy
Copy link
Contributor

sinskiy commented Dec 23, 2024

Spreading another config after i18n key (..(await import("./config/vercel/server")).default) breaks your types.
There is a simpler and more logical solution for TypeScript, but you don't use TypeScript, so you can move your Vercel config above i18n key:

// @ts-check
import { defineConfig } from "astro/config";

import { env, vite } from "./config";
import { storyblok, sitemap, robots } from "./config/integrations";
+ import vercel from "config/vercel/server"

// https://astro.build/config
export default defineConfig({
  site: env.SITE_URL,
+ ...vercel,
  //
  scopedStyleStrategy: "attribute",
  build: {
    inlineStylesheets: "never",
    assets: "_app",
    format: "file",
    // assetsPrefix: env.SITE_URL
  },
  image: {
    domains: ["a.storyblok.com"],
  },
  //
  i18n: {
    locales: ["en", "zh-CN"],
    defaultLocale: "zh-CN",
  },
  //
  vite,
  //
- ...(await import("./config/vercel/server")).default,
  //
  integrations: [storyblok, robots, sitemap],
});

@JakiChen
Copy link
Author

I've debugged according to astro docs and config and it seems to fix the issue on its own.

So here comes the question: why can't it be configured like before 4.0.0, and the interface hasn't changed much, the question is inexplicable, 5.0.0 is really attractive.

Hopefully, the Astro team will be able to improve the issue or have it clearly documented.

// @ts-check
import { defineConfig } from 'astro/config';

import { env, vite } from './config';
import { favicons, storyblok, sitemap, robots } from './config/integrations';

// https://astro.build/config
export default defineConfig({
  site: env.SITE_URL,
  trailingSlash: 'ignore',
  //
  ...(await import('./config/vercel/server')).default,
  //
  vite,
  integrations: [
    favicons,
    storyblok,
    robots,
    sitemap,
  ],
  //
  compressHTML: import.meta.env.PROD,
  scopedStyleStrategy: 'attribute',
  security: {
    checkOrigin: true,
  },
  build: {
    format: 'file',
    inlineStylesheets: 'never',
    assets: '_app',
    // assetsPrefix: env.SITE_URL
  },
  image: {
    domains: ['a.storyblok.com'],
  },
  //
  i18n: {
    locales: ['zh-CN', 'zh-HK', 'en'], defaultLocale: 'zh-CN'
  },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants