-
Notifications
You must be signed in to change notification settings - Fork 414
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
Fails to compile typescript enums #761
Comments
More dataThe code above does not build neither for Linaria versions 3-beta, 2, 1.4, 1.3 with both evaluators Now, take the import { Color } from './constants/style'
const H1 = styled.h1`
color: ${Color.black};
` And it builds for Linaria 1.4 and 2.1 as long as evaluator is set to |
Hi @dewey92 and @PierreGUI I've fixed that issue, but I don't sure yet, that the fix doesn't break anything else. I need a couple of days for additional testing. |
@Anber Thanks for the fix! We can also help you test your fix 🙂 We'll let you know if we encounter problems, considering we use enums a lot in our linaria codebase |
Ok! |
Published |
Super thanks @Anber! I think it solves the enum problem, great job! However, I found a new interesting bug in our codebase: It's when you import an enum: /* constants/styles.ts */
export enum Size {
xs = 'xs',
...
xxl = 'xxl'
}
/* another_constants/avatar.ts */
import { Size } from 'constants/styles'
export const AvatarSize = {
[Size.xs]: 20,
...
[Size.xxl]: 50
}
/* Component.tsx */
import { styled } from '@linaria/react'
import { AvatarSize } from 'nother_constants/avata'
const Avatar = styled.div`
height: ${AvatarSize.xxl}px;
` The error message:
|
Hmm… I couldn't reproduce it but I'll try again later today. Thank you for the report! :) |
@Anber will try next week! Thanks for letting me know 😉 |
@Anber Thanks for creating a patch! After updating to I've prepared a minimal reproducable repo if you want to fiddle around https://github.com/dewey92/linaria-v3-iife-repro. Sorry if this is the least I could do to help you pinpoint the problem |
Hi @dewey92!
https://www.typescriptlang.org/play?#code/KYOwrgtgBAwg9gGzgJygbwFAEgBGCCGAxgNZQC8UA5AMQAM9lGAvhkA |
@Anber My bad! With the latest patch my issue-reproduction repo does indeed work. But in our project it's still not compiling, complaining it's undefined. Let me close the issue until I figure out the exact problem. Thanks once again 🙂 |
Environment
Description
TS enums are always evaluated to
undefined
, producing this error:Reproducible Demo
You can also try replacing that enum with the transpiled code and it will still fail:
So it seems like it doesn't run IIFEs
Other configs
webpack
.babelrc
The text was updated successfully, but these errors were encountered: