From ce01225a700aff5b437d46f21161e5f557050e12 Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Mon, 17 Oct 2022 11:29:39 -0300 Subject: [PATCH] Fix types not working properly when using `moduleResolution: 'node16'` (#5108) * Fix imports failling under `moduleResolution: node16` * Add changeset * Revert comment about Vite 4 --- .changeset/olive-jeans-shout.md | 5 +++++ packages/astro/astro-jsx.d.ts | 10 +++++----- packages/astro/config.d.ts | 2 +- packages/astro/env.d.ts | 2 +- packages/astro/package.json | 5 ++++- 5 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 .changeset/olive-jeans-shout.md diff --git a/.changeset/olive-jeans-shout.md b/.changeset/olive-jeans-shout.md new file mode 100644 index 0000000000..423b11e00f --- /dev/null +++ b/.changeset/olive-jeans-shout.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix types not working properly when using `moduleResolution: 'node16'` diff --git a/packages/astro/astro-jsx.d.ts b/packages/astro/astro-jsx.d.ts index 893b92b2f7..aa7c0a5730 100644 --- a/packages/astro/astro-jsx.d.ts +++ b/packages/astro/astro-jsx.d.ts @@ -23,12 +23,12 @@ declare namespace astroHTML.JSX { children?: Children; } - type AstroBuiltinProps = import('./dist/@types/astro').AstroBuiltinProps; - type AstroBuiltinAttributes = import('./dist/@types/astro').AstroBuiltinAttributes; - type AstroDefineVarsAttribute = import('./dist/@types/astro').AstroDefineVarsAttribute; - type AstroScriptAttributes = import('./dist/@types/astro').AstroScriptAttributes & + type AstroBuiltinProps = import('./dist/@types/astro.js').AstroBuiltinProps; + type AstroBuiltinAttributes = import('./dist/@types/astro.js').AstroBuiltinAttributes; + type AstroDefineVarsAttribute = import('./dist/@types/astro.js').AstroDefineVarsAttribute; + type AstroScriptAttributes = import('./dist/@types/astro.js').AstroScriptAttributes & AstroDefineVarsAttribute; - type AstroStyleAttributes = import('./dist/@types/astro').AstroStyleAttributes & + type AstroStyleAttributes = import('./dist/@types/astro.js').AstroStyleAttributes & AstroDefineVarsAttribute; // This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework diff --git a/packages/astro/config.d.ts b/packages/astro/config.d.ts index fab3fe946f..6e081a2242 100644 --- a/packages/astro/config.d.ts +++ b/packages/astro/config.d.ts @@ -1,5 +1,5 @@ type ViteUserConfig = import('vite').UserConfig; -type AstroUserConfig = import('./dist/@types/astro').AstroUserConfig; +type AstroUserConfig = import('./dist/@types/astro.js').AstroUserConfig; /** * See the full Astro Configuration API Documentation diff --git a/packages/astro/env.d.ts b/packages/astro/env.d.ts index 10a61b06f0..659f2972b8 100644 --- a/packages/astro/env.d.ts +++ b/packages/astro/env.d.ts @@ -4,7 +4,7 @@ // As such, if the typings you're trying to add should be available inside ex: React components, they should instead // be inside `client-base.d.ts` -type Astro = import('./dist/@types/astro').AstroGlobal; +type Astro = import('./dist/@types/astro.js').AstroGlobal; // We have to duplicate the description here because editors won't show the JSDoc comment from the imported type // However, they will for its properties, ex: Astro.request will show the AstroGlobal.request description diff --git a/packages/astro/package.json b/packages/astro/package.json index 805f92ac19..c3549db859 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -37,7 +37,10 @@ "./tsconfigs/*": "./tsconfigs/*.json", "./jsx/*": "./dist/jsx/*", "./jsx-runtime": "./dist/jsx-runtime/index.js", - "./config": "./config.mjs", + "./config": { + "types": "./config.d.ts", + "default": "./config.mjs" + }, "./app": "./dist/core/app/index.js", "./app/node": "./dist/core/app/node.js", "./client/*": "./dist/runtime/client/*",