小编Yud*_*rya的帖子

调试会话期间打字稿未定义的常量

我有以下带有 Typescript项目的Node.js,它运行得非常好。但是,在调试会话期间,我注意到从另一个 Typescript 文件导出的常量总是undefined

在此处输入图片说明

我有点怀疑这是由于names生成的源映射中的空数组:

{
  "version": 3,
  "file": "main.js",
  "sourceRoot": "",
  "sources": [
    "../src/main.ts"
  ],
  "names": [], // <---- empty
  "mappings": ...details omitted... 
}
Run Code Online (Sandbox Code Playgroud)

有没有办法从 Typescript 编译器或其他解决方案中生成正确的源映射来解决这个调试问题?以下是我的tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true, 
    "target": "es2017",
    "noImplicitAny": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "sourceMap": true,
    "allowJs": true,
    "outDir": "dist",
    "baseUrl": ".",
    "typeRoots": [
      "./node_modules/@types"
    ],
    "types": [
      "node" 
    ],
    "paths": {
      "*": [
        "node_modules/*" …
Run Code Online (Sandbox Code Playgroud)

node.js webstorm typescript

5
推荐指数
1
解决办法
338
查看次数

Kotlin匿名函数用例?

根据我的理解,Kotlin中的匿名函数允许您指定返回类型。除此之外,anonymous内部的return语句将仅退出功能块,而在lambda中,它将退出封闭功能。

不过,我无法想象lambda语法无法提供的Kotlin匿名函数在现实世界中的用例是什么?

Kotlin高阶函数和Lambda

kotlin

4
推荐指数
1
解决办法
1294
查看次数

如何在更新期间将null设置为QueryDSL时间戳列?

我在Postgre中有下表:

CREATE TABLE user_attempts
(
    id INT PRIMARY KEY NOT NULL,
    username VARCHAR(50) NOT NULL,
    attempts SMALLINT NOT NULL,
    lastmodified TIMESTAMP,
    FOREIGN KEY ( username ) REFERENCES users ( username )
);
Run Code Online (Sandbox Code Playgroud)

我想lastmodified通过QueryDSL和Spring Data JDBC Extension 更新该字段,如下所示:

template.update(userAttempts, update -> update
                .set(userAttempts.attempts, (short) 0)
                .set(userAttempts.lastmodified, null) // compilation error here
                .where(userAttempts.username.eq(username))
                .execute();
Run Code Online (Sandbox Code Playgroud)

但是,似乎QueryDSL的set方法无法接受,null因为它将匹配多个函数签名.

java querydsl spring-data

2
推荐指数
1
解决办法
1870
查看次数

为什么Kotlin在运算符重载之外使用运算符修饰符?

我对operatorKotlin 中修饰符的使用有点困惑.例如,Kotlin operator在解构声明和属性委托期间使用修饰符,恕我直言(原谅我的无知),有点混乱,因为两个场景都在运算符重载之外.

解构:

operator fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>> = entrySet().iterator()
operator fun <K, V> Map.Entry<K, V>.component1() = getKey()
operator fun <K, V> Map.Entry<K, V>.component2() = getValue()

for ((key, value) in map) {
    // ...
}
Run Code Online (Sandbox Code Playgroud)

物业代表团:

interface ReadOnlyProperty<in R, out T> {
    operator fun getValue(thisRef: R, property: KProperty<*>): T
}

interface ReadWriteProperty<in R, T> {
    operator fun getValue(thisRef: R, property: KProperty<*>): T
    operator fun setValue(thisRef: R, property: KProperty<*>, value: T)
}
Run Code Online (Sandbox Code Playgroud)

kotlin

2
推荐指数
1
解决办法
460
查看次数

标签 统计

kotlin ×2

java ×1

node.js ×1

querydsl ×1

spring-data ×1

typescript ×1

webstorm ×1