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

Import as recommended by docs not working #2097

Open
Michael-Murzin opened this issue Jul 1, 2024 · 2 comments
Open

Import as recommended by docs not working #2097

Michael-Murzin opened this issue Jul 1, 2024 · 2 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
2 participants