添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PS C:\Users\user\Desktop\code\jsonFetch> tsc .\index.ts
node_modules/axios/index.d.ts:75:3 - error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type.

75 Symbol.iterator : IterableIterator<[string, AxiosHeaderValue]>;
~~~~~~~~~~~~~~~~~

node_modules/axios/index.d.ts:75:4 - error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later.

75 Symbol.iterator : IterableIterator<[string, AxiosHeaderValue]>;
~~~~~~

node_modules/axios/index.d.ts:75:24 - error TS2304: Cannot find name 'IterableIterator'.

75 Symbol.iterator : IterableIterator<[string, AxiosHeaderValue]>;
~~~~~~~~~~~~~~~~

Found 3 errors in the same file, starting at: node_modules/axios/index.d.ts:75

To Reproduce

create the two files
package.json
index.ts
both files code is given in code snippet.
if you run tsc .\index.ts i get the following error.

Code snippet

index.ts

import axios from "axios";
const url = 'https://jsonplaceholder.typicode.com/todos/1'
axios.get(url).then(response => {
    console.log(response.data);
});

Package.json

"name" : "jsonfetch" , "version" : "1.0.0" , "description" : "" , "main" : "index.js" , "scripts" : { "test" : "echo \"Error: no test specified\" && exit 1" "keywords" : [ ] , "author" : "" , "license" : "ISC" , "dependencies" : { "axios" : "^1.5.0"

Expected behavior

a compiled version of typescript file which is .js file without any error.

Axios Version

1.5.0

Adapter Version

Browser

chrome

Browser Version

117.0.5938.89

Node.js Version

v18.17.1

windows

Additional Library Versions

nodejs

Additional context/Screenshots

but when is run code with `ts-node .\index.ts` code produce expected result.

@joaocosta-azores

I'm getting the same error. Have you solved yours? Are you at Oak Academy JS course?

@Chris-AM install @types/node package and let me know if it fixes the problem.
Not sure what is Oak Academy JS course. I was doing a udemy typescript course.