I have this simple typescript code:
const y = Buffer.from("fds")
y.toString("hex")
But I am getting a tsc type error on "hex" saying Expected 0 arguments, but got 1.
The toString method takes in an argument though https://nodejs.org/api/buffer.html#buftostringencoding-start-end
So it seems like my types are somehow not up to date for just this standard library somehow?
╰─❯ node -v
v20.12.2
╰─❯ yarn tsc -v
Version 5.3.2
I am running yarn run tsc --noEmit --p ./src --incremental"
My tsconfig
{
"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
}
}
I ended up solving this by deleting node_modules/ and reinstalling.