Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Import as recommended by docs not working #2097

Closed
Michael-Murzin opened this issue Jul 1, 2024 · 3 comments
Closed

Import as recommended by docs not working #2097

Michael-Murzin opened this issue Jul 1, 2024 · 3 comments
Labels
bug Things that aren't working right in the library.

Comments

@Michael-Murzin
Copy link

Describe the bug

currently we include this way:

import {SlButton } from '@shoelace-style/shoelace/dist/react';

the docs recommend to include this way:

import SlButton from '@shoelace-style/shoelace/dist/react/button';

the second one does not work for me. my Guess is, that something in my tsconfig.json is not correct for it to work. if it cares, the project is on react with ts initialized trough vite.

Screenshots

Bildschirmfoto 2024-07-01 um 09 18 35

Browser / OS

  • OS: Mac

Additional information

my tsconfig:

{
	"compilerOptions": {
		"target": "ES2020",
		"useDefineForClassFields": true,
		"lib": ["ES2020", "DOM", "DOM.Iterable"],
		"module": "ESNext",
		"skipLibCheck": true,
		"types": ["vitest/globals"],

		/* Bundler mode */
		"moduleResolution": "bundler",
		"allowImportingTsExtensions": true,
		"allowSyntheticDefaultImports": true,
		"resolveJsonModule": true,
		"isolatedModules": true,
		"noEmit": true,
		"jsx": "react-jsx",

		/* Linting */
		"strict": true,
		"noUnusedLocals": true,
		"noUnusedParameters": true,
		"noFallthroughCasesInSwitch": true,

		/* Paths */
		"baseUrl": "./src",
		"paths": {
			"@/*": ["*"]
		}
	},
	"include": ["src"],
	"references": [{ "path": "./tsconfig.node.json" }]
}

@Michael-Murzin Michael-Murzin added the bug Things that aren't working right in the library. label Jul 1, 2024
@KonnorRogers
Copy link
Collaborator

Do you have a reproduction I could look at?

the other option is to try the following:

import SlButton from '@shoelace-style/shoelace/dist/react/button/index.js';

@Michael-Murzin
Copy link
Author

https://stackblitz.com/edit/vitejs-vite-qdetjw
i coppied over my configs and it does work there, maybe i forgot something.
My main reason for asking was because i thought that this way i could resolve my problem below there(line 12)
i Cant use SlAlert in useRef, seems like its not typed well

I found a workaround with a shitty import:

const drawErrorToast = useRef<SlAlertType>(null);
	const [drawError, setDrawError] = useState<DrawLectureErrorCodesEnum | null>(
		null,
	);

import:

import type { default as SlAlertType } from '@shoelace-style/shoelace/dist/components/alert/alert.component.d.ts';

It does work this way without a problem, was just something bothering me a bit und i hoped it would be fixed, do you guys have a suggestion

@KonnorRogers
Copy link
Collaborator

https://stackblitz.com/edit/vitejs-vite-qdetjw i coppied over my configs and it does work there, maybe i forgot something. My main reason for asking was because i thought that this way i could resolve my problem below there(line 12) i Cant use SlAlert in useRef, seems like its not typed well

I found a workaround with a shitty import:

const drawErrorToast = useRef<SlAlertType>(null);
	const [drawError, setDrawError] = useState<DrawLectureErrorCodesEnum | null>(
		null,
	);

import:

import type { default as SlAlertType } from '@shoelace-style/shoelace/dist/components/alert/alert.component.d.ts';

It does work this way without a problem, was just something bothering me a bit und i hoped it would be fixed, do you guys have a suggestion

Its probably either a configuration problem in your bundler or tsconfig, without a reproduction, its hard to say which one is the problem.

@shoelace-style shoelace-style locked and limited conversation to collaborators Jul 15, 2024
@claviska claviska converted this issue into discussion #2108 Jul 15, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

No branches or pull requests

2 participants