Skip to content

update type generation script #8712

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

Merged
merged 38 commits into from
Jun 14, 2023
Merged

update type generation script #8712

merged 38 commits into from
Jun 14, 2023

Conversation

Rich-Harris
Copy link
Member

This PR looks bigger than it is because it incorporates version-4 commits that aren't yet in sites. We can't just merge version-4 into sites because the doc generation will break if we do.

It's not a 1:1 replacement yet (and there may be some changes needed to dts-buddy, e.g. removing unnecessary _1 suffixes from generic argument names), but it's close. We should probably put the logic in site-kit since it's duplicated between here and kit.svelte.dev

gtm-nayan and others added 7 commits June 7, 2023 19:22
* initialize playground

* pnpm up

* tidy up git ignore

* remove fluff

* format

* rm readme

* fix jsconfig error

* add skip-worktree instructions

* reload hack

* simplify

* use rollup

* ughh

* add flag for SSR

* ...

* simplify further

* configure launch.json

* add debugger info to readme

* remove vm modules flag

* use replaceAll instead of replace

* tidy up

* fix: make it run

* add watch to launch config
* use dts-buddy

* remove debug output

* remove existing type generation script

* fix package.json

* update gitignore

* bump dts-buddy

* remove unused action entry point

* add svelte/compiler and svelte/types/compiler/preprocess modules

* bump dts-buddy

* annoying

* changeset

* bump dts-buddy

* get rid of .d.ts files

* another one

* Update packages/svelte/package.json

Co-authored-by: gtmnayan <[email protected]>

---------

Co-authored-by: Rich Harris <[email protected]>
Co-authored-by: gtmnayan <[email protected]>
* fix: export ComponentType

* ughh

* changeset
* fix: derived store types

* changeset
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@Rich-Harris
Copy link
Member Author

Rich-Harris commented Jun 8, 2023

deleted comment, all tasks were addressed

@PuruVJ
Copy link
Collaborator

PuruVJ commented Jun 8, 2023

Ah yeah, many are because of extra logic I added to this compared to kit site. Do you mind if I directly push to this branch with appropriate changes.

About the SvelteComponent_1, can't that be fixed in dts-buddy?

@Rich-Harris
Copy link
Member Author

Do you mind if I directly push to this branch with appropriate changes.

go right ahead, i'm not in the branch at the moment

About the SvelteComponent_1, can't that be fixed in dts-buddy?

i think that would be best, yeah. i'm not sure what it's doing there in the first place. will take a look when i get a chance

@benmccann benmccann added this to the 4.x milestone Jun 9, 2023
@PuruVJ
Copy link
Collaborator

PuruVJ commented Jun 10, 2023

This does require changes at dts-buddy level. many types and generics are sufficed with this 🤔

CleanShot 2023-06-10 at 16 42 55@2x

Also I noticed that SvelteComponentTyped's comments are not copied over, which removes the deprecated warning

Source:
CleanShot 2023-06-10 at 16 47 23@2x

Output:
CleanShot 2023-06-10 at 16 46 33@2x

Other than that, I removed the $$_attribute from Action, and reduced prettier printWidth to 60 for the code snippets, to make em more readable

@PuruVJ
Copy link
Collaborator

PuruVJ commented Jun 12, 2023

svelte/compiler doesn't work either. twoslash says it can't find svelte/compiler, whereas all other submodules are easily found.

UPDATE: None of the submodules work now. I cleared the cache in node_modules/.snippets and nothing's working now

Error compiling snippet in 04-compiler-and-api/01-svelte-compiler.md
## Code

'''js
// @filename: ambient.d.ts
/// <reference types="svelte" />
/// <reference types="svelte/action" />
/// <reference types="svelte/compiler" />
/// <reference types="svelte/easing" />
/// <reference types="svelte/motion" />
/// <reference types="svelte/transition" />
/// <reference types="svelte/store" />
/// <reference types="svelte/action" />
// @esModuleInterop

// @filename: ambient.d.ts
declare global {
  var source: string
}

export {}

// @filename: index.ts
// ---cut---
import { compile } from 'svelte/compiler';

const result = compile(source, {
  // options
});
'''
TwoslashError: 
## Errors were thrown in the sample, but not included in an errors tag

These errors were not marked as being expected: 2307. 
Expected: // @errors: 2307

Compiler Errors:

index.ts
  [2307] 37 - Cannot find module 'svelte/compiler' or its corresponding type declarations.
Please report this to https://github.com/markedjs/marked.
    at validateCodeForErrors (/Users/puruvijay/Projects/svelte/node_modules/.pnpm/@[email protected]/node_modules/@typescript/twoslash/dist/twoslash.cjs.development.js:280:18)
    at Object.twoslasher (/Users/puruvijay/Projects/svelte/node_modules/.pnpm/@[email protected]/node_modules/@typescript/twoslash/dist/twoslash.cjs.development.js:873:5)
    at Proxy.runTwoSlash (/Users/puruvijay/Projects/svelte/node_modules/.pnpm/[email protected][email protected]/node_modules/shiki-twoslash/dist/shiki-twoslash.cjs.development.js:870:26)
    at syntax_highlight (/Users/puruvijay/Projects/svelte/sites/svelte.dev/src/lib/server/markdown/renderer.js:878:43)
    at code (/Users/puruvijay/Projects/svelte/sites/svelte.dev/src/lib/server/markdown/renderer.js:114:15)
    at Renderer.code (/Users/puruvijay/Projects/svelte/sites/svelte.dev/src/lib/server/markdown/renderer.js:207:31)
    at renderer.<computed> [as code] (file:///Users/puruvijay/Projects/svelte/node_modules/.pnpm/[email protected]/node_modules/marked/lib/marked.esm.js:2782:41)
    at Parser.parse (file:///Users/puruvijay/Projects/svelte/node_modules/.pnpm/[email protected]/node_modules/marked/lib/marked.esm.js:2309:32)
    at parse (file:///Users/puruvijay/Projects/svelte/node_modules/.pnpm/[email protected]/node_modules/marked/lib/marked.esm.js:2243:19)
    at file:///Users/puruvijay/Projects/svelte/node_modules/.pnpm/[email protected]/node_modules/marked/lib/marked.esm.js:2675:18 {
  title: 'Errors were thrown in the sample, but not included in an errors tag',
  description: 'These errors were not marked as being expected: 2307. \n' +
    'Expected: // @errors: 2307',
  recommendation: 'Compiler Errors:\n' +
    '\n' +
    'index.ts\n' +
    "  [2307] 37 - Cannot find module 'svelte/compiler' or its corresponding type declarations.",
  code: '## Code\n' +
    '\n' +
    "'''js\n" +
    '// @filename: ambient.d.ts\n' +
    '/// <reference types="svelte" />\n' +
    '/// <reference types="svelte/action" />\n' +
    '/// <reference types="svelte/compiler" />\n' +
    '/// <reference types="svelte/easing" />\n' +
    '/// <reference types="svelte/motion" />\n' +
    '/// <reference types="svelte/transition" />\n' +
    '/// <reference types="svelte/store" />\n' +
    '/// <reference types="svelte/action" />\n' +
    '// @esModuleInterop\n' +
    '\n' +
    '// @filename: ambient.d.ts\n' +
    'declare global {\n' +
    '  var source: string\n' +
    '}\n' +
    '\n' +
    'export {}\n' +
    '\n' +
    '// @filename: index.ts\n' +
    '// ---cut---\n' +
    "import { compile } from 'svelte/compiler';\n" +
    '\n' +
    'const result = compile(source, {\n' +
    '  // options\n' +
    '});\n' +
    "'''"
}

@Rich-Harris
Copy link
Member Author

The _1 suffixes are fixed by #8727

Rich-Harris and others added 2 commits June 13, 2023 11:30
* put comment in right place

* bump dts-buddy

---------

Co-authored-by: Rich Harris <[email protected]>
@PuruVJ
Copy link
Collaborator

PuruVJ commented Jun 13, 2023

Nice!!

Are you facing these same errors as well? Where it can't find svelte modules at all? I thought it was something with twoslash, but then I went into the d.ts files inside type-gen folder that we had and even then VSCode was erroring out

@PuruVJ PuruVJ marked this pull request as ready for review June 14, 2023 07:35
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.

5 participants