Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stylin/ts-loader

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stylin/ts-loader

Stylin TypeScript typing loader module for webpack

  • 0.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
99K
decreased by-0.4%
Maintainers
1
Weekly downloads
 
Created
Source

@stylin/ts-loader

Webpack loader for type auto-generation.


Installation

npm install --save-dev @stylin/ts-loader

In webpack configuration file, place @stylin/ts-loader after @stylin/msa-loader in modules/rules section.

webpack.config.js
module.exports = {
  module: {
    rules: [{
      test: /\.scss$/i,
      use: [
        `@stylin/ts-loader`,
        `@stylin/msa-loader`,
        {loader: MiniCssExtractPlugin.loader}, // it can be `style-loader`
        {loader: `css-loader`, options: {modules: true}},
        `sass-loader`, // optional
      ],
    }],
  }
}

Options

You can customize the generated type names. By default, they are equal:

 propsType: (componentName: string) => `${componentName}Props`
 styledPropsType: (componentName: string) => `Styled${componentName}Props`,

The generated interfaces for User component will be:

💅 *.scss.d.ts
export interface UserProps extends ComponentProps<'div'> {
  status: 'online' | 'busy' | 'offline'
}

export const User: FC<UserProps>

Optional property

For optional component properties, add a question mark as you do in typescript:

/**
  @tag: input
  @component: Input
  disabled?: true
*/

⚠ Webpack watcher

Webpack in watch mode keeps tracking file changes only if it is in the dependency graph. It means if you create a file that is not imported in your application code source, webpack will not track it and will not generate types for it. Before starting coding a new component, first of all, import it into your code and then begin implementation.

FAQs

Package last updated on 19 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc