107-161JS

target事件委托

list.onclick = function(evt){

console.log(evt.target||.srcElement)
list.onclick = function(evt){
console.log(evt.target)
evt.target.parentNode.remove()

通过此方法可以防止如果是li 就把所有li都删除的情况

console.log(evt.target.nodeName)
if(evt.target.nodeName==="BUTTON"){
evt.target.parentNode.remove()

这样只有点击按钮才会出事件

正则表达式

正则表达式语法大全

var reg = /abc/
//2.内置构造函数
var reg2 = new RegExp("abc")

在这里插入图片描述
^$首尾限定符

捕获exec

// test()
//exec()捕获片段
var reg = /\d{3}/
console.log(reg.exec("aa123aa"))

特性

//1.懒惰,解决使用全局标识符g
//2.贪婪
var reg = /\d14)/
console.log(reg.exec("aa123456bb"))

还有search match

this指向

谁调用我,this就指向谁

改变this指向

// call
obj1.getName.call(obj2)
//cal1执行函数,
并改变this执行为函数的第一个参数
支持多个参数
obj1.getName.call(obj2,1,2,3)
// apply执行函数,并改变this执行为函数的第一个参数
第二个参数为数组,只支持两个参数
T
obj1.getName.apply(obj2, [1,2,3]
//bind改变this指向为函数的第一个参数,不会自动指向函数
var fun1 =obj1.getName.bind(obj2)

ES6定义变量

在这里插入图片描述

for (let i = 0; i ‹ oHeaderItems.length; i++) {
//自定义属性
oHeaderItems[i].dataset.index = i
oHeaderItems[i].onclick =function (){
console.log(i)}

ES6箭头函数

可以用来简洁代码

var test1 = function(){
console.log("11111")
}
var test2
()=>{
console.log(2222)
}
效果是一样的

写法:

var test =a => {
console.log(111,a)
一个参数可以省略括号

var test = (a,b) => {
console.log(111,a)

注意:1.(只有一个形参的时候)可以省略
2.{}可以省略只有一句代码或只有返回值的时候,省略return
3.没有arguments
4.箭头函数没有this,
箭头函数this是父级作用域的,

var test =()=>
(
{name:"kerwin"
})要加上小括号避免被当成函数
//函数的默认参数 用来以防万一
function test(a=1,b=2){
return a+b I
console.log(test(1,20))
console.log(test())

ES6解构赋值

重点:对号入座
快速的从对象和数组中获取里面的成员

var arr = ["xiaoming","teichui", "shanzhen"]
// arr[2]
Let [x,y,z] = arr[]

可以快速获取多维数组

var arr2=[1,2,[3,4,[5]]]//多维度数组
// console.log(arr2[2][2][0])
var [q,w,[e,r,[t]]]=arr2

ES6展开运算符

//...展开数组
var a =[1,2,3]
var b =[4,5,6]
// console.log(a.concat(b))
var c=[a,b]
console.log(c)
/...复制
// var·a =[1,2,3]
7/·var b=[..a]
//b[0]="kerwin"
//...参数-实参-形参
var test =(…arr)=> {
console.log(arr)
test(1,2,3,4,5)
function test(){

var arr =[.…arguments]
console.log(arr)
test(1,2,3,4,5)

ES6模块化

1.私密不漏
2.重名不怕
3.依赖不乱

导入导出:

<script type="module">
imporl {A1,A2,test} From './module/A.js'
A1()
A2()
test()
import {A1,A2,test as A_test} from './module/A.js'
import {B1,B2,test as B_test} from './module/B.js'
A1()
A2()
A_test()
B_test

初识面向对象

在这里插入图片描述

创建对象

工厂函数
function createobj(){
var obj ={}

obj.name="蒸羊羔",
obj.material =[]
return obj
自定义构造函数

```javascript
function createobj(name){
this.name=name
this.material =[]
this.cook = function(){
}
var obj1=_new createobj("蒸羊羔"

构造函数注意问题

//1.首字母大写
function Createobj(name){
this.ñame = name
//
//}
// var obj1 = new Createobj("kerwin")
// console.log(obj1)
//2.构造函数不写return
function Createobj(name){
this.name
name

return {
a:1,
b:2
}
new Createobj("kerwin")
var obj1
console.log(obj1)
构造函数能当普通函数用
function Createobj(name){
console.log(this)
this.name = name
// var obj1 = new Createobj("kerwin")
// console.log(obj1)
var obj1 = Createobj("kerwin")
console.log(obj1,window.name)
this指向new完后创建出的对象

面向对象的原型

function Createlist(select,data){
this.ele = document.querySelector(select)
this.title = data.title,
this.list = data.list
}
var obj1 = new CreateList(".box1",data1)
// var obj2 = new CreateList(data2.title,data2.list)
function CreateList(select,data){
this.ele = document.querySelector(select)
this.title = data.title,
this.list = datat.list
this.render function(){/渲染页面
var h1 this.ele.querySelector("h1")
var ul this.ele.querySelector("ul")
// console.log(h1,ul)
h1.innerHTML this.title
ul.innerHTML=this.list.map(item=> <li>{item</li>)
.join("")
}

对象.__proto__===构造函数.prototyple

ES6-Class

class Createobj {
∥构造器函数
constructor(name){
this.name=name

say(){
console.log(this.name,"hello")
}
}
var obj=new Createobj()

面向对象继承

function Person(name,age){
this.name = name
this.age = age
Person.prototype.say = function(){
console.log(this.name ,"hello")
}
function Student(name,age,grade){
Person.call(this,name,age)
this.grade = grade
}
// Student.prototype.say = function(){
console.log(this.name ,"hello")
}
Student.prototype = new Person()
//基础增加方法
Student.prototype.printGrade = function(){
console.log(this.name,this.grade)
Student.prototype.say = function(){
console.log(this.name,this.grade)
//覆盖
Student.prototype.say = function(){
console.log(this.name ,"hello")
console.log(this.name,"您好"
∥增强原来方法
Student.prototype.say2 = function(){
this.say()
console.log(this.name,"您好")
var obj = new Student("kerwin",100,100)

ES6继承

//父类
class Person {
constructor(name,age){
this.name = name
this.age = age
say(){
console.log(this.name,"hello")
}
//子类
//原型继承
class Student extends Person{
	constructor(name,age,grade){	
	super(name,age) //Person.call(this,name,age)
	this.grade = grade
}
var obj = new Student()
console.log(obj)

Aajax

在这里插入图片描述

//ajax ===async javascript and xml(闭合标签)
//JSON.parse()
//1.创建XHR new XMLHttpRequest()
var xhr = new XMLHttpRequest()
console.log(xhr)
//2。配置open(请求方式,请求地址,是否异步)
xhr.open("GET","http://127.0.0.1:5500/136-ajax/1.txt")
//3. send
xhr.send()
//4.接受数据,注册一个事件
//btn.onclick = function(){}
xhr.onreadystatechange =function(){}

在这里插入图片描述
在这里插入图片描述

ajax同步异步

var xhr = new XMLHttpRequest()
xhr.open("GET","1.json",false)
//true 表示异步请求
//false表示同步请求
xhr.send()
xhr.onload = function()
if(xhr.status===200){
console.log(xhr.responseText)
}
}

请求方式1

get 偏向获取数据
post偏向提交数据
put偏向更新
delete 偏向删除信息
patch 偏向部分修改
{header
options
connect
}
特殊的post:

xhr.open("POST","http://localhost:3000/users")
xhr.onload =function(){
if(xhr.status===200){
console.log(JSON.parse(xhr.responseText))
	}
}
//提交信息
//post name=kerwin&age=100
//post {"name":"kerwin"}
xhr.setRequestHeader("Content-Type","application/
x-www-form-urlencoded")

xhr.send(`username=gangdan&&password=123`)

ajax的封装

ajax调用:
在这里插入图片描述
通过回调函数来封装

ajax({
url:"http://localhost:3000/users",
success:function(){
console.log("sucess")
}error:function(err){
console.log("error",err)
}

捕获错误

try {
Let result = JSON.parse("111111111&22222222")
success(result)
}catch|(err){
//error('解析失败!因为后端返回的结果不是 json 格式字符串’)
}
////设置请求头内的信息
for (Let k in headers) xhr.setRequestHeader(k, headers[k])
// if (/get$/i.test(method)) {
// xhr.send()
// } else {
xhr.send(data)
//
//}
xhr.send(data)

案例:

import ajax from'./util.js'
// console.log(ajax)
class TodoList{
constructor(select){
this.list = document.querySelector(select)
this.1istdata=[//列表数据
this.init()
}
init(){
//初始化
this.bindEvent()
bindEvent(){
this.listEle.onclick=function(evt){
console.log(evt.target)
}
}
//获取数据的方法
this.getList(){
ajax({
url:"http://localhost:3000/list",
success:(res)=>{
console.log(res)
}error:function(){
}//渲染页面
render(){
// console.log("render")
this.listEle.innerHTML = this.listdata.map
(item=> <li>11111</li> ).join("")

addItem(text){
// console.log(text)
//在”数据库“添加后,成功回调里,页面添加
ajax({
//在”数据库“添加后,成功回调里,页面添加
ajax({
url: http://localhost:3000/list,
method:"POST",
data:{
text
}success:(res) => {
// console.log("成功",res)
// location.reload()//全局刷新页面
}error:function(){
})

重点:
没有嵌套的函数this指向为window,嵌套中的函数this指向为undifined,会出现指向问题

回调地狱

在这里插入图片描述
ajax嵌套

promise基础语法

在这里插入图片描述

//Promise构造函数
var q = new Promise(function(a,b){
//异步
setTimeout(()=>{
resolve()//成功兑现承诺
//失败拒接承诺
//reject()
},2000)
}//q是promi.se对象
q.then(function(){
//兑现承诺,这个函数被执行
}).catch(function(){
//拒绝承诺,这个函数就会被执行
})

在这里插入图片描述

Promise封装ajax

function pajax(options){
var q = new Promise(function(resolve,reject){
ajax({
.options,
success:function(res){
resolve(res)
}error:function(err){
reject(err)
}}return q

async和await

在这里插入图片描述

async function test(){

//await 同步代码
await console.log(1111)
console.log(2222)
test()
async function test()
await Promise.all([q1,q2])
var res
console.log(res)
}
test()

fetch

为了取代XMLHTTPrequest

fetch("http://localhost:3000/users").then(res=>{
// console.log(res)
return res.json()
}).then(res=>{
console.log(res)
}}

必须要用json解析,要不然会报错

fetch("http://localhost:3000/users",{
method:"POST",
headers:{
"content-type":"application/x-www-form-urlencoded"
}body:"username=tiechui&password=123"
}.then(res=>res.json())
.then(res=>{
conscle.log(res)
})

cookie

http协议无状态
localStorage:用户名密码?
token钥匙==>Nodejs token认证。
cookie 本地存储sessionID 钥匙 ==>Nodejscookie+session

savebtn.onclick = function()
//路径设置
document.cookie = "username=xiaoming;path=/155-cookie/aaa"
document.cookie = "age=18"
//过期时间设置
var date = new Date()
date.setMinutes(date.getMinutes()+1)
document.cookie =` username=kerwin;expires=${date}`

删除原理:将其设置时间提前。让其时间过期

jsopn

在这里插入图片描述
同源策略:同域名同端口号同协议
不符合同源策略,浏览器为了安全,会阻止请求

解决跨域问题:
1.cors 由后端设置 Access-Control-Allow-Origin:
2. jsonp

function test(obj){
console.log(obj)
}
mybtn.onclick =function(){
var oscript = document.createElement("script")
oscript.src="01.txt”//未来地址
document.body.appendchild(oscript)
}

通过文本文件来引入

mysearch.oninput = function(evt){
console.log(evt.target.value)
var oscript document.createElement("script")

oscript.src =`https://www.baidu.com/sugrec?pre=1&p=3&xxxxx`
document.body.appendChild(oscript)
oscript.onload = function(){
oscript.remove()
}

再谈函数

函数有返回值,而且返回值必须是复杂类型,而且要赋值给外面的变量。

function test(){
var name ="kerwin"
console.log(name)
var obj = {
a:1,
b:2
return obj
}
var obj1 = test()

var obj2=test()

在这里插入图片描述

闭包

闭包:
函数内部返回一个函数,被外界所引用。
这个内部函数就不会被销毁回收。
内部函数所用到的外部函数的变量也不会被销毁。

function FetchContainer(url){
return function(path){
return fetch(url+path)
var fetcha = FetchContainer("http://www.a.com")
fetcha("/aaa").then(res=>res.json()).then(res=>console.log(res))
fetcha("/bbb").then(res=>res.json()).then(res=>console.log(res))
fetcha =null
这样子蟹后面可以加而且
回收和方便
不用就回收

输入后才发请求:

mysearch.oninput =(function (){
var timer
null
return function () {
if (timer) {
clearTimeout(timer)
timer = setTimeout(function () {
console.log("发ajax请求"},500)
})()
gapinyc@DESKTOP-9QS7RL5:~/superset-prod/superset-5.0.0/superset-frontend$ npm run build > superset@5.0.0 build > cross-env NODE_OPTIONS=--max_old_space_size=8192 NODE_ENV=production BABEL_ENV="${BABEL_ENV:=production}" webpack --color --mode production [Superset Plugin] Use symlink source for @superset-ui/chart-controls @ ./packages/superset-ui-chart-controls [Superset Plugin] Use symlink source for @superset-ui/core @ ./packages/superset-ui-core [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-calendar @ ./plugins/legacy-plugin-chart-calendar [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-chord @ ./plugins/legacy-plugin-chart-chord [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-country-map @ ./plugins/legacy-plugin-chart-country-map [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-horizon @ ./plugins/legacy-plugin-chart-horizon [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-map-box @ ./plugins/legacy-plugin-chart-map-box [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-paired-t-test @ ./plugins/legacy-plugin-chart-paired-t-test [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-parallel-coordinates @ ./plugins/legacy-plugin-chart-parallel-coordinates [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-partition @ ./plugins/legacy-plugin-chart-partition [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-rose @ ./plugins/legacy-plugin-chart-rose [Superset Plugin] Use symlink source for @superset-ui/legacy-plugin-chart-world-map @ ./plugins/legacy-plugin-chart-world-map [Superset Plugin] Use symlink source for @superset-ui/legacy-preset-chart-deckgl @ ./plugins/legacy-preset-chart-deckgl [Superset Plugin] Use symlink source for @superset-ui/legacy-preset-chart-nvd3 @ ./plugins/legacy-preset-chart-nvd3 [Superset Plugin] Use symlink source for @superset-ui/plugin-chart-cartodiagram @ ./plugins/plugin-chart-cartodiagram [Superset Plugin] Use symlink source for @superset-ui/plugin-chart-echarts @ ./plugins/plugin-chart-echarts [Superset Plugin] Use symlink source for @superset-ui/plugin-chart-handlebars @ ./plugins/plugin-chart-handlebars [Superset Plugin] Use symlink source for @superset-ui/plugin-chart-pivot-table @ ./plugins/plugin-chart-pivot-table [Superset Plugin] Use symlink source for @superset-ui/plugin-chart-table @ ./plugins/plugin-chart-table [Superset Plugin] Use symlink source for @superset-ui/plugin-chart-word-cloud @ ./plugins/plugin-chart-word-cloud [Superset Plugin] Use symlink source for @superset-ui/switchboard @ ./packages/superset-ui-switchboard 10% building 0/8 entries 8/8 dependencies 0/5 modules`isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) `isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) `isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) 10% building 0/8 entries 8/9 dependencies 0/5 modules`isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) `isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) 10% building 0/8 entries 187/250 dependencies 4/100 modules`isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) `isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) `isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) `isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) `isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) `isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) 10% building 0/8 entries 285/386 dependencies 16/145 modules`isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration` at isModuleDeclaration (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@babel/types/lib/validators/generated/index.js:2793:35) at PluginPass.Program (/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/babel-plugin-lodash/lib/index.js:102:44) 1146 assets 12794 modules LOG from ./node_modules/less-loader/dist/cjs.js less-loader ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[6].use[1]!./node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[6].use[2]!./src/assets/stylesheets/superset.less <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 15, column 20: <w> 15 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 24, column 20: <w> 24 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 33, column 20: <w> 33 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 42, column 20: <w> 42 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 51, column 20: <w> 51 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 37, column 20: <w> 37 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 42, column 20: <w> 42 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 50, column 20: <w> 50 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 55, column 20: <w> 55 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 73, column 20: <w> 73 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 84, column 20: <w> 84 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 107, column 22: <w> 107 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 112, column 22: <w> 112 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 129, column 22: <w> 129 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 134, column 22: <w> 134 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 216, column 15: <w> 216 .button-size( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 241, column 17: <w> 241 .button-size( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 246, column 17: <w> 246 .button-size( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 284, column 20: <w> 284 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 290, column 20: <w> 290 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 298, column 20: <w> 298 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 304, column 20: <w> 304 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 395, column 17: <w> 395 .button-size( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 400, column 17: <w> 400 .button-size( <w> LOG from ./node_modules/less-loader/dist/cjs.js less-loader ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[6].use[1]!./node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[6].use[2]!./src/assets/stylesheets/antd/index.less <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 15, column 20: <w> 15 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 24, column 20: <w> 24 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 33, column 20: <w> 33 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 42, column 20: <w> 42 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/style/mixins/typography.less on line 51, column 20: <w> 51 .typography-title( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 37, column 20: <w> 37 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 42, column 20: <w> 42 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 50, column 20: <w> 50 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 55, column 20: <w> 55 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 73, column 20: <w> 73 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 84, column 20: <w> 84 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 107, column 22: <w> 107 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 112, column 22: <w> 112 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 129, column 22: <w> 129 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 134, column 22: <w> 134 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 216, column 15: <w> 216 .button-size( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 241, column 17: <w> 241 .button-size( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 246, column 17: <w> 246 .button-size( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 284, column 20: <w> 284 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 290, column 20: <w> 290 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 298, column 20: <w> 298 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 304, column 20: <w> 304 .button-color( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 395, column 17: <w> 395 .button-size( <w> <w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/antd/lib/button/style/mixin.less on line 400, column 17: <w> 400 .button-size( <w> WARNING in ./src/components/Tooltip/index.tsx 22:0-42 export 'TooltipProps' (reexported as 'TooltipProps') was not found in 'antd-v5/lib/tooltip' (possible exports: __esModule, default) WARNING in ./src/components/Tooltip/index.tsx 22:0-42 export 'TooltipPlacement' (reexported as 'TooltipPlacement') was not found in 'antd-v5/lib/tooltip' (possible exports: __esModule, default) ERROR in ./node_modules/@luma.gl/webgl/dist/adapter/webgl-adapter.js 65:38-62 Module not found: Error: Can't resolve './webgl-device' in '/home/gapinyc/superset-prod/superset-5.0.0/superset-frontend/node_modules/@luma.gl/webgl/dist/adapter' Did you mean 'webgl-device.js'? BREAKING CHANGE: The request './webgl-device' failed to resolve only because it was resolved as fully specified (probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'). The extension in the request is mandatory for it to be fully specified. Add the extension to the request. ERROR in ./node_modules/@deck.gl/core/src/controllers/controller.ts:21:24 TS7006: Parameter 't' implicitly has an 'any' type. 19 | 20 | const DEFAULT_INERTIA = 300; > 21 | const INERTIA_EASING = t => 1 - (1 - t) * (1 - t); | ^ 22 | 23 | const EVENT_TYPES = { 24 | WHEEL: ['wheel'], ERROR in ./node_modules/@deck.gl/core/src/controllers/controller.ts:114:3 TS2578: Unused '@ts-expect-error' directive. 112 | abstract get transition(): TransitionProps; 113 | > 114 | // @ts-expect-error (2564) - not assigned in the constructor | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 115 | protected props: ControllerProps; 116 | protected state: Record<string, any> = {}; 117 | ERROR in ./node_modules/@deck.gl/core/src/controllers/controller.ts:173:7 TS7032: Property 'events' implicitly has type 'any', because its set accessor lacks a parameter type annotation. 171 | } 172 | > 173 | set events(customEvents) { | ^^^^^^ 174 | this.toggleEvents(this._customEvents, false); 175 | this.toggleEvents(customEvents, true); 176 | this._customEvents = customEvents; ERROR in ./node_modules/@deck.gl/core/src/controllers/controller.ts:173:14 TS7006: Parameter 'customEvents' implicitly has an 'any' type. 171 | } 172 | > 173 | set events(customEvents) { | ^^^^^^^^^^^^ 174 | this.toggleEvents(this._customEvents, false); 175 | this.toggleEvents(customEvents, true); 176 | this._customEvents = customEvents; ERROR in ./node_modules/@deck.gl/core/src/controllers/controller.ts:338:16 TS7006: Parameter 'eventNames' implicitly has an 'any' type. 336 | } 337 | > 338 | toggleEvents(eventNames, enabled) { | ^^^^^^^^^^ 339 | if (this.eventManager) { 340 | eventNames.forEach(eventName => { 341 | if (this._events[eventName] !== enabled) { ERROR in ./node_modules/@deck.gl/core/src/controllers/controller.ts:338:28 TS7006: Parameter 'enabled' implicitly has an 'any' type. 336 | } 337 | > 338 | toggleEvents(eventNames, enabled) { | ^^^^^^^ 339 | if (this.eventManager) { 340 | eventNames.forEach(eventName => { 341 | if (this._events[eventName] !== enabled) { ERROR in ./node_modules/@deck.gl/core/src/controllers/controller.ts:340:26 TS7006: Parameter 'eventName' implicitly has an 'any' type. 338 | toggleEvents(eventNames, enabled) { 339 | if (this.eventManager) { > 340 | eventNames.forEach(eventName => { | ^^^^^^^^^ 341 | if (this._events[eventName] !== enabled) { 342 | this._events[eventName] = enabled; 343 | if (enabled) { ERROR in ./node_modules/@deck.gl/core/src/controllers/controller.ts:484:29 TS7006: Parameter 'event' implicitly has an 'any' type. 482 | } 483 | > 484 | protected _onPanRotateEnd(event): boolean { | ^^^^^ 485 | const {inertia} = this; 486 | if (this.dragRotate && inertia && event.velocity) { 487 | const pos = this.getCenter(event); ERROR in ./node_modules/@deck.gl/core/src/controllers/map-controller.ts:406:19 TS7006: Parameter 'scale' implicitly has an 'any' type. 404 | /* Private methods */ 405 | > 406 | _zoomFromCenter(scale) { | ^^^^^ 407 | const {width, height} = this.getViewportProps(); 408 | return this.zoom({ 409 | pos: [width / 2, height / 2], ERROR in ./node_modules/@deck.gl/core/src/controllers/map-controller.ts:414:18 TS7006: Parameter 'offset' implicitly has an 'any' type. 412 | } 413 | > 414 | _panFromCenter(offset) { | ^^^^^^ 415 | const {width, height} = this.getViewportProps(); 416 | return this.pan({ 417 | startPos: [width / 2, height / 2], ERROR in ./node_modules/@deck.gl/core/src/controllers/map-controller.ts:422:20 TS7006: Parameter 'newProps' implicitly has an 'any' type. 420 | } 421 | > 422 | _getUpdatedState(newProps): MapState { | ^^^^^^^^ 423 | // @ts-ignore 424 | return new this.constructor({ 425 | makeViewport: this.makeViewport, ERROR in ./node_modules/@deck.gl/core/src/controllers/transition-manager.ts:40:24 TS7006: Parameter 't' implicitly has an 'any' type. 38 | }; 39 | > 40 | const DEFAULT_EASING = t => t; | ^ 41 | const DEFAULT_INTERRUPTION = TRANSITION_EVENTS.BREAK; 42 | 43 | type TransitionSettings = BaseTransitionSettings & { ERROR in ./node_modules/@deck.gl/core/src/controllers/transition-manager.ts:209:12 TS7006: Parameter 'transition' implicitly has an 'any' type. 207 | 208 | _onTransitionEnd(callback?: (transition: Transition) => void) { > 209 | return transition => { | ^^^^^^^^^^ 210 | this.propsInTransition = null; 211 | 212 | this.onStateChange({ ERROR in ./node_modules/@deck.gl/core/src/controllers/transition-manager.ts:223:25 TS7006: Parameter 'transition' implicitly has an 'any' type. 221 | } 222 | > 223 | _onTransitionUpdate = transition => { | ^^^^^^^^^^ 224 | // NOTE: Be cautious re-ordering statements in this function. 225 | const { 226 | time, ERROR in ./node_modules/@deck.gl/core/src/lib/view-manager.ts:161:7 TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'. 159 | const viewMap = {}; 160 | this.views.forEach(view => { > 161 | viewMap[view.id] = view; | ^^^^^^^^^^^^^^^^ 162 | }); 163 | return viewMap; 164 | } ERROR in ./node_modules/@deck.gl/core/src/lib/view-manager.ts:180:32 TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'ViewStateObject<ViewsT>'. No index signature with a parameter of type 'string' was found on type 'ViewStateObject<ViewsT>'. 178 | typeof viewOrViewId === 'string' ? this.getView(viewOrViewId) : viewOrViewId; 179 | // Backward compatibility: view state for single view > 180 | const viewState = (view && this.viewState[view.getViewStateId()]) || this.viewState; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 181 | return view ? view.filterViewState(viewState) : viewState; 182 | } 183 | ERROR in ./node_modules/@deck.gl/core/src/lib/view-manager.ts:269:5 TS2322: Type 'unknown[]' is not assignable to type 'View<TransitionProps, CommonViewProps<TransitionProps>>[]'. Type 'unknown' is not assignable to type 'View<TransitionProps, CommonViewProps<TransitionProps>>'. 267 | // Does not actually rebuild the `Viewport`s until `getViewports` is called 268 | private _setViews(views: View[]): void { > 269 | views = flatten(views, Boolean); | ^^^^^ 270 | 271 | const viewsChanged = this._diffViews(views, this.views); 272 | if (viewsChanged) { ERROR in ./node_modules/@deck.gl/core/src/lib/view-manager.ts:306:21 TS7006: Parameter 'viewState' implicitly has an 'any' type. 304 | onViewStateChange: this._eventCallbacks.onViewStateChange, 305 | onStateChange: this._eventCallbacks.onInteractionStateChange, > 306 | makeViewport: viewState => | ^^^^^^^^^ 307 | this.getView(view.id)?.makeViewport({ 308 | viewState, 309 | width: this.width, ERROR in ./node_modules/@deck.gl/core/src/transitions/linear-interpolator.ts:100:7 TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'. 98 | const propsInTransition = {}; 99 | for (const key of this._propsToExtract) { > 100 | propsInTransition[key] = lerp(startProps[key] || 0, endProps[key] || 0, t); | ^^^^^^^^^^^^^^^^^^^^^^ 101 | } 102 | 103 | if (endProps.aroundPosition && this.opts.makeViewport) { ERROR in ./node_modules/@deck.gl/core/src/transitions/transition-interpolator.ts:66:9 TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'. 64 | for (const key of this._propsToExtract) { 65 | if (key in startProps || key in endProps) { > 66 | startViewStateProps[key] = startProps[key]; | ^^^^^^^^^^^^^^^^^^^^^^^^ 67 | endViewStateProps[key] = endProps[key]; 68 | } 69 | } ERROR in ./node_modules/@deck.gl/core/src/transitions/transition-interpolator.ts:67:9 TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'. 65 | if (key in startProps || key in endProps) { 66 | startViewStateProps[key] = startProps[key]; > 67 | endViewStateProps[key] = endProps[key]; | ^^^^^^^^^^^^^^^^^^^^^^ 68 | } 69 | } 70 | ERROR in ./node_modules/@deck.gl/core/src/transitions/transition-interpolator.ts:100:23 TS7006: Parameter 'props' implicitly has an 'any' type. 98 | } 99 | > 100 | _checkRequiredProps(props) { | ^^^^^ 101 | if (!this._requiredProps) { 102 | return; 103 | } ERROR in ./node_modules/@deck.gl/core/src/types/types.ts:10:8 TS7019: Rest parameter 'args' implicitly has an 'any[]' type. 8 | 9 | export interface ConstructorOf<T> { > 10 | new (...args): T; | ^^^^^^^ 11 | } 12 | ERROR in ./node_modules/@deck.gl/core/src/utils/flatten.ts:44:28 TS7031: Binding element 'target' implicitly has an 'any' type. 42 | 43 | /** Uses copyWithin to significantly speed up typed array value filling */ > 44 | export function fillArray({target, source, start = 0, count = 1}) { | ^^^^^^ 45 | const length = source.length; 46 | const total = count * length; 47 | let copied = 0; ERROR in ./node_modules/@deck.gl/core/src/utils/flatten.ts:44:36 TS7031: Binding element 'source' implicitly has an 'any' type. 42 | 43 | /** Uses copyWithin to significantly speed up typed array value filling */ > 44 | export function fillArray({target, source, start = 0, count = 1}) { | ^^^^^^ 45 | const length = source.length; 46 | const total = count * length; 47 | let copied = 0; ERROR in ./node_modules/@deck.gl/core/src/utils/math-utils.ts:100:5 TS7034: Variable 'scratchArray' implicitly has type 'any' in some locations where its type cannot be determined. 98 | } 99 | > 100 | let scratchArray; | ^^^^^^^^^^^^ 101 | 102 | /** 103 | * Split a Float64Array into a double-length Float32Array ERROR in ./node_modules/@deck.gl/core/src/utils/math-utils.ts:121:45 TS7005: Variable 'scratchArray' implicitly has an 'any' type. 119 | 120 | const count = (endIndex - startIndex) / size; > 121 | scratchArray = typedArrayManager.allocate(scratchArray, count, { | ^^^^^^^^^^^^ 122 | type: Float32Array, 123 | size: size * 2 124 | }); ERROR in ./node_modules/@deck.gl/core/src/views/view.ts:155:11 TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'TransitionProps'. No index signature with a parameter of type 'string' was found on type 'TransitionProps'. 153 | for (const key in this.props.viewState) { 154 | if (key !== 'id') { > 155 | newViewState[key] = this.props.viewState[key]; | ^^^^^^^^^^^^^^^^^ 156 | } 157 | } 158 | return newViewState; ERROR in ./node_modules/@deck.gl/core/src/views/view.ts:155:31 TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ id?: string | undefined; } & Partial<ViewState>'. No index signature with a parameter of type 'string' was found on type '{ id?: string | undefined; } & Partial<ViewState>'. 153 | for (const key in this.props.viewState) { 154 | if (key !== 'id') { > 155 | newViewState[key] = this.props.viewState[key]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ 156 | } 157 | } 158 | return newViewState; webpack 5.102.1 compiled with 30 errors and 2 warnings in 464552 ms gapinyc@DESKTOP-9QS7RL5:~/superset-prod/superset-5.0.0/superset-frontend$
10-24
你当前的 `npm run build` 命令已经 **部分成功执行**,Webpack 已经开始构建流程,并且加载了大部分插件和模块。但最终 **编译失败(30 errors + 2 warnings)**。 --- ## 🚨 核心错误分类 我们将这些错误分为三类: | 类型 | 错误数量 | 是否致命 | 说明 | |------|----------|----------|------| | 🔴 TypeScript 隐式 `any` 类型错误 | ~25 条 | ✅ 致命 | `TS7006`, `TS7031`, `TS7053` 等 —— 源码未严格标注类型 | | 🔴 ES Module 解析失败 | 1 条 | ✅ 致命 | `Module not found: Can't resolve './webgl-device'` | | ⚠️ 警告(非阻断) | 2 条 | ❌ 不致命 | `TooltipProps` 找不到、Less 空格弃用警告 | --- # ✅ 重点问题分析与解决方案 --- ## 🔴 问题:【关键】`Module not found: Can't resolve './webgl-device'` ```bash ERROR in ./node_modules/@luma.gl/webgl/dist/adapter/webgl-adapter.js 65:38-62 Module not found: Error: Can't resolve './webgl-device' in '.../node_modules/@luma.gl/webgl/dist/adapter' Did you mean 'webgl-device.js'? BREAKING CHANGE: The request './webgl-device' failed to resolve only because it was resolved as fully specified ``` ### 💥 原因: Node.js 的 ESM(ES6 Modules)模式下要求导入路径必须带 `.js` 后缀(“fully specified”),而 CommonJS 允许省略。 你的项目或某些依赖启用了 `"type": "module"`,导致 Webpack 使用 ESM 规则解析模块,但 `@luma.gl/webgl` 发布的代码中使用的是: ```js import { WebGLDevice } from './webgl-device'; // ❌ 缺少 .js ``` 应该写成: ```js import { WebGLDevice } from './webgl-device.js'; // ✅ 正确 ``` 这是 **库发布时不符合现代 Node.js ESM 规范的问题**。 --- ### ✅ 解决方案 1:降级 Node.js 版本(临时绕过) > 👉 推荐 Superset 官方支持的 Node.js 版本是 **v18.x**,不要用 v20+ 的最新版! #### 步骤: ```bash # 卸载当前 Node.js(如果是 nvm) nvm uninstall 20 # 安装 v18(LTS) nvm install 18 nvm use 18 # 清理缓存重新安装 rm -rf node_modules package-lock.json npm install npm run build ``` 📌 **为什么有效?** - Node.js v18 对 ESM 的检查较宽松 - 许多旧包(如 deck.gl, luma.gl)尚未完全适配 v20 的严格模块规则 --- ### ✅ 解决方案 2:手动 patch 文件(治标不治本) 如果你坚持用 Node.js v20+,可以手动修复这个文件: ```bash # 编辑出错的文件 nano node_modules/@luma.gl/webgl/dist/adapter/webgl-adapter.js ``` 找到第 65 行附近: ```js require("./webgl-device"); ``` 改为: ```js require("./webgl-device.js"); ``` ⚠️ 注意:每次 `npm install` 都会被覆盖,不可持续。 --- ### ✅ 解决方案 3:使用 `patch-package` 永久修复 ```bash # 1. 安装 patch 工具 npm install --save-dev patch-package # 2. 修改上面那个文件(加 .js) # 3. 生成补丁 npx patch-package @luma.gl/webgl ``` 这会在 `patches/` 目录生成个 `.patch` 文件,下次 `npm install` 会自动应用。 --- ## 🔴 问题二:TypeScript 类型错误(大量 TSXXX) 例如: ```ts TS7006: Parameter 't' implicitly has an 'any' type. ``` ```ts TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. ``` ### 💥 原因: 这些来自 `@deck.gl/core` 和 `@luma.gl` 的源码本身没有开启严格的 TypeScript 检查(比如 `noImplicitAny: true`)。但在你的构建环境中,TS loader 强制启用严格模式,导致报错。 这不是你的代码问题,而是 **第三方库质量不高或版本不匹配**。 --- ### ✅ 解决方案 1:降级 `@deck.gl/core` / `@luma.gl` 到兼容版本 Superset 5.0.0 应该搭配特定版本的 `deck.gl`。 #### 查看官方兼容性表: Apache Superset 5.0 → 推荐使用: ```json "@deck.gl/core": "8.9.10", "@deck.gl/layers": "8.9.10", "@luma.gl/core": "8.9.10", "@luma.gl/webgl": "8.9.10" ``` #### 手动锁定版本(在 `package.json` 中): ```json "resolutions": { "@deck.gl/core": "8.9.10", "@deck.gl/layers": "8.9.10", "@luma.gl/core": "8.9.10", "@luma.gl/webgl": "8.9.10" } ``` 然后: ```bash rm -rf node_modules package-lock.json npm install ``` ✅ 这些老版本更稳定,不会触发 TS 错误。 --- ### ✅ 解决方案 2:关闭 `noImplicitAny`(不推荐) 修改 `tsconfig.json`(如果有): ```json { "compilerOptions": { "noImplicitAny": false } } ``` ⚠️ 风险:降低类型安全性,可能引入运行时 bug。 --- ## ⚠️ 警告问题:`TooltipProps` 找不到 ```bash WARNING in ./src/components/Tooltip/index.tsx 22:0-42 export 'TooltipProps' was not found in 'antd-v5/lib/tooltip' ``` ### 原因: `antd-v5` 包结构变了,`TooltipProps` 不再直接导出。 ### ✅ 修复方法: 编辑 `src/components/Tooltip/index.tsx`,替换为: ```ts import Tooltip from 'antd-v5/lib/tooltip'; import 'antd-v5/lib/tooltip/style'; // Manually define or import from antd if needed type TooltipProps = React.ComponentProps<typeof Tooltip>; export { Tooltip, TooltipProps }; ``` 或者从 Ant Design 主包导入: ```ts import type { TooltipProps } from 'antd'; ``` 前提是确保 `antd` 和 `antd-v5` 版本致。 --- ## ✅ 总结:完整解决步骤 ### ✅ Step 1: 使用正确的 Node.js 版本 ```bash nvm install 18.18.2 nvm use 18.18.2 ``` ### ✅ Step 2: 锁定 `deck.gl` / `luma.gl` 版本 在 `package.json` 添加: ```json "resolutions": { "@deck.gl/core": "8.9.10", "@deck.gl/layers": "8.9.10", "@luma.gl/core": "8.9.10", "@luma.gl/webgl": "8.9.10" } ``` ### ✅ Step 3: 清理并重装依赖 ```bash rm -rf node_modules package-lock.json npm install ``` ### ✅ Step 4: (可选)修复 Tooltip 导出问题 修改 `src/components/Tooltip/index.tsx`,避免引用不存在的导出。 ### ✅ Step 5: 构建 ```bash npm run build ``` 你应该能看到构建成功,输出类似: ``` Hash: abc123... Built at: 2025-04-05 10:00:00 Asset Size Chunks Chunk Names ... ... ... ... ``` --- ## 📌 附加建议 | 建议 | 说明 | |------|------| | ✅ 使用 `yarn` 而非 `npm` | Yarn 支持 `resolutions` 更好,更适合大型前端项目 | | ✅ 参考 [Superset 官方构建文档](https://github.com/apache/superset/blob/master/CONTRIBUTING.md#frontend) | 明确列出 Node、Yarn 版本要求 | | ✅ 开发时可用 `npm run dev` | 比 build 快,便于调试 | ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值