How to fix this Error? Why do not works HTMLSelectElement? I build with webpack. Another modules works. If I remove HTMLSelectElement, cant build, because
Error TS2339 (TS) Property 'options' does not exist on type 'HTMLElement'.
index.cshtml
<select class="form-control me-2" name="select">
<option value="4">Four</option>
</select>
<button class="btn btn-outline-success" id="submit">Search</button>
index.ts
document.getElementById("submit").addEventListener("click", function () {
const select = document.getElementsByName("select")[0] as HTMLSelectElement;
});
webpack.config.js
const webpack = require('webpack');
module.exports = {
entry: './Scripts/index.ts',
output: {
path: __dirname
+ "/wwwroot/js",
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
],
},
],
},
mode: 'production',
devtool: 'eval-cheap-source-map',
optimization: {
usedExports: true,
}
};
tsconfig.json
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "ES2020",
"module": "ES2020",
"skipLibCheck": true,
"baseUrl": "node_modules"
},
"compileOnSave": true,
"exclude": [
"node_modules",
"wwwroot"
],
"include": [
"Scripts/*.ts"
]
}