Ошибка TypeScript "TS2354: для этого синтаксиса требуется импортированный помощник, но модуль 'tslib' не найден" - PullRequest
0 голосов
/ 14 апреля 2020

Я сократил проблему с TypeScript до следующего примера. При попытке запустить ts c я получаю следующее сообщение об ошибке, но tslib должно быть доступно.

https://codesandbox.io/s/quizzical-mclean-n9vvi?fontsize=14&hidenavigation=1&theme=dark

$ tsc --noEmit --project ./tsconfig.json

index.js:3:8 - error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found.

3 const {ArgumentParser} = require('argparse');
         ~~~~~~~~~~~~~~
Found 1 error.

пакет. json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.ts",
  "scripts": {
    "test": "tsc --noEmit --project ./tsconfig.json"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/argparse": "1.0.38",
    "argparse": "1.0.10",
    "tslib": "1.11.1",
    "typescript": "3.8.3"
  }
}

tsconfig. json

{
  "compilerOptions": {
    "checkJs": true,
    "allowJs": true,
    "moduleResolution": "node",
    "target": "es2018",
    "module": "commonjs",
    "importHelpers": true,
    "lib": [
      "es2018"
    ]
  },
  "include": [
    "*.js"
  ],
  "exclude": [
    "node_modules"
  ]
}

index. js

'use strict';

const {ArgumentParser} = require('argparse');

1 Ответ

0 голосов
/ 18 апреля 2020

Теперь проблема подтверждена как ошибка в TypeScript https://github.com/microsoft/TypeScript/issues/37991

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...