【问题标题】:duplicate data property in object literal is not allowed in strict mode严格模式下不允许对象文字中的重复数据属性
【发布时间】:2017-12-31 03:48:12
【问题描述】:

当我在浏览器 (ionic serve -l) 中运行我的应用程序时,一切都很好,即使在大多数 android 设备上也没有问题,但我发现一些不会启动应用程序并在设备上方出现错误时死机。我在 android 5.0.2 上运行时遇到问题。我什至尝试在 tsconfig.json 中关闭严格模式,但没有成功。是否有人遇到过类似的问题,或者有什么方法可以找出问题的确切位置?

tsconfig.json

{
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "declaration": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "diagnostics": true,
        "allowUnreachableCode": true,
        "noImplicitUseStrict": true,
        "lib": [
          "dom",
          "es2015"
        ],
        "module": "es2015",
        "moduleResolution": "node",
        "sourceMap": true,
        "target": "es5"
      },
      "include": [
        "src/**/*.ts"
      ],
      "exclude": [
        "node_modules"
      ],
      "compileOnSave": false,
      "atom": {
        "rewriteTsconfig": false
      }    

}

【问题讨论】:

  • 这不是一个有效的 json 结构
  • 没错,只是忘记在这篇文章中添加“{”

标签: android json typescript ionic2


【解决方案1】:

您有所有这些选项来配置严格的类型检查:

    /* Strict Type-Checking Options */        
    "strict": true,                        /* Enable all strict type-checking options. */
    "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
    "strictNullChecks": true,              /* Enable strict null checks. */
    "noImplicitThis": true,                /* Raise error on 'this' expressions with an implied 'any' type. */
    "alwaysStrict": true,                  /* Parse in strict mode and emit "use strict" for each source file. */

请注意,TypeScript 2.3 中添加了“严格”​​配置

【讨论】:

  • 尝试了所有这些,但没有成功,看起来严格模式仍在。
  • 您的 TS 或 JS 文件中有“use strict”吗?
  • 'use strict' 在 JS 文件中
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-01-01
  • 1970-01-01
  • 2015-02-05
  • 2016-08-21
  • 2015-07-08
  • 2018-11-11
相关资源
最近更新 更多