【问题标题】:Different behaviour between Typescript in ts files and in jsdocts 文件和 jsdoc 中的 Typescript 之间的不同行为
【发布时间】:2019-07-11 16:40:54
【问题描述】:

Typescript 和 jsdoc 中的 Typescript 中的不同覆盖行为。我觉得我做错了什么。关于 Typescriptin jsdoc 的文档中没有太多信息。请参见下面的示例。

打字稿版本:3.5.3

.tsconfig.json

{
  "compilerOptions": {
    "target": "ES2017",
    "module": "commonjs",
    "lib": ["es2017", "dom"],
    "allowJs": true,
    "checkJs": true,
    "noEmit": true,
    "strict": false,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "esModuleInterop": true
  },
  "include": [
    "*.js",
    "*.ts"
  ]
}

js 文件中的有效打字稿

class A {
    /**
     * @param {number} a
     * @returns {string}
     */
    apply(a) {
        return "";
    }
}

/**
 * @extends {A}
 */
class B extends A {
    /**
     * @param {object} a
     * @returns {string}
     */
    apply(a) {
        return "";
    }
}

ts 文件中的打字稿无效

class A {
    apply(a: number): string {
        return "";
    }
}

class E extends A {
    apply(some: object) { // got error here as function signature is different
        return "";
    }
}

预计A.js 中会出现同样的错误

【问题讨论】:

    标签: typescript jsdoc


    【解决方案1】:

    object,在 typescript 中没有任何意义,使用 Object,用大写的 'O' 代替

    【讨论】:

    • 其实object是TypeScript中的一个类型。
    猜你喜欢
    • 1970-01-01
    • 2016-06-23
    • 1970-01-01
    • 2014-11-01
    • 1970-01-01
    • 2018-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多