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

TS interfaces? #770

Closed
wclr opened this issue Apr 28, 2018 · 7 comments
Closed

TS interfaces? #770

wclr opened this issue Apr 28, 2018 · 7 comments

Comments

@wclr
Copy link

wclr commented Apr 28, 2018

Expected Behaviour

I wonder why this module doesn't export any TS interfaces (LoaderOptions).

import { LoaderOptions } from 'ts-loader'

Actual Behaviour

Just js code.

@johnnyreilly
Copy link
Member

Sorry you want .d.ts to be emitted too? What's the use case? I'm up for including them if there's a need

@johnnyreilly
Copy link
Member

Feel free to submit a PR

@wclr
Copy link
Author

wclr commented Apr 29, 2018

I use TS webpack config, and some wrappers to configure loaders.

@johnnyreilly
Copy link
Member

Okay - myself I use js for my webpack config. I'm happy to support others with different flows though. Why don't you fork, have a play and submit a PR.

I'm guessing it's just a case of adding declaration: true to the tsconfig.json. let me know your findings

@Hotell
Copy link
Contributor

Hotell commented Jun 7, 2018

Heyo! I have the same problem.
I'm using awesome latest TS 2.9 for type checking js files and with that having type safe configs for webpack, jest etc. right now I have to write my own ambient type definitions for interface LoaderOptions

webpack.config.js

// @ts-check

/**
 * @type {Partial<import('ts-loader').LoaderOptions>}
 */
const tsLoaderOptionsRules = {
  configFile: tsConfig,
  transpileOnly: true
}

/**
 * @type {(env:{production?:boolean})=>import('webpack').Configuration}
 */
const config = (env) => {

  return {
    module: {
      rules: [
        {
          include: resolve(__dirname, 'src'),
          test: /\.tsx?$/,
          loader: 'ts-loader',
          options: tsLoaderOptionsRules
        }
      ]
    },
}

instead I would like to use definitions, which you already have in codebase, just need to be shipped as ambient types with your package. I'm definitely up to sending a PR, if you can point me in right direction.

cheers !

@johnnyreilly
Copy link
Member

So I think it's as simple as adding declaration: true to the tsconfig.json. Want to try and report back? If it's just that then pr with that change and we're done!

@Hotell
Copy link
Contributor

Hotell commented Jun 7, 2018

I'm on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants