Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 04:29
    typescript-bot opened #35161
  • Nov 17 22:27
    jalooc opened #35160
  • Nov 17 21:45
    ivogabe opened #35159
  • Nov 17 21:29
    dsherret edited #35158
  • Nov 17 21:29
    dsherret edited #35158
  • Nov 17 21:25
    dsherret opened #35158
  • Nov 17 21:23
    balupton edited #35157
  • Nov 17 21:19
    balupton edited #35157
  • Nov 17 21:19
    balupton opened #35157
  • Nov 17 20:00
    typescript-bot closed #33749
  • Nov 17 17:57
    idoros reopened #35156
  • Nov 17 16:57
    idoros closed #35156
  • Nov 17 14:28
    jablko synchronize #33645
  • Nov 17 13:37
    idoros edited #35156
  • Nov 17 13:35
    idoros opened #35156
  • Nov 17 13:30
    Leko opened #35155
  • Nov 17 12:17
    BTOdell opened #35154
  • Nov 17 12:08
    vczh opened #35153
  • Nov 17 10:51
    d1y opened #35152
  • Nov 17 06:14
    Jack-Works synchronize #35148
Bruce Pascoe
@fatcerberus
Yeah, you can’t instantiate the generic without calling the function, we were discussing that here recently
Keith Layne
@keithlayne
if you could....
Bruce Pascoe
@fatcerberus
It actually seems like it’s interpreting the angle brackets as comparison operators there, which is odd
Anthony Lukach
@alukach
Is it clear what I'm trying to do? This would be helpful for composing "point free" functions (I'm using ramda). WIthout adding a type to Object.entries, TS thinkings the 1 index of the tuple is any rather than number... Is there a way to achieve my goal?
Keith Layne
@keithlayne
yeah, we all understand what you want
Anthony Lukach
@alukach
Keith Layne
@keithlayne
write a lambda where you specify the type
Anthony Lukach
@alukach
well that's not much fun, but if that's the way it has to be...
Keith Layne
@keithlayne
for your own functions you can sort of work around by writing a generic interface with a call signature.
Bruce Pascoe
@fatcerberus
The compiler sees a syntax error in reality but it always tries to recover and emit valid code so that makes sense
Keith Layne
@keithlayne
whoosh
Bruce Pascoe
@fatcerberus
Huh?
Anthony Lukach
@alukach
@fatcerberus :thumbsup: Oops, I spaced the error about Property 'entries' does not exist on type 'ObjectConstructor'.
Thanzex
@Thanzex

I'm trying to create a package to export some constants and interfaces that we need for a project. The interfaces work just fine, but trying to import and use one of the exported constants gives an error in compilation with webpack.
WARNING in ./src/app/app.component.ts 6:17-20 "export 'CONSTANT' was not found in 'package'
My package is made of:
constants.ts

export const TEST="test";

index.js

import { TEST } from './constants'

module.exports = { TEST }

index.d.ts

export { TEST} from './constants'

After searching for a while i found webpack/webpack#7378 that seems to dive into the problem but i haven't found a soultion yet.
Any ideas?

Keith Layne
@keithlayne
you need to export { TEST } from './constants'
Thanzex
@Thanzex
yup sorry, i re-wrote everything for the message, there are no typos
Keith Layne
@keithlayne
and in the types. Not sure what your mixed case meant. Okay.
Do you have a constants.d.ts?
and are you exporting the constant in JS somewhere?
Thanzex
@Thanzex
in the message i forgot to add the module exports in the js file
@keithlayne what do you mean?
i do not have a constants.d.ts
Keith Layne
@keithlayne
well you're referencing it.
Thanzex
@Thanzex
i do have many more files that contain only interfaces without the *.d.ts file and they work fine with this setup
Keith Layne
@keithlayne
are you writing in mixed js/ts?
Thanzex
@Thanzex
nope, only ts, but the package started as a normal js one
Keith Layne
@keithlayne
if you have tsc emit your declarations you shouldn't have a problem I think.
Unless it's something weird that I don't understand, which is totally possible.
what I was getting at is that tsc will generate a .d.ts per .ts file, and they'll reference each other just like the JS files.
I'm still not clear if you're writing those declarations by hand or not.
Thanzex
@Thanzex
in the issue that i referenced i foud out about isolatedModules. Apparently if you declare a constant in a file and export it, export it fro another file again like export { foo } from './bar' it's like the declaration doesn't exist
it was all done by hand
Keith Layne
@keithlayne
yeah you shouldn't do that, especially when tsc can do it for you. Why isolatedModules? Using babel or something?
sorry, got a meeting for now
Thanzex
@Thanzex
yup, using webpack
sorry, forgot to add
Keith Layne
@keithlayne
yeah I never really use any bundlers on npms. I can imagine some use cases, but I generally let the consumer decide if/how to bundle.
Bruce Pascoe
@fatcerberus
You can't do export from with isolatedModules afaik
With that setting on the compiler is basically looking at each file individually so it's not able to thread the types through
Since you're using webpack I recommend disabling isolatedModules and using ts-loader
Then webpack will compile the TS directly as part of the build
No need for a pre-transpile step
Andrew Hodges
@betawaffle
Is there a reason something like this isn't in lib.es5.d.ts? https://gist.github.com/betawaffle/98f10203a9d97eb43e64468488b3df9a
AnyhowStep
@AnyhowStep
The TS team tends to shy away from using generics and conditional types in the lib.d.ts files, from my experience
Andrew Hodges
@betawaffle
has anybody made a library with extensions like that to get more type information out?
another thing i'd like to see would be the ability to replace any with unknown in a lot of places
like maybe a compiler option to treat any the same as unknown?
Keith Layne
@keithlayne
I'd like that, it wouldn't break some things, but sadly there are places where you need any and unknown wouldn't work.
Andrew Hodges
@betawaffle
yeah, so maybe just putting it in more places in the stdlib, or having an alternate set of libs (or extra lib) which replaces most of the any with unknown
though i'm curious, where is any really needed besides just being a shortcut?