У меня есть этот простой машинописный код:
const y = Buffer.from("fds")
y.toString("hex")
Но я получаю ошибку типа tsc в «hex»: Expected 0 arguments, but got 1.
Однако метод toString принимает аргумент https://nodejs.org/api/buffer.html#buftostringencoding-start-end
Получается, что мои типы как-то не актуальны только для этой стандартной библиотеки?
╰─❯ node -v
v20.12.2
╰─❯ yarn tsc -v
Version 5.3.2
Я бегу yarn run tsc --noEmit --p ./src --incremental"
Мой цконфиг
{
"extends": "../tsconfig.base.json",
"include": ["./src/**/*", "./mmmEval"],
"exclude": ["node_modules", "_build", "dist"],
"compilerOptions": {
"target": "es2020",
"composite": true,
"module": "ESNext",
"baseUrl": "./src",
"paths": {
"#src/*": ["./*"]
},
"types": ["node"],
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"plugins": [{ "name": "grats-ts-plugin" }]
},
"grats": {
"graphqlSchema": "./src/gql/schema.generated.graphql",
"tsSchema": "./src/gql/schema.generated.ts",
"tsSchemaHeader": "// @ts-nocheck\n // This file was automatically generated and should not be edited.\n",
"nullableByDefault": false
},
}
tsconfig.base.json
{
"compilerOptions": {
"composite": true,
"target": "es2022",
"lib": ["es2022", "dom", "dom.iterable", "esnext.disposable", "ESNext.Disposable"],
"module": "CommonJS",
"preserveSymlinks": true,
"preserveValueImports": true,
"ignoreDeprecations": "5.0",
"noUnusedLocals": true,
"esModuleInterop": false,
"forceConsistentCasingInFileNames": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"strict": true,
"skipLibCheck": true,
"importsNotUsedAsValues": "error",
"noFallthroughCasesInSwitch": true,
"isolatedModules": true
}
}
Как лучше всего узнать, какие типы узлов я установил? У меня есть эти типы пакетов в моем package.json ``` "@types/find-config": "^1.0.1", "@types/luxon": "^3", "@types/pg": "^ 8.10.2", "@types/semver": "^7", "@types/diff": "^5", ```






Вам необходимо добавить в проект недостающую зависимость: @types/node определения типов для узла.
yarn add @types/node
Это должно решить вашу проблему
В итоге я решил эту проблему, удалив node_modules/ и переустановив.
какие типизации для узла у вас установлены?