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

[fix] add app.d.ts to template #4244

Closed
wants to merge 2 commits into from

Conversation

baseballyama
Copy link
Member

fix: #4241

After committing #4118 , type checker can not find ambient module.
It seems that tsconfig.json can only read ambient module that is a subdirectory of it.
(Now tsconfig.json is at inside of .svelte-kit folder but ambient module is inside of ./node_modules/@sveltejs/kit/types.)
So AFAIK, we need to tell ambient module somehow.
So I added app.d.ts at root.
If you have a better way, please correct me!

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2022

🦋 Changeset detected

Latest commit: d925490

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
default-template Patch
create-svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dummdidumm
Copy link
Member

Can't validate this myself today but I would be surprised if "extends" prevents app.d.ts from including the modules. AFAIK tsconfig is merged first and then loaded as if everything is in the tsconfig that extends the other.

@baseballyama
Copy link
Member Author

To be honest I am confused by this. Since .svelte-kit/tsconfig.ts is used via jsconfig.json, I was expecting node_modules to be treated as a subdirectory.
But in fact, it seems not.

if "extends" prevents app.d.ts from including the modules.

Maybe I didn't get the meaning of this.
Without the PR, the template doesn't provide app.d.ts. And after adding app.d.ts, type checker recognizes app.d.ts and type checker recognizes the ambient module through it.

@baseballyama
Copy link
Member Author

@Conduitry

Now I'm facing a deploy error that I faced yesterday in my local.
#4239 (comment)
https://app.netlify.com/sites/kit-demo/deploys/622468f183e8a9000860529a#L1048

Maybe yesterday's deploy process used cache or something? (I didn't get why it was succeeded...)
But anyway I think again we need to add @sveltejs/adapter-static ...

@baseballyama baseballyama marked this pull request as draft March 6, 2022 08:30
@baseballyama
Copy link
Member Author

baseballyama commented Mar 6, 2022

This is because while parsing this code, an error occurred inside shiki-twoslash because cannot find module @sveltejs/adapter-static.
https://github.com/sveltejs/kit/blob/master/documentation/docs/13-configuration.md?plain=1#L243

[2307] 20 - Cannot find module '@sveltejs[/adapter-static]()' or its corresponding type declarations.
Please report this to [https://github.com/markedjs/marked]().
    at [/Users/baseballyama/Desktop/git/svelte-contributes/kit/node_modules/.pnpm/]()@typescript+twoslash@3.1.0[/node_modules/]()@typescript[/twoslash/dist/twoslash.cjs.production.min.js:1:12381]()
    at Object.exports.twoslasher ([/Users/baseballyama/Desktop/git/svelte-contributes/kit/node_modules/.pnpm/]()@typescript+twoslash@3.1.0[/node_modules/]()@typescript[/twoslash/dist/twoslash.cjs.production.min.js:1:12593]())
    at exports.runTwoSlash ([/Users/baseballyama/Desktop/git/svelte-contributes/kit/node_modules/.pnpm/shiki-twoslash]()@3.0.2[/node_modules/shiki-twoslash/dist/shiki-twoslash.cjs.production.min.js:1:22890]())
    at code ([file:///Users/baseballyama/Desktop/git/svelte-contributes/kit/sites/kit.svelte.dev/.svelte-kit/output/server/chunks/index-6307d1fd.js:651:26]())
    at Renderer.code ([file:///Users/baseballyama/Desktop/git/svelte-contributes/kit/sites/kit.svelte.dev/.svelte-kit/output/server/chunks/index-6307d1fd.js:788:33]())
    at Renderer.renderer.<computed> [as code] ([file:///Users/baseballyama/Desktop/git/svelte-contributes/kit/node_modules/.pnpm/marked@4.0.5/node_modules/marked/lib/marked.esm.js:2544:41]())
    at Parser.parse ([file:///Users/baseballyama/Desktop/git/svelte-contributes/kit/node_modules/.pnpm/marked@4.0.5/node_modules/marked/lib/marked.esm.js:2157:32]())
    at Parser.parse ([file:///Users/baseballyama/Desktop/git/svelte-contributes/kit/node_modules/.pnpm/marked@4.0.5/node_modules/marked/lib/marked.esm.js:2232:30]())
    at Parser.parse ([file:///Users/baseballyama/Desktop/git/svelte-contributes/kit/node_modules/.pnpm/marked@4.0.5/node_modules/marked/lib/marked.esm.js:2232:30]())
    at Function.parse ([file:///Users/baseballyama/Desktop/git/svelte-contributes/kit/node_modules/.pnpm/marked@4.0.5/node_modules/marked/lib/marked.esm.js:2091:19]())

This PR added js check, therefore I think shiki-twoslash tried to check it but originally module does not exist.
#4011

https://github.com/sveltejs/kit/pull/4011/files#diff-28812e50c84eb6916715a197501054d6481bb671e82a8cf57f75514ff381c22cR80

We may end up registering all adapters in package.jsonof site, but it is important that the documentation be accurate, so we are willing to allow for that.

baseballyama added a commit to baseballyama/kit that referenced this pull request Mar 6, 2022
sveltejs#4011 added @sveltejs/adapter-static .
But sveltejs#4239 removed it.
Then deploy process is failed. (Please see sveltejs#4244 (comment) for more details)
Rich-Harris pushed a commit that referenced this pull request Mar 6, 2022
* add @sveltejs/adapter-static.

#4011 added @sveltejs/adapter-static .
But #4239 removed it.
Then deploy process is failed. (Please see #4244 (comment) for more details)

* workspace:^1.0.0-next.29 -> workspace:*
@baseballyama
Copy link
Member Author

The deployment was successful by incorporating another PR. (#4245)
Therefore, I changed the status to ready for review.

@Rich-Harris
Copy link
Member

I'm not sure I understand this? There's already src/app.d.ts and I just confirmed (in a new project) that it works fine:

image

@Rich-Harris
Copy link
Member

I believe #4295 was the underlying issue, so I'll close this — thanks

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

Successfully merging this pull request may close these issues.

Cannot import from $app/navigation in latest SvelteKit
3 participants