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

Module '"@adobe/leonardo-contrast-colors"' has no exported member 'BackgroundColor'. #175

Closed
pabloromeroelux opened this issue Sep 29, 2022 · 3 comments · Fixed by #207
Closed
Labels
bug Something isn't working

Comments

@pabloromeroelux
Copy link

pabloromeroelux commented Sep 29, 2022

Description

I'm trying to set up a TypeScript/React project and use leonardo-contrast-colors module but I can't import any of the exports.

Apparently this import { BackgroundColor, Color, Theme } from "@adobe/leonardo-contrast-colors"; points to index.d.ts rather than index.js.

I wonder if this is a problem with the package or my project configuration. I can't figure it out.

This is my tsconfig.json:

{
  "compilerOptions": {
    "allowJs": true,
    "esModuleInterop": true,
    "target": "ES2015",
    "jsx": "react",
    "typeRoots": ["./node_modules/@types"],
    "module": "ESNext",
    "moduleResolution": "Node",
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true
  },
  "include": ["src/**/*.ts", "src/**/*.tsx"]
}

Steps to reproduce

npm install @adobe/[email protected]

Then in the code I do the following according to the example in the README.md:

import { BackgroundColor, Color, Theme } from "@adobe/leonardo-contrast-colors";

let gray = new BackgroundColor({
  name: "gray",
  colorKeys: ["#cacaca"],
  ratios: [2, 3, 4.5, 8],
});

let blue = new Color({
  name: "blue",
  colorKeys: ["#5CDBFF", "#0000FF"],
  ratios: [3, 4.5],
});

let red = new Color({
  name: "red",
  colorKeys: ["#FF9A81", "#FF0000"],
  ratios: [3, 4.5],
});

let theme = new Theme({
  colors: [gray, blue, red],
  backgroundColor: gray,
  lightness: 97,
});

but I get this error:
Module '"@adobe/leonardo-contrast-colors"' has no exported member 'BackgroundColor'.

Expected behavior

import { BackgroundColor, Color, Theme } from "@adobe/leonardo-contrast-colors"; should import BackgroundColor, Color, Theme

Leonardo package and version

Tried using both 1.0.0-alpha.13 and 1.0.0-alpha.16
According to #173 the latest release is broken.

Environment

Mac OS

@NateBaldwinDesign
Copy link
Collaborator

@pabloromeroelux this issue I believe relates to #143 as Leonardo currently does not have Typescript support

@xaddict
Copy link

xaddict commented Aug 4, 2023

Just ran into this for nth time with version ^1.0.0-alpha.17

https://stackblitz.com/edit/vitejs-vite-eaduzs?file=main.js

@Jeremy-Walton
Copy link

I also ran into this today. Like the above example with stackblitz, I was using vite with no other dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants