Answer the question
In order to leave comments, you need to log in
Using a library having typescript d.ts?
I'm learning typescript.
Faced the problem of connecting the axios library.
main.ts file:
/// <reference path="../node_modules/axios/index.d.ts" />
//import axios from 'axios';
export function ok_lets_go()
{
axios.get('https://ya.ru')
.then((response) => {
console.log(response.data);
console.log(response.status);
});
}
//import axios from 'axios';
/// <reference path="../node_modules/axios/index.d.ts" />
error TS2304: Cannot find name 'axios'.
error TS7006: Parameter 'response' implicitly has an 'any' type.
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title>eXtodo</title>
<meta name="google" content="notranslate">
<meta http-equiv="Content-Type" content="text/html; Charset=utf-8">
<script type="text/javascript" src="./build/axios.js"></script>
</head>
<body>
<div id='app'></div>
<script type="module">
import {ok_lets_go} from './build/main.js';
ok_lets_go();
</script>
</body>
</html>
{
"compilerOptions": {
"target": "ES6",
"module": "es6",
"sourceMap": true,
"outDir": "./build",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"types": ["node"]
},
"compileOnSave": true,
"include": ["./src"],
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question