Giter VIP home page Giter VIP logo

lsif-node's Introduction

Deprecated: TypeScript LSIF indexer

This project is no longer maintained. Please use scip-typescript instead.

See OLD_README.md for the unmaintained documentation on how to use this project.

lsif-node's People

Contributors

aidaeology avatar arjunattam avatar bobheadxi avatar chrismwendt avatar davejrt avatar dbaeumer avatar efritz avatar eseliger avatar gbrik avatar jumattos avatar macraig avatar microsoftopensource avatar msftgits avatar olafurpg avatar renovate-bot avatar renovate[bot] avatar shrouxm avatar strum355 avatar varungandhi-src avatar vihangm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsif-node's Issues

JavaScript glob pattern doesn’t work as expected in zsh or bash

πŸ‘‹ I’ve been trying to use this project on vanilla JavaScript code and can’t get the example from the README to work as expected due to shell expansion issues (I think). Here is my project’s structure, which is just the output of npx create-react-app my-app with the src folder copied at different levels of nesting:

$ tree .
.
β”œβ”€β”€ README.md
β”œβ”€β”€ dump.lsif
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ App.css
β”‚Β Β  β”œβ”€β”€ App.js
β”‚Β Β  β”œβ”€β”€ App.test.js
β”‚Β Β  β”œβ”€β”€ copy
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ App.css
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ App.js
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ App.test.js
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ copy
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ App.css
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ App.js
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ App.test.js
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ index.css
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ logo.svg
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ serviceWorker.js
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── setupTests.js
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ index.css
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ logo.svg
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ serviceWorker.js
β”‚Β Β  β”‚Β Β  └── setupTests.js
β”‚Β Β  β”œβ”€β”€ index.css
β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β  β”œβ”€β”€ logo.svg
β”‚Β Β  β”œβ”€β”€ serviceWorker.js
β”‚Β Β  └── setupTests.js
└── yarn.lock

This has 15 .js files. The first issue I have is that when I get the indexer to work, there are 17 files indexed. It’s unclear to me whether this is because the .json files are also processed, or something else.

This also fails in zsh when my project contains a node_modules folder:

lsif-tsc **/*.js --AllowJs --checkJs
zsh: argument list too long: lsif-tsc

I assume this is because this relies on shell expansion of the glob pattern. Not sure whether this is a feature or a bug.

Trying to bypass shell expansion doesn’t work either:

lsif-tsc '**/*.js' --AllowJs --checkJs

0 file(s), 0 symbol(s)
Processed in 0.003s

Switching to bash instead of zsh, the shell expansion doesn’t support arbitrarily-deep folder structures:

lsif-tsc **/*.js --AllowJs --checkJs
.....
7 file(s), 113 symbol(s)
Processed in 0.326s

Practically I would want to run this in CI, so can probably figure out which shell this should run inside of with which pattern, but it would be nicer for this to be more portable. And the pattern in the README should "just work" IMHO.


Packages like fast-glob / globby should solve this by making the glob patterns portable across different shells. Then there’s the problem of whether the indexer is meant to go through node_modules, or auto-magically ignore it, or whether there should be a way to supply ignore patterns. Or whether it’s a bad idea to use **/*.js as documented, and users should be told to use more specific patterns.

Symbol type info is not the expected value

Sample code: const foo = Symbol("foo")

When I hover on foo in a js file in vscode I get const foo: typeof foo. When I put the same code in a TS file I get const foo: unique symbol. On Sourcegraph.com, I always get the JS type, even if I'm browsing a TS file.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Invalid document URIs

When generating an LSIF index for lodash we get the following illegal URIs:

{"id":115885,"type":"vertex","label":"document","uri":"file:///test/findLastIndex-and-lastIndexOf.test.js","languageId":"typescript"}

Index was generated with lsif-tsc *.js test/*.js --AllowJs --checkJs.

TypeScript jsx type 'react-jsx' not supported

Since version 4.1 of TypeScript React 17 JSX factories are supported. To do this, the key "jsx" must be set to "react-jsx" in "tsconfig.json".

https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#jsx-factories
https://www.typescriptlang.org/tsconfig#jsx

Unfortunately, lsif-tsc throws the following error

error TS6046: Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'.
    at loadConfigFile (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:85:15)
    at processProject (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:110:18)
    at run (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:259:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:265:1)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
```

[Question] run it on Gitlab

For golang there is an example: https://docs.gitlab.com/ee/user/project/code_intelligence.html#configuration
But none for node, I supposed that it will follow the same syntax but looks like it's not.

Here is what I did:

code_navigation:
 image: sourcegraph/lsif-node
 allow_failure: true # recommended
 script:
   - lsif-node
 artifacts:
   reports:
     lsif: dump.lsif

But it looks like the script is taking arguments in that case: search, api, repos...

What should I do to reproduce what golang is doing?

Publish updated npm package

The latest available @sourcegraph/lsif-tsc on NPM is v0.6.6 which depends on https://github.com/dbaeumer/TypeScript/releases/download/3.8.3-lsif/typescript-3.8.3-lsif.tgz

The latter seems to have been removed from github for some reason and so we can no longer npm install @sourcegraph/lsif-tsc.
Can you publish a newer version of @sourcegraph/lsif-tsc from the master branch since I see that the dbaeumer/TypeScript has been updated to one that's available?

You might also want to decouple from dbaeumer/TypeScript if they keep on deleting old releases.

Indexing TypeScript projects is slow

A customer reported performance issues with lsif-node.

Key points from the discussion:

  • The project involved 4 tsconfig files, each of which had a ~700M LSIF dump, and indexing took in total about 400 seconds on a laptop.
  • It wasn't clear to the customer how they could/should profile the performance.
  • It wasn't clear to the customer how to parallelize builds (and whether it was safe to do so).
  • The customer noted that some colleagues pointed out that the compiler was relatively slow, so the time taken by indexing was "not really unexpected" but she said that it would be nice to speed it up.
  • The customer mentioned that if indexing took over 20 minutes, the index may be invalid by the time it is uploaded.

RangeError: Maximum call stack size exceeded

Happens to some of my lsif-tsc generations. Either due to an infinite loop or it goes way too deep.

....RangeError: Maximum call stack size exceeded
at checkPropertyAccessExpressionOrQualifiedName (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:71051:132)
at checkPropertyAccessExpression (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:70862:17)
at checkExpressionWorker (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:76001:28)
at checkExpression (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:75918:38)
at getTypeOfExpression (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:75859:24)
at getMatchingUnionConstituentForObjectLiteral (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:66116:40)
at discriminateContextualTypeByObjectMembers (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:69270:20)
at getApparentTypeOfContextualType (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:69284:105)
at getContextualTypeForObjectLiteralElement (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:69174:24)
at getContextualType (/Users/william.chau/.config/yarn/global/node_modules/typescript-lsif/lib/typescript.js:69380:28)

Another example:

RangeError: Maximum call stack size exceeded
at Object.createSymbolKey (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/typescripts.js:156:25)
at Symbols.findBaseMembers (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:787:23)
at Symbols.findBaseMembers (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:811:47)
at Symbols.findBaseMembers (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:811:47)
at Symbols.findBaseMembers (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:811:47)
at Symbols.findBaseMembers (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:811:47)
at Symbols.findBaseMembers (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:811:47)
at Symbols.findBaseMembers (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:811:47)
at Symbols.findBaseMembers (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:811:47)
at Symbols.findBaseMembers (/Users/william.chau/.config/yarn/global/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:811:47)

Reference not tracked when creating an object

In the following code, references to the query variable aren't tracked correctly. Using "Find references" on the query variable doesn't return the object in the console.log statement.

export function foo(test: string) {
  const query = 'test'
  console.log({ query })
}

Reproduction example

View the code on Sourcegraph and see that query within the console.log statement isn't shown in references.

Automate Docker Hub uploads

Currently, we don't automatically publish new releases to Docker Hub on git tag push, causing issues like #163. We should add GitHub Actions workflows to automate this step so that Docker Hub is always in sync with what is published to npm.

Lsif-node isn't indexing JSX file and cross references don't work

User from https://app.hubspot.com/contacts/2762526/company/436902646

There is a mix of Typescript and Javascript in this repo.
I’m using the lsif-tsc tool to generate the LSIF file for the repository. I followed this docbut I’ve encountered several problems:
β€’ When indexing JS files over the whole repo, the given command (lsif-tsc **/*.js --allowJs --checkJs) fails because the number of JS files is greater than the bash limit for arguments
β€’ Cross references between TS and JS does not work
β€’ JSX file seems not to be indexed

index Js repository but *.jsx files not analysed

I'm trying to use lsif-node to generate index files for my Js project.
The command I executed was lsif-tsc **/*.js --AllowJs --checkJs. The *.js files were successfully indexed but *.jsx files were not indexed and some problems could be found in the dump.lsif.

{
    "id":281904,
    "type":"vertex",
    "label":"diagnosticResult",
    "result":[
        {
            "severity":1,
            "code":6142,
            "message":"Module './Header.jsx' was resolved to '/xxx/Header.jsx', but '--jsx' is not set.",
            "range":{
                "start":{
                    "line":4,
                    "character":19
                },
                "end":{
                    "line":4,
                    "character":33
                }
            }
        },
        
        {
            "severity":1,
            "code":17004,
            "message":"Cannot use JSX unless the '--jsx' flag is provided.",
            "range":{
                "start":{
                    "line":31,
                    "character":6
                },
                "end":{
                    "line":31,
                    "character":35
                }
            }
        }
       
    ]
}

I tried to use lsif-tsc **/*.js* --AllowJs --jsx --checkJs but it didn't work. I was wondering how to index a Js repository with both js and jsx files analysed.

Depend on our fork of typescript (or get changes merged upstream)

This package (which is a fork of microsoft/lsif-node) depends on a fork of the typescript compiler maintained by the microsoft/lsif-node author.

We should eventually either:

  • maintain our own fork of that fork, since right now we're only half decoupled from their implementation, OR
  • merge our changes to lsif-node back into the original so we don't have to maintain it any more

Multi-project indexing

Dependent projects appear to be indexed but references to files outside of the current project's root are not accessible within the dump (nor are monikers generated as its not a reference to an external library).

"Shouldn't be called" exception

When generating an index for moment we run into the following exception:

Error: Shouldn't be called
    at AliasedSymbolData.getOrCreateReferenceResult (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:462:15)
    at SymbolDataPartition.end (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:623:51)
    at AliasedSymbolData.nodeProcessed (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:405:23)
    at DataManager.nodeProcessed (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:1224:32)
    at Visitor.doVisit (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:1397:26)
    at Visitor.visit (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:1348:22)
    at Visitor.visitProgram (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:1335:18)
    at Object.lsif (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/lsif.js:1970:26)
    at processProject (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:161:19)
    at run (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:222:11)

Index was generated with lsif-tsc **/*.js --AllowJs --checkJs.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

dockerfile
Dockerfile
  • sourcegraph/src-cli 3.16.1@sha256:b5dd688d25557eaa5fb0ec33cf2cc15a87bc72a7f5d9efa6d5e461644e93ac09
  • node 14.5-alpine3.10@sha256:7fb1e608dc4081c25930db83cb4a5df884b6a3f6e4e9f5fa2df08f22778fcfad
Dockerfile.autoindex
  • sourcegraph/src-cli 3.30.4@sha256:76ee253f9ba6ed1a8fdc46ab1e3f333ea0813841d34feb1aa9b8b57edce4eaab
  • node 14.17.4-alpine3.14@sha256:60a5e65ced8bad91a4c57c05a474baa01182b2b773eb50380e4a90ad4b3e6358
github-actions
.github/workflows/lsif.yml
  • actions/checkout v1
.github/workflows/pr-auditor.yml
  • actions/checkout v2
  • actions/setup-go v2
.github/workflows/release-autoindex.yml
  • actions/checkout v2
  • docker/setup-buildx-action v1
  • docker/login-action v1
  • docker/build-push-action v2
.github/workflows/release.yml
  • actions/checkout v2
  • docker/setup-buildx-action v1
  • actions/setup-node v2
  • actions/checkout v2
  • docker/login-action v1
  • docker/build-push-action v2
npm
package.json
  • lru-cache ^5.1.1
  • lsif-protocol 0.4.3
  • minimist ^1.2.0
  • npm ^6.14.2
  • typescript-lsif https://github.com/dbaeumer/TypeScript/releases/download/4.4.0-beta-lsif.1/lsif-typescript-4.4.0-beta-lsif.1.tgz
  • uuid ^7.0.2
  • vscode-uri ^2.1.1
  • @sourcegraph/eslint-config 0.27.1
  • @sourcegraph/prettierrc 3.0.3
  • @sourcegraph/tsconfig 4.0.1
  • @sourcegraph/tslint-config 13.4.0
  • @types/lru-cache 5.1.1
  • @types/minimist 1.2.2
  • @types/node 13.13.51
  • @types/npm 2.0.32
  • @types/uuid 7.0.4
  • eslint 7.32.0
  • prettier 2.7.1
  • ts-node ^8.6.2
  • tslint 6.1.3
  • typescript ^3.8.3
  • node >=10.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

TS5023: Unknown compiler option 'noUncheckedIndexedAccess'

I get a TS5023: Unknown compiler option 'noUncheckedIndexedAccess' error message when I use the current Docker image.

The code can be found here: https://gitlab.com/anti-tracking/ClearURLs/core/-/tree/dev
The CI output here: https://gitlab.com/anti-tracking/ClearURLs/core/-/jobs/1313500016

$ lsif-tsc -p .
Error: error TS5023: Unknown compiler option 'noUncheckedIndexedAccess'.
    at loadConfigFile (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:85:15)
    at processProject (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:110:18)
    at run (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:259:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/@sourcegraph/lsif-tsc/dist/src/main.js:265:1)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

Excess memory usage

In the past, we've run into OOMs with 2GB of RAM in CI. For example: https://github.com/sourcegraph/sourcegraph/runs/4479534778?check_suite_focus=true

(copied relevant part of the log below in case the log gets deleted)

Run yarn eslint -f lsif
yarn run v1.22.4
$ eslint --cache '**/*.[tj]s?(x)' -f lsif

<--- Last few GCs --->

[328:0x55eb601eb760]   480668 ms: Scavenge (reduce) 2031.1 (2051.5) -> 2030.1 (2051.5) MB, 1.9 / 0.0 ms  (average mu = 0.389, current mu = 0.503) allocation failure 
[328:0x55eb601eb760]   480677 ms: Scavenge (reduce) 2031.2 (2051.5) -> 2030.2 (2051.5) MB, 2.0 / 0.0 ms  (average mu = 0.389, current mu = 0.503) allocation failure 
[328:0x55eb601eb760]   480682 ms: Scavenge (reduce) 2031.2 (2051.5) -> 2030.3 (2051.8) MB, 2.1 / 0.0 ms  (average mu = 0.389, current mu = 0.503) allocation failure 


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
error Command failed with signal "SIGABRT".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

Cross-repo monikers

Explore moniker generation and determine why import monikers are not specified where expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.