npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-library-learn

v1.0.0

Published

1. ts-loader 编译的时候可以进行类型检查, 新项目使用 2. babel-loader @/babel/preset-typescript 不能进行检查,旧项目一般使用

Downloads

2

Readme

ts的编译

  1. ts-loader 编译的时候可以进行类型检查, 新项目使用
  2. babel-loader @/babel/preset-typescript 不能进行检查,旧项目一般使用

ts-loader的配置

  1. ts-loader 依赖 typescritp: npm i typescript -D,执行npm run start,提示 The 'files' list in config file 'tsconfig.json' is empty.
  2. 执行tsc --init
  3. 执行npm i @types/react @types/react-dom -S
  4. 提示 Cannot use JSX unless the '--jsx' flag is provided,修改tsconfig.json的jsx属性的值为"react" preserve 保留jsx语法和tsx后续 react-native 保留jsx语法但会把后缀改为js react 不保留jsx语法直接编译成es5.后缀改为js
{
    test: /\.tsx | \.js?$/,
    use: 'ts-loader',
    exclude: /node_modules/
}

ts-loader也可以处理js文件

  • 入口文件改成js文件也可以正常运行 要明白ts-loader做了哪些事 index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));

tsconfig.json配置

如果tsx文件要引入js文件写的组件,需要将"allowJs"属性设置成true

eslint配置

  • 没有配置前,有错误提示,但是不影响运行

eslint的安装和配置

npm i eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser -D