1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Angularにgts導入したらaot buildできなくて詰んだ話

Last updated at Posted at 2019-11-11

楽にLintを導入したかっただけなのに

$ npx gts init

何も考えずOverwriteポチー

エラーの山が襲来

AoT buildができない!

多すぎて一部抜粋。

これとか
addEventListener(element: HTMLElement, eventName: string, handler: Function): Function;

これとか
src/main.ts:12:17 - error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.

⇒ gtsでtsconfig.jsonが上書きしてしまったことが原因。

解決法

tsconfig.jsonのtargetやlibを戻せば解決した。

tsconfig.json
{
  "extends": "./node_modules/gts/tsconfig-google.json",
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "include": [
    "src/**/*.ts",
    "test/**/*.ts"
  ],
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?