Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

Cannot find global type 'CallableFunction' #2646

Closed
ckaznocha opened this issue Feb 9, 2023 · 3 comments · Fixed by #2712
Closed

Cannot find global type 'CallableFunction' #2646

ckaznocha opened this issue Feb 9, 2023 · 3 comments · Fixed by #2712
Labels

Comments

@ckaznocha
Copy link

ckaznocha commented Feb 9, 2023

Bug description

Opening an assemblyscript project with vscode results in the error "Cannot find global type 'CallableFunction'" from the tsconfig.json. It looks like this is caused by the noLib being true and no global definition for CallableFunction in the assemblyscript d.ts files. This only started for me after I updated to the latest version of vscode which I'm under the impression comes with a bundled version of typescript.

I found some folks on so are having the same problem with no resolution but I wasn't able to find an issue here so creating one.

https://stackoverflow.com/questions/74438208/cannot-find-global-type-callablefunction-error-in-tsconfig-json-file

Steps to reproduce

Open an assemblyscript project with vscode v1.75.0 then edit any ts file.

AssemblyScript version

v0.26.7

@ckaznocha ckaznocha added the bug label Feb 9, 2023
@dcodeIO
Copy link
Member

dcodeIO commented Feb 10, 2023

Seems we'll need to declare a mock CallableFunction in std/index.d.ts, where the noLib environment is declared, so TS tooling can pick it up. Might be as simple as copy-pasting the interface TS uses.

@neodon
Copy link

neodon commented Feb 12, 2023

I ran into this as well. Turns out newer versions of TypeScript have stricter typing for bind, call, and apply. See TypeScript 3.2 released with configuration inheritance and more under the strictBindCallApply heading for a bit more detail.

For now, you can disable these newer types by changing your project's tsconfig.json and setting strictBindCallApply to false like this:

{
  "extends": "assemblyscript/std/assembly.json",
  "include": [
    "./**/*.ts"
  ],
  "compilerOptions": {
    "strictBindCallApply": false
  }
}

@ckaznocha
Copy link
Author

Thanks for posting this workaround @neodon! I tried it in a project and can confirm it suppresses the new errors from the tsconfig.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants