Проблема с переносом проекта TypeScript на новую версию Visual Studio
Есть солюшен, когда-то написанный на C# и TypeScript в Visual Studio 2017. Возникла необходимость его поправить, но уже в Visual Studio 2019. Все C# проекты собрались без проблем, но основной Web-проект, написанный на TS, не собирается. Выдаёт в файлах определений много ошибок вида:
Error TS2344 (TS) Type '"altKey" | "bubbles" | "cancelable" | "changedTouches" | "ctrlKey" | "detail" | "eventPhase" | "metaKey" | "pageX" | "pageY" | "shiftKey" | "view" | "char" | "charCode" | "key" | ... 13 more ... | "touches"' does not satisfy the constraint '"altKey" | "bubbles" | "cancelable" | "changedTouches" | "ctrlKey" | "detail" | "eventPhase" | "metaKey" | "pageX" | "pageY" | "shiftKey" | "view" | "char" | "charCode" | "key" | ... 55 more ... | "DOM_KEY_LOCATION_STANDARD"'. Type '"toElement"' is not assignable to type '"altKey" | "bubbles" | "cancelable" | "changedTouches" | "ctrlKey" | "detail" | "eventPhase" | "metaKey" | "pageX" | "pageY" | "shiftKey" | "view" | "char" | "charCode" | "key" | ... 55 more ... | "DOM_KEY_LOCATION_STANDARD"'. ARM.Web
Error TS2717 (TS) Subsequent property declarations must have the same type. Property 'support' must be of type 'JQuerySupport', but here has type 'PlainObject'
Попытался установить более новую версию TS, как рекомендовано здесь - не помогло. Вижу в файле index.d вот такой заголовок:
// Type definitions for jquery 3.3
// Project: https://jquery.com
// Definitions by: Leonard Thieu <https://github.com/leonard-thieu>
// ...
// Thomas Schulz <https://github.com/King2500>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
Но ошибки всё те же. Кто-нибудь сталкивался с такой проблемой? Как можно это победить?
upd
Увидел следующее:
в файле ...\MyProject\Scripts\typings\jqueryui\jqueryui.d.ts такое объявление:
interface SortableOptions extends SortableEvents {
...
helper?: string | ((event: Event, element: Sortable) => Element);
...
}
a в файле ...\MyProject\node_modules@types\jqueryui\index.d.ts такое:
interface SortableOptions extends SortableEvents {
...
helper?: string | ((event: JQueryEventObject, element: Sortable) => Element);
...
}
В этом, собственно, и конфликт - несовместимость версий. Как эти файлы "подружить"?
Файл package.json содержит следующее:
{
"name": "myproject",
"version": "1.0.0",
"devDependencies": {
"typescript": "^3.8.2"
"@types/bootstrap-notify": "^3.1.33",
"@types/jquery": "^3.3.4",
"@types/jqueryui": "^1.12.2"
}
}
Т.е. в него прописывается версия установленного TS. А файла tsconfig.json я не нашёл в проекте.
Ответы (1 шт):
не знаю как оно там в мире Visual Studio, но попробую помочь.
Попытался установить более новую версию TS, как рекомендовано здесь...
Не знаю как рекомендовано ТАМ, но Я вам так не рекомендую от слова совсем или очень очень аккуратно.
почему:
Найдите в своём веб проекте файл package.json
{
"devDependencies": {
"typescript": "^3.7.5"
}
}
{
"dependencies": {
"typescript": "^3.7.5"
}
}
"typescript": "^3.7.5" - версия TS в !данном проекте.
найдите файл tsconfig.json
попробуйте !!ДОБАВИТЬ в него всё да по отдельности:
{
"compilerOptions": {
"skipLibCheck": true
},
"exclude": [
"./node_modules"
]
}
если у вас таких файлов нет:
курите этот странный мануал.
пробуйте ищите как то же самое что я сказал реализовать но ... по другому .