Во-первых, проект создавался идеально, когда он был в V8.x, я ничего не менял.
Я позвонил
ng update @angular/cli --force
, чтобы обновить, '- force '- это только обход одного пакета, т.е. angular-in-memory-web-api
У меня есть файл определения, который содержит некоторое определение:
// *********** typings.d.ts
/* SystemJS module definition */
declare var module: NodeModule;
interface NodeModule {
id: string;
}
declare var KTMenu: any;
declare var KTOffcanvas: any;
declare var KTScrolltop: any;
declare var KTHeader: any;
declare var KTToggle: any;
declare var KTUtil: any;
declare var KTPortlet: any;
declare var KTDialog: any;
declare var KTWizard: any;
declare var Chart: any;
declare module "*.png" {
const content: any;
export default content;
}
declare module "*.html" {
const content: any;
export default content;
}
declare module "*.jpg" {
const content: any;
export default content;
}
declare module "*.svg" {
const content: any;
export default content;
}
tsconfig
// tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"resolveJsonModule": true,
"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"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
tscoconfig .app. json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"types": []
},
"files": [
"main.ts",
"polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}
the webpack.config
/**
* Main file of webpack config.
* Please do not modified unless you know what to do
*/
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const WebpackRTLPlugin = require("webpack-rtl-plugin");
const WebpackMessages = require("webpack-messages");
const del = require("del");
// theme name
const themeName = "metronic";
// global variables
const rootPath = path.resolve(__dirname);
const distPath = rootPath + "/src/assets";
const entries = {
"css/style.angular": "./src/assets/sass/style.angular.scss"
};
// remove older folders and files
(async () => {
await del.sync(distPath + "/css", { force: true });
})();
const mainConfig = function () {
return {
mode: "development",
stats: "errors-only",
performance: {
hints: false
},
entry: entries,
output: {
// main output path in assets folder
path: distPath,
// output path based on the entries' filename
filename: "[name].js"
},
resolve: { extensions: ['.scss'] },
plugins: [
// webpack log message
new WebpackMessages({
name: themeName,
logger: str => console.log(`>> ${str}`)
}),
// create css file
new MiniCssExtractPlugin({
filename: "[name].css",
}),
new WebpackRTLPlugin({
filename: "[name].rtl.css",
}),
{
apply: (compiler) => {
// hook name
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
(async () => {
await del.sync(distPath + "/css/*.js", { force: true });
})();
});
}
},
],
module: {
rules: [
{//**
test: /\.(png|jpe?g|gif|jp2|webp|svg)$/,
loader: 'file-loader',
exclude: /node_modules/,
options: {
name: 'media/[name].[ext]'
}
},
//{
// test: /\.(mp4)$/i,
// loader: "file-loader?name=/videos/[name].[ext]",
// exclude: /node_modules/
//},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "sass-loader",
options: {
sourceMap: true,
}
},
]
},
]
},
}
};
module.exports = function () {
return [mainConfig()];
};
Проблема в том, что все переменные и модули, определенные в typings.d.ts
, не распознаются и сборка команда продолжает показывать - ошибка TS2304: не удается найти имя 'KTUtil' - KTUtil
является примером