question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript not finding basic javascript methods

See original GitHub issue
  • 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' ); 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

2reactions
LucasLeeDotNetcommented, May 11, 2019

@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.

0reactions
maxorlovskycommented, May 28, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript not finding basic javascript methods #639 - GitHub
Description. When loading an react application with typescript, code-server throws error on: Object => cannot find name 'Object' Function = ...
Read more >
Typescript cannot find method in definition file - Stack Overflow
app.d.ts is defining a method on an interface called App , but the TableViewModel is trying to use a global function called pageSetUp ......
Read more >
Documentation - TypeScript for JavaScript Programmers
By understanding how JavaScript works, TypeScript can build a type-system that accepts JavaScript code but has types. This offers a type-system without ......
Read more >
TypeScript: JavaScript With Syntax For Types.
TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. Property 'name' does not exist...
Read more >
Documentation - Type Checking JavaScript Files - TypeScript
In a .js file, the compiler infers properties from property assignments inside the class body. The type of a property is the type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found