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

Starting v104.4.4 lines of code above $storename cause "Type Foo has no call signatures" etc. errors (with latest dependencies) #859

Closed
vatro opened this issue Mar 5, 2021 · 4 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@vatro
Copy link
Contributor

vatro commented Mar 5, 2021

Describe the bug
With (since) v104.4.4 (incl., last ok: v104.4.3) I get a lot of "Type Foo has no call signatures" errors in my project mostly after creating instances of Classes let foo = new Foo(), simple assignments to boolean values or to undefined, at the end of ternaries etc., yet not everywhere / always 🤔.

👉 Adding an (optional) semicolon after the certain expressions fixes the errors!

EDIT: When using "Svelte for VSCode" 1.0.4.44 or above, anything written above the $ prefixed store name causes errors (with currently latest versions of Svelte / Svelte ts-app template dependencies). Only lines above $storename-lines are affected. Lines above reactive statements' $ are ok, see #859 (comment)

To Reproduce
Since the problem doesn't seem to occur everywhere / always (?), maybe: take a bigger existing semi: true Svelte/TS component and remove them with Prettier semi: false with "Svelte for VSCode" >= v104.4.4 installed.

EDIT: Meanwhile successfully reproduced, see #859 (comment)

Expected behavior
No errors as with <= v104.4.3

System (please complete the following information):

  • Windows 10
  • IDE: VSCode
  • "Svelte for VSCode" >= v104.4.4

Additional context
tsconfig.js

{
    "extends": "@tsconfig/svelte/tsconfig.json",
   
    "compilerOptions": {
        
        // tested, none of these have something to do with the errors
        "target": "ESNext",
        "strict": true,
        "strictNullChecks": false,
        "noImplicitAny": false,
        "strictFunctionTypes": true,

        // "Svelte for VSCode Problem": "no call signatures" etc. errors: 
        // v103.0.0: ok
        // v104.0.0: ok
        // v104.0.0: ok
        // v104.4.0: ok
        // v104.4.3: ok
        // v104.4.4: errors start

    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules/*",
        "__sapper__/*",
        "public/*"
    ]
} 

Svelte 3.35.0
TypeScript 4.2.3

@vatro vatro added the bug Something isn't working label Mar 5, 2021
@dummdidumm
Copy link
Member

Could you provide a code snippet where this occurs?

@vatro
Copy link
Contributor Author

vatro commented Mar 5, 2021

Could you provide a code snippet where this occurs?

sorry, not atm, but they occur at many different places / cases + not always, mostly as I've described above. I couldn't figure out any "real" logic yet. Will take a look again at it later.

EDIT:
The errors could also (somehow, atm: 🤷🏼‍♂️) be related to my project setup, though before I was able to nail them down to (at least as it seems atm) using a specific "Svelte for VSCode" version, I tried changing any of relevant VSCode / tsconfig / RollUp settings.

AND ☝️ before getting them, I believe I've updated all packages (Svelte for sure), so the latest Svelte / TS / RollUp etc. might also be the reason. Will check again later!

@dummdidumm
Copy link
Member

As long as it's a reproducible code snippet I'm fine, you don't need to track down the logic

@vatro
Copy link
Contributor Author

vatro commented Mar 5, 2021

@dummdidumm Ok, I was able to reproduce it:

  1. Create a fresh svelte-ts-app
npx degit sveltejs/template svelte-typescript-app
cd svelte-typescript-app
node scripts/setupTypeScript.js
  1. Update all dependecies
 "devDependencies": {
    "@rollup/plugin-commonjs": "^17.1.0",
    "@rollup/plugin-node-resolve": "^11.2.0",
    "@rollup/plugin-typescript": "^8.2.0",
    "@tsconfig/svelte": "^1.0.10",
    "rollup": "^2.40.0",
    "rollup-plugin-css-only": "^3.1.0",
    "rollup-plugin-livereload": "^2.0.0",
    "rollup-plugin-svelte": "^7.1.0",
    "rollup-plugin-terser": "^7.0.2",
    "svelte": "^3.35.0",
    "svelte-check": "^1.2.2",
    "svelte-preprocess": "^4.6.9",
    "tslib": "^2.1.0",
    "typescript": "^4.2.3"
  },
  "dependencies": {
    "sirv-cli": "^1.0.11"
  }
  1. Create a simple app / component using a store

BUG: When using "Svelte for VSCode" 1.0.4.44 or above, anything written above the $ prefixed store name causes errors. Only lines above $storename-lines are affected. Reactive statements' $ are ok.

image

adding a semicolon at the end of the affected lines, fixes errors:

image

@vatro vatro changed the title Since v104.4.4 multiple "Type Foo has no call signatures" etc. errors when not using (optional) JS semicolons Starting v104.4.4 lines of code above $storename cause "Type Foo has no call signatures" etc. errors Mar 5, 2021
@vatro vatro changed the title Starting v104.4.4 lines of code above $storename cause "Type Foo has no call signatures" etc. errors Starting v104.4.4 lines of code above $storename cause "Type Foo has no call signatures" etc. errors (with latest dependencies) Mar 5, 2021
dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Mar 5, 2021
The store transformation now is prepended with a semicolon if it's the first thing in an expression statement because the statement above it could end without a semicolon, making JavaScript think that this is a function invocation
sveltejs#859
dummdidumm added a commit that referenced this issue Mar 5, 2021
The store transformation now is prepended with a semicolon if it's the first thing in an expression statement because the statement above it could end without a semicolon, making JavaScript think that this is a function invocation
#859
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants