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

move node_modules into root folder [action required] #1408

Merged
merged 3 commits into from
Oct 7, 2021
Merged

move node_modules into root folder [action required] #1408

merged 3 commits into from
Oct 7, 2021

Conversation

dae
Copy link
Member

@dae dae commented Oct 7, 2021

Recommend removing ts/node_modules folder before attempting to
build after this update.

This moves ts/node_modules into the root of the project to work around
#1405 (comment)

Also fixes the sass errors shown when running scripts/svelte-check

Recommend removing ts/node_modules folder before attempting to
build after this update.

This moves ts/node_modules into the root of the project to work around
#1405 (comment)

Also fixes the sass errors shown when running scripts/svelte-check
@dae dae mentioned this pull request Oct 7, 2021
@hgiesel
Copy link
Contributor

hgiesel commented Oct 7, 2021

I think we're getting closer, but this still does not work for me.

With the PR as is, VS Code can now find definitions. E.g. when opening ts/editor/TemplateButtons.svelte, right-clicking on ButtonGroup and "Go to definition", will lead me to bazel-bin/ts/editor/ButtonGroup.svelte.d.ts. This means no more red squiggles, however the component's props/slots/events are still not typechecked.

In comparison to that, when removing "." from rootDirs, like I mentioned in #1405, the Go to definition will lead me to ts/editor/ButtonGroup.svelte, which enables typechecking on props/slots/events for me (this approach works in this PR too, however it still breaks typechecking for tr).

@dae
Copy link
Member Author

dae commented Oct 7, 2021

Sorry, we could have avoided some back and forth if I'd asked you to explain the problem you were experiencing in more detail earlier :-)

The "go to definition" being broken was mentioned in a3d9f90:

The only downside seems to be that cmd+clicking
on a Svelte imports jumps to the .d.ts file instead of the original now;
presumably they'll fix that in a future plugin update.

It appears the Svelte plugin for VS Code will preferentially use the .d.ts file over the .svelte file. It's a trade-off: we lose the ability to jump directly to the .svelte file, but the editor now understands non-default exports from the Svelte module as well, so { components } in editor/index.ts displays correctly for example.

I imagine what's happening when you remove "." from rootDirs is you break the build :-). If you run it from a terminal, you get this:

dae@dip:code/dtop/ts% ../node_modules/.bin/tsc -b  .
lib/i18n_helpers.ts:82:33 - error TS2307: Cannot find module './i18n' or its corresponding type declarations.

82 import type { ModuleName } from "./i18n";
...

That prevents VS Code from reading the generated sources, and presumably prevents it from reading the svelte.d.ts files as well - so it behaves as if there were no svelte.d.ts files, allowing you to jump to their definitions instead.

The reason Bazel still works is because it's manually including args like --rootDir as it builds each project.

As for the lack of type checking, it appears the .d.ts files we're creating do not have the properties set correctly, eg:

import { SvelteComponentTyped } from "svelte";
declare const __propDef: any;
export declare type SpinBoxProps = typeof __propDef.props;
export declare type SpinBoxEvents = typeof __propDef.events;
export declare type SpinBoxSlots = typeof __propDef.slots;
export default class SpinBox extends SvelteComponentTyped<SpinBoxProps, SpinBoxEvents, SpinBoxSlots> {
}
export {};

I believe they were working before, and I suspect if they can be fixed, the editor typechecking will work again - will look into it.

dae added 2 commits October 7, 2021 21:33
I erroneously removed them near the end of the ts_project work, and
didn't realise the properties had broken.
@dae
Copy link
Member Author

dae commented Oct 7, 2021

Does the latest commit resolve your remaining issues?

@hgiesel
Copy link
Contributor

hgiesel commented Oct 7, 2021

Yes! Awesome, look forward to the full typing experience :)

@dae dae merged commit 26e2941 into main Oct 7, 2021
@dae dae deleted the root-node branch October 7, 2021 13:21
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.

2 participants