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

The plugin isn't working correctly for me and I'm not sure why #238

Closed
fregante opened this issue Oct 3, 2023 · 4 comments
Closed

The plugin isn't working correctly for me and I'm not sure why #238

fregante opened this issue Oct 3, 2023 · 4 comments

Comments

@fregante
Copy link

fregante commented Oct 3, 2023

This isn't a bug report, I'm sure I'm doing something wrong, but it seems that I'm using it correctly:

  • I added the module types to globals.d.ts (see)
  • I added the plugin to tsconfig.json (see)

The issue:

  • the types are exactly those provided in the globals.d.ts file, they don't auto-complete nor does TypeScript complain if I misspell a class name

I also tried:

  • using the exact syntax suggested in the readme instead of Record<string, string>
    • same result
    Screenshot 3
  • removing the plugin from tsconfig.json
    • no change
  • breaking the name of the plugin in tsconfig.json
    • no change, which suggest it's not attempting to read the plugin list

For self reference: Link to my own issue

@fregante
Copy link
Author

fregante commented Oct 3, 2023

Ok I think I figured out why: it's broken when importing via paths alias. Should I open a bug report?

Aliased path (types from globals.d.ts)

Screenshot 7

Relative path (types by typescript-plugin-css-modules)

Screenshot 8

@fregante
Copy link
Author

fregante commented Oct 3, 2023

The issue seems to persist outside the editor view though. This fails with strictNullChecks: true

src/components/formBuilder/preview/FormPreviewFieldTemplate.tsx:51:9 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.

51   const stuff: string = styles.isActive;
           ~~~~~

even if it looks like this in VSC:

Screenshot 9

@mrmckeb
Copy link
Owner

mrmckeb commented Oct 4, 2023

HI @fregante, we do support paths aliases - so long as they are defined in your tsconfig.json file. Many of our users use aliases. If that's not working for you, a reproduction will help us to track down the bug.

However, the plugin currently doesn't work outside of the IDE due to a TypeScript limitation.

This has been an issue for a long time, but there is now hope on the horizon, and as soon as this is supported in TS, we'll make any required changes here.

@fregante
Copy link
Author

fregante commented Oct 4, 2023

Thank you for the info! I'll look forward to the changes in TS.

@fregante fregante closed this as completed Oct 4, 2023
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

No branches or pull requests

2 participants