Skip to content

Typescript not finding basic javascript methods #639

Closed
@LucasLeeDotNet

Description

@LucasLeeDotNet
  • 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' ); 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions