{"id":396643,"date":"2021-03-12T10:02:44","date_gmt":"2021-03-12T02:02:44","guid":{"rendered":"http:\/\/4563.org\/?p=396643"},"modified":"2021-03-12T10:02:44","modified_gmt":"2021-03-12T02:02:44","slug":"%e8%af%b7%e6%95%99%e4%b8%80%e4%b8%8b%ef%bc%8c-js-%e9%a1%b9%e7%9b%ae%e6%89%93%e5%8c%85%ef%bc%8c%e5%8f%91%e5%b8%83-lib-%e5%92%8c%e7%9b%b8%e5%85%b3-type-%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=396643","title":{"rendered":"\u8bf7\u6559\u4e00\u4e0b\uff0c js \u9879\u76ee\u6253\u5305\uff0c\u53d1\u5e03 lib \u548c\u76f8\u5173 type \u65b9\u6cd5"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u4e00\u4e0b\uff0c js \u9879\u76ee\u6253\u5305\uff0c\u53d1\u5e03 lib \u548c\u76f8\u5173 type \u65b9\u6cd5               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yazoox <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4e00\u822c\uff0cjs \u9879\u76ee\uff0cwebpack \u6253\u5305\u540e\uff0c\u53ea\u8981\u628a dist \u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\uff0c\u90e8\u7f72\u5230 aws \u7b49\u4e91\u670d\u52a1\uff0c\u5c31\u53ef\u4ee5\u5de5\u4f5c\u4e86\uff01<\/p>\n<p>\u90a3\u4e48\uff0c\u5982\u679c\u6211\u63d0\u4f9b\u4e86\u4e00\u4e9b api\uff0c\u53d1\u5e03\u5230 npm \uff1f\u9700\u8981\u5565\u7279\u522b\u5904\u7406 \/\u6d41\u7a0b\u4e48\uff1f\u5c24\u5176\u662f\uff0c\u8981\u652f\u6301 typescript\uff0c\u600e\u4e48\u5904\u7406\uff1f\u597d\u50cf\u662f\u8981\u751f\u6210\u4e00\u4e2a custom.d.ts \u6587\u4ef6\uff01\u8fd9\u4e2a\u80fd\u81ea\u52a8\u751f\u6210\u4e48\uff1f<\/p>\n<p>\u4ee5\u53ca\uff0c\u60f3\u4f7f\u7528\u7684\u7b2c\u4e09\u65b9\u7c7b\u5e93\uff0c\u6ca1\u6709\u63d0\u4f9b type\uff0c\u6211\u81ea\u5df1\u7684 typescript \u9879\u76ee\u5982\u4f55\u4f7f\u7528\uff1f<\/p>\n<p>\u6709\u6ca1\u6709\u76f8\u5173\u6587\u6863\uff0c\u4ecb\u7ecd\u7684\u6bd4\u8f83\u597d\u7684\uff01\uff1f<\/p>\n<p>\u641c\u7d22\u4e86\u4e00\u4e0b\uff0c\u6682\u65f6\u6ca1\u627e\u5230\u5199\u5f97\u6bd4\u8f83\u597d\u3002 \u7279\u6765\u5411\u5927\u5bb6\u8bf7\u6559\u4e00\u4e0b<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>12<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5527251\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yanguoyu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u4f60\u8981\u5199 lib \u5e93\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u7528\u8fd9\u4e2a https:\/\/github.com\/yanhaijing\/jslib-base\uff0c\u81f3\u4e8e\u4f7f\u7528\u7684\u7b2c\u4e09\u65b9\u5e93\u6ca1\u6709 declared \u6587\u4ef6\uff0c\u90a3\u5c31\u9700\u8981\u81ea\u5df1\u5b9a\u4e49\uff0c\u53ef\u4ee5\u770b ts \u5b98\u65b9\u6587\u6863\u6216\u8005\u7ffb\u8bd1\u6587\u6863\u3002<br \/>\u4e2d\u6587\uff1a https:\/\/www.tslang.cn\/docs\/handbook\/declaration-files\/introduction.html<br \/>\u82f1\u6587\uff1a https:\/\/www.typescriptlang.org\/docs\/handbook\/declaration-files\/introduction.html                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527252\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vcfvct <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Type \u7684\u8bdd tsc \u53ef\u4ee5\u751f\u6210\uff0c\u4e00\u822c lib \u7684\u8bdd\u4e5f\u53ef\u4ee5\u628a\u6240\u4ee5\u76f8\u5173\u7c7b\u653e\u5728 index.ts \uff0c\u8fd9\u6837\u522b\u4eba\u5c31\u53ef\u4ee5\u76f4\u63a5\u4ece\u4f60 lib \u7684 root import \u4e86.<br \/>\u540e\u7aef bundle \u4e5f\u53ef\u4ee5\u8bd5\u8bd5 esbuild\uff0ctreeshaking \u4ec0\u4e48\u7684\u6bd4\u8f83                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527253\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vcfvct <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f53\u7136 index \u91cc\u662f export \u4e00\u4e0b\uff0c\u4e0d\u662f\u771f\u6b63\u7684\u6240\u4ee5 source                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527254\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : musi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8e72\u4e00\u4e2a\u597d\u7528\u7684\u65b9\u6848                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527255\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ccraohng <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u4e0d\u662f ts \u5199\u7684\uff0cpackage.json \u6307\u5b9a typings \u5b57\u6bb5\u3002<br \/>\u5982\u679c\u662f \uff0c\u6253\u5f00\u8f93\u51fa dts \u9009\u9879\u3002<br \/>\u6216\u8005\u53d1\u5e03 @types \u5305<br \/>\u4e3a\u7b2c\u4e09\u5e93\u5199\u7533\u660e \u641c\u4e00\u4e0b\u5e94\u8be5\u86ee\u591a\u7684\uff0c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527256\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hupo0 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u53ef\u4ee5\u53c2\u8003\u522b\u4eba\u7684\u5e93\u662f\u600e\u4e48\u6253 npm \u5305\u548c\u53d1\u5e03\u7684\uff0c\u6bd4\u5982\u8bf4\u6211\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527257\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hupo0 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @hupo0 \u6211\u9760\uff0c\u6211\u60f3\u6362\u884c\u600e\u4e48\u5c31\u53d1\u51fa\u53bb\u4e86\u3002<br \/>https:\/\/github.com\/Iplaylf2\/no-stream<br \/>\u4e3b\u8981\u770b\u9876\u7ea7\u76ee\u5f55\uff0cpackage.json \u548c gulpfile.js \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527258\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : LOWINC <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/www.npmjs.com\/package\/tsdx<\/p>\n<p>\u6211\u4e00\u822c\u7528\u8fd9\u4e2a                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527259\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhuweiyou <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u4f60\u662f TS \u5199\u7684, tsc \u53ef\u4ee5\u76f4\u63a5\u7f16\u8bd1\u4ea7\u51fa d.ts<br \/>\u5982\u679c\u4f60\u662f JS \u5199\u7684,\u636e\u6211\u6240\u77e5\u5f97\u624b\u5199                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527260\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wobuhuicode <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f88\u7b80\u5355\uff0cpackage.json \u6307\u5b9a\u4e00\u4e2a .d.ts \u6587\u4ef6\u5c31\u53ef\u4ee5\u4e86 <br \/>&#8220;types&#8221;: &#8220;index.d.ts&#8221;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527261\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ruoxie <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/github.com\/umijs\/father                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5527262\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fox2081 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u662f TS \u9879\u76ee\uff0c\u4f1a\u81ea\u52a8\u751f\u6210 dts\uff0c\u4f46\u662f\u662f\u4e00\u5bf9\u4e00\u7684\uff0c\u4e0d\u4f1a\u6253\u5305\u6210\u4e00\u4e2a\uff0c\u60f3\u6253\u5305\u7684\u8bdd rollup \u3001webpack \u90fd\u6709\u63d0\u4f9b\u4e00\u4e9b\u63d2\u4ef6\uff0c\u4f46\u6548\u679c\u90fd\u4e0d\u614e\u7406\u60f3\uff0c\u4e4b\u524d\u6253\u5305\u7c7b\u5e93\u6709\u7528\u8fc7\u4e00\u4e2a rollup-plugin-dts\uff0c\u9879\u76ee\u4ee3\u7801\u4e00\u591a\uff0c\u5230\u65f6\u5019\u58f0\u660e\u6587\u4ef6\u5c31\u4e0d\u662f\u4eba\u80fd\u770b\u61c2\u7684\u4e86\u3002TS \u73b0\u5728\u5df2\u7ecf\u4e0d\u63a8\u8350\u4f7f\u7528 namespace \u548c module \u4e86\uff0c\u4f46\u662f dts \u91cc\u9762\u8fd8\u662f\u633a\u597d\u7528\u7684\uff0c\u540e\u9762\u8fd8\u662f\u901a\u8fc7\u81ea\u52a8\u751f\u6210\u7684\u624b\u52a8\u6574\u7406\u3002<\/p>\n<p>JS \u9879\u76ee\u60f3\u751f\u6210 dts \u4f30\u8ba1\u4e0d\u592a\u9760\u8c31\u3002<\/p>\n<p>\u652f\u6301 ts\uff0c\u5c31\u8981\u5728 package.json \u4e2d\u7684 typings \u4e2d\u6307\u5411\u4f60\u9879\u76ee\u4e2d\u7684 dts \u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u6ca1\u5173\u7cfb\uff0c\u5c31\u884c main \u8fd9\u6837\u7684\u5165\u53e3\u6587\u4ef6\u3002<\/p>\n<p>\u7b2c\u4e09\u65b9\u7c7b\u5e93\u5982\u679c\u6ca1\u6709\u81ea\u5e26\u58f0\u660e\uff0c\u53ef\u4ee5\u641c @types\/xxx\uff0c\u989d\u5916\u5b89\u88c5\u58f0\u660e\u6587\u4ef6\uff0c\u4e0d\u51b7\u95e8\u7684\u57fa\u672c\u90fd\u6709\uff0c\u6ca1\u6709\u7684\u8bdd\u5728\u4f60\u9879\u76ee\u5185\u5bb9\u53ef\u4ee5\u201c\u5e2e\u201d\u4ed6\u5199\uff0c\u4e00\u822c\u662f declare module &#8216;xxx&#8217;\uff0c\u653e\u5728\u4f60 tsconfig \u5305\u542b\u7684\u76ee\u5f55\u91cc\u3002<\/p>\n<p>dts \u662f\u89e3\u9664 ts \u4e4b\u540e\u5c31\u8ba9\u4eba\u7231\u4e0d\u91ca\u624b\u7684\u4e1c\u897f\uff0c\u5373\u4f7f\u662f js \u9879\u76ee\uff0c\u7f16\u8f91\u5668\u4e5f\u53ef\u4ee5\u6839\u636e\u5176\u4ed6\u9879\u76ee\u7684 dts \u63d0\u4f9b\u667a\u80fd\u63d0\u793a\uff0c\u6211\u73b0\u5728\u516c\u53f8\u8c03\u7528\u540e\u7aef\u7684\u63a5\u53e3\u5c31\u662f\u901a\u8fc7\u540e\u7aef\u626b\u63cf\u6570\u636e\u7ed3\u6784\u548c\u63a5\u53e3\u8def\u7531\u81ea\u52a8\u751f\u6210\u5e76\u53d1\u5e03\u7684\u4e00\u4e2a\u9879\u76ee\uff0c\u58f0\u660e\u6587\u4ef6\u622a\u81f3\u76ee\u524d\u6709 16325 \u884c\uff0c\u6253\u5305\u4e4b\u540e\u7684\u4ee3\u7801\u53ea\u6709 12kb\uff0c\u91cc\u9762\u6709 10kb \u8fd8\u662f\u540e\u7aef\u751f\u6210\u7684\u679a\u4e3e\u6587\u4ef6\uff0c\u4f7f\u7528\u8d77\u6765\u63a5\u53e3\u5730\u5740\u3001\u53c2\u6570\u5b9a\u4e49\u3001\u8fd4\u56de\u683c\u5f0f\u7edf\u7edf\u667a\u80fd\u63d0\u793a\u90fd\u63d0\u4f9b\uff0c\u5982\u679c\u662f ts \u9879\u76ee\uff0c\u63a5\u53e3\u66f4\u65b0\u4f1a\u76f4\u63a5\u5728\u7f16\u8bd1\u65f6\u628a\u9700\u8981\u6539\u7684\u5730\u65b9\u5217\u51fa\u6765\uff0c\u5e73\u65f6\u5f00\u53d1\u76f4\u63a5\u4e0d\u7528\u67e5\u6587\u6863\uff0c\u7ec4\u5458\u7528\u8fc7\u90fd\u8bf4\u597d                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u4e00\u4e0b\uff0c js \u9879\u76ee\u6253\u5305\uff0c\u53d1\u5e03 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/396643"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=396643"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/396643\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=396643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=396643"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=396643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}