github / github/codeql

Adding functions from typescript lib files to analysis

Open
#18,748 2 comments 1 reaction 0 assignees View on GitHub
question
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

Hello,

I want to be able to get the CallSignatureType for functions defined in the typescript lib files. I can't seem to get this to work. However, getting the getReturnTypeAnnotation seems to work for some functions. Please let me know how to add typescript lib files to my analysis so I can get call signatures consistently. Do I have to copy over the .d.ts files from the typescript source?

JavaScript file:
```
let x = BigInt.asUintN(64, 0);

let cachedTextEncoder = new TextEncoder('utf-8');
let y = cachedTextEncoder.encode("hi")
```

The following CodeQL query returns no results:
```
from Function called_function, CallExpr call
where called_function.getName() = call.getCalleeName()
select call, called_function.getCallSignature()
```
The following CodeQL query returns results for the `cachedTextEncoder.encode` call:
```
from Function called_function, CallExpr call
where called_function.getName() = call.getCalleeName()
select call, called_function.getCallSignature()
```

I am building the codeql database as follows after running `tsc --init` in the directory with the js file I want to analyze.
```
codeql database create --language=javascript -- ql_db
```

Thank you!

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue using the shown JavaScript file, the database creation command, and the two CodeQL queries. Start by checking how the TypeScript lib files and their .d.ts declarations are included in the analysis; done means calls such as BigInt.asUintN and TextEncoder.encode consistently expose a CallSignatureType.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.