Skip to content

Typescript not finding basic javascript methods #639

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

Closed
LucasLeeDotNet opened this issue May 3, 2019 · 6 comments · Fixed by #857
Closed

Typescript not finding basic javascript methods #639

LucasLeeDotNet opened this issue May 3, 2019 · 6 comments · Fixed by #857
Labels
bug Something isn't working

Comments

@LucasLeeDotNet
Copy link

LucasLeeDotNet commented May 3, 2019

  • code-server version: 1.939
  • OS Version: OSX 10.13.6, Ubuntu 18.04

Description

When loading an react application with typescript, code-server throws error on:
Object => cannot find name 'Object'
Function => cannot find name 'Function'
document => cannot find name 'document', even thought dom is included in the lib of tsconfig
bind => bind does not exist on type ( id: string )=>void, is not recognizing that functions have the bind prototype
filter => filter does not exist on type {} event thought the variable is initialize as an array and type as an string[]

For context, the application is a react application created using create-react-app
tsconfig is the one that came prebuild:

This was tested on both Mac OSX 10.13.6 and Ubuntu 18.04 with 2 different react apps.

Note that it still compiles as expected, but the intellisense highlighter is reporting it as an error
One the desktop visual studio code, it will compile and intellisense will not highlight these items

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve"
  },
  "include": [
    "src"
  ]
}

Steps to Reproduce

  1. run create-react-app to generate a react app with typescript
npx create-react-app bugs --typescript
  1. create a interface or variable with type Object or Function
export interface iProps{ 
  test: Object;
  onChange: Function;
}
  1. create a function, then call it with bind
const foo = ( echo:string ):string => echo;
foo.bind( this )( 'no' );
  1. create an array and use the filter method
const foo: string[] = [ 'yes', 'no', 'maybe' ];
const yes = foo.filter( ( answer: string ):boolean => answer === 'yes' ); 
@LucasLeeDotNet LucasLeeDotNet added the bug Something isn't working label May 3, 2019
@josephRice
Copy link

Can confirm the issue, as it affects me as well. Windows 10 WSL (sshcode) -> Ubuntu back end on an Angular/typescript project

@josephRice
Copy link

Bumping down the typescript version to 3.3.3333 work around the issue for me. However there still may be an issue with the code-server language files as I have 3.4.3 and 3.3.3333 installed by VSCode.

for reference how to workaround this see

https://stackoverflow.com/questions/53275853/visual-studio-code-showing-error-cant-find-name-date

@LucasLeeDotNet
Copy link
Author

@josephRice Thanks! bumping it down to 3.3.3333 and 3.1.1 worked, just had to also manually switch the version on the vs code bottom toolbar , since 3.4.3 still gets provided by vs code even if a new version is installed in the node module.

@erwinverdonk
Copy link

erwinverdonk commented May 27, 2019

Indeed, at the right bottom you can select the TypeScript version to use. Default the version of Code-Server is being used, which indeed gives this issue. Select 'Use Workspace Version' to use the TypeScript version used by your project.

@maxorlovsky
Copy link

In the bottom right corner of the vscode, try to pick different version of the typescript.

@maxorlovsky
Copy link

Oh never mind, it was answered :) I guess this issue can be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants