Skip to content

merge upstream #4

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

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
fdf79f0
Add `unsorted` expected completions (#1351)
gabritto Jul 2, 2025
6faf496
Update copilot instructions and setup steps with new stuff (#1350)
Copilot Jul 2, 2025
af0fe4a
Bump github/codeql-action from 3.29.0 to 3.29.1 in the github-actions…
dependabot[bot] Jul 2, 2025
104aea5
Implement tryLoadInputFileForPath, file loader diags (#1302)
jakebailey Jul 3, 2025
15def02
Make `projecttestutil.Setup` generic, avoid casts. (#1353)
DanielRosenwasser Jul 3, 2025
69a1fc5
Fixed some completions close to end of files (#1356)
Andarist Jul 3, 2025
f156cc3
Add `goTo....` functions to fourslash (#1357)
gabritto Jul 4, 2025
76d4e43
Handle LSP textDocument/documentSymbol requests (#1363)
ahejlsberg Jul 6, 2025
2fe47a5
Add script to update list of failing generated fourslash tests (#1361)
gabritto Jul 7, 2025
7919c9a
Add CFA regression test for while loop with continue statements (#1325)
Copilot Jul 7, 2025
b7f1b49
Don't allocate empty slice for named members (#1312)
jakebailey Jul 7, 2025
09e7953
Clean up host related code (#1354)
jakebailey Jul 7, 2025
e092266
Temporarily work around GetLineMap CPU usage (#1368)
jakebailey Jul 8, 2025
9953b71
Clear out checker-level stacks on pop (#1369)
jakebailey Jul 8, 2025
1f1dd93
Port TS PR 61505 - Cache mapper instantiations (#1358)
jakebailey Jul 8, 2025
7347bf4
fourslash baselines and `VerifyBaselinefindAllReferences` (#1274)
iisaduan Jul 8, 2025
7b92fe5
Fix no-file cases (#1370)
jakebailey Jul 8, 2025
bc8d29c
Fix panic when hovering over functions with JSDoc links (#1339)
Copilot Jul 8, 2025
7c32d84
Various memory allocation improvements (#1366)
jakebailey Jul 8, 2025
36d9e06
Avoid holding on to NodeBuilder in checker (#1289)
jakebailey Jul 8, 2025
b630b33
Port ES2016 transform (#1371)
weswigham Jul 8, 2025
742fcd2
Port es2021 transform (#1372)
weswigham Jul 8, 2025
685faad
Allow duplicate names in package.json parsing (#1321)
jakebailey Jul 9, 2025
a076c17
Port `??` binary operator emit (#1375)
weswigham Jul 9, 2025
ff64032
Use update failing tests script in CI (#1378)
gabritto Jul 9, 2025
dec0b9d
Better formatting for generated fourslash tests (#1377)
gabritto Jul 9, 2025
48799f0
Handle `completionItem/resolve` (#1384)
gabritto Jul 10, 2025
a942c19
fix(1379): add return type support to construct signature declaration…
a-tarasyuk Jul 11, 2025
678ab6f
Port verifyCompilerOptions, error on things removed from this repo (#…
jakebailey Jul 11, 2025
5f0157e
Ignore go/allocation-size-overflow in codeql (#1392)
jakebailey Jul 11, 2025
23aad64
Keep reusing caches from previous runs for copilot runs (#1390)
jakebailey Jul 11, 2025
19c1578
Port some more truncation check related code (#1373)
jakebailey Jul 11, 2025
3195e8e
fix(1342): adjust node ranges to ignore trivia (#1355)
a-tarasyuk Jul 11, 2025
fba8b25
Port TS PR 61764 (for (using of = is incorrectly parsed) (#1307)
a-tarasyuk Jul 11, 2025
6e77150
Small fixes to fourslash tests conversion script (#1393)
gabritto Jul 11, 2025
83d4f30
Fix setup-go restore key (#1394)
jakebailey Jul 11, 2025
b0107af
Undo my CI caching changes (#1395)
jakebailey Jul 11, 2025
2b82831
lsp: Check diagnostic refresh capabilities against nil values & suppo…
osiewicz Jul 12, 2025
6c17bea
Port `?.` emit (#1385)
weswigham Jul 14, 2025
f9ca2a1
Fix `completionItem/resolve` keyword and hover crashes (#1403)
gabritto Jul 14, 2025
e62a044
Port `isInComment` (#1397)
gabritto Jul 15, 2025
256441c
Completions fixes (#1404)
gabritto Jul 15, 2025
eb83c1c
Fix invalid URI for untitled references/definitions (#1344)
Copilot Jul 15, 2025
2342d77
Obtain target type before calling getBaseTypes (#1409)
ahejlsberg Jul 16, 2025
d0520d8
Add issue templates (#1410)
andrewbranch Jul 17, 2025
4fd6eb1
Improve go-to-definition and implement go-to-type-definition (#1405)
ahejlsberg Jul 17, 2025
96c0688
Deep clone JSDoc (#1412)
sandersn Jul 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/01-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Crash
about: Using tsgo or the language server caused a panic
title: ''
labels: Crash
assignees: ''

---

## Stack trace

```
[paste stack trace here]
```

## Steps to reproduce

1.
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/02-behavior-difference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Behavior Difference
about: tsgo produces different results than TypeScript 5.8
title: ''
labels: ''
assignees: ''

---

## Steps to reproduce

<!-- Share a repository link or a code sample -->

## Behavior with `[email protected]`

## Behavior with `tsgo`
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/03-other.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Other
about: Something else
title: ''
labels: ''
assignees: ''

---


26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/04-copilot-pr-porting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: '[TypeScript Team Use] Copilot PR porting'
about: Instructions for Copilot to port a PR from microsoft/TypeScript
title: 'Port TypeScript PR #[NNNNN]'
labels: Porting PR
assignees: ''

---

This repository is a port of microsoft/TypeScript from TypeScript to Go. Since the port began, the following pull request was applied to microsoft/TypeScript. An equivalent change now needs to be applied here.

## PR to port

- PR link: <!-- https://github.com/microsoft/TypeScript/pull/NNNNN -->
- Squash commit diff: <!-- Copy the squash commit link and append ".patch", e.g. https://github.com/microsoft/TypeScript/commit/a271797c1a95494e5f7aa8075c01941ad25cad08.patch -->

## Instructions

1. Use `playwright` to view the PR listed above
2. Apply the edits made in that PR to this codebase, translating them from TypeScript to Go.
- The change may or may not be applicable. It may have already been ported. Do not make any significant changes outside the scope of the diff. If the change cannot be applied without significant out-of-scope changes, explain why and stop working.
- Tip: search for functions and identifiers from the diff to find the right location to apply edits. Some files in microsoft/TypeScript have been split into multiple.
- Tip: some changes have already been ported, like changes to diagnostic message text. Tests do not need to be ported as they are imported from the submodule.
3. Refer to your copilot_instructions.md for guidance on how to build and test your change. Note the following differences to the typical development workflow:
- Since you are porting the implementation for a behavior that already has tests in the submodule, you don't need to add new tests. Instead, your change should change existing baselines.
- If done correctly, you should see removals in `.diff` baselines. These `.diff` removals are your ultimate source of truth: your change is not correct unless diffs are reduced.
9 changes: 5 additions & 4 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ runs:
go-version: ${{ inputs.go-version }}
cache: false

# There is more code downloaded and built than is covered by '**/go.sum',
# so give each job its own cache to try and not end up sharing the wrong
# cache between jobs, and hash the Herebyfile and golancgi-lint version.

- name: Go cache
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
# There is more code downloaded and built than is covered by '**/go.sum',
# so give each job its own cache to try and not end up sharing the wrong
# cache between jobs.
key: ts-setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/Herebyfile.mjs', '**/.custom-gcl.yml') }}-${{ github.workflow }}-${{ inputs.cache-name }}
restore-keys: |
ts-setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/Herebyfile.mjs', '**/.custom-gcl.yml') }}
ts-setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/Herebyfile.mjs', '**/.custom-gcl.yml') }}-${{ github.workflow }}-
path: |
~/go/pkg/mod
~/.cache/go-build
Expand Down
3 changes: 3 additions & 0 deletions .github/codeql/codeql-configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ query-filters:
# This query takes too long on complicated string manipulations
- exclude:
id: go/unsafe-quoting
# Times out in our code.
- exclude:
id: go/allocation-size-overflow
26 changes: 19 additions & 7 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,29 @@ Most of our development takes place in the `internal` directory, and most behavi

Most development on the codebase is in Go.
Standard Go commands and practices apply, but we primarily use a tool called `hereby` to build, run tests, and other tasks.
Feel free to install `hereby` globally (`npm install -g hereby`) if it is easier, and run `hereby --list` to see all available commands.
Run `npx hereby --list` to see all available commands.

```sh
hereby build # Build the project
hereby test # Run tests
hereby format # Format the code
hereby lint # Run linters
npx hereby build # Build the project
npx hereby test # Run tests
npx hereby format # Format the code
npx hereby lint # Run linters

# To run a specific compiler test:
go test -run='TestSubmodule/<test name>' ./internal/testrunner # For submodule tests in _submodules/TypeScript
go test -run='TestLocal/<test name>' ./internal/testrunner # For local tests in testdata/tests/cases
```

Always make sure code is formatted, linted, and tested before sending a pull request.
Always make sure code is formatted, linted, and tested before sending a pull request.

## Compiler Features, Fixes, and Tests

When fixing a bug or implementing a new feature, at least one minimal test case should always be added in advance to verify the fix.
This project primarily uses snapshot/baseline/golden tests rather than unit tests.
New compiler tests are written in `.ts`/`.tsx` files in the directory `testdata/tests/cases/compiler/`, and are written in the following format:

**Note:** Issues with editor features cannot be tested with compiler tests in `testdata/tests/cases/`. Editor functionality requires integration testing with the language server.

```ts
// @target: esnext
// @module: preserve
Expand Down Expand Up @@ -79,6 +85,12 @@ It is ideal to implement features and fixes in the following order, and commit c

It is fine to implement more and more of a feature across commits, but be sure to update baselines every time so that reviewers can measure progress.

## Code Porting Reference

The code in `internal` is ported from the code in `_submodules/TypeScript`.
When implementing features or fixing bugs, those files should be searched for similar functions when code is either missing or potentially wrong.
The TypeScript submodule serves as the reference implementation for behavior and functionality.

# Other Instructions

- Do not add or change existing dependencies unless asked to.
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,8 @@ jobs:
- run: node ./internal/lsp/lsproto/_generate/fetchModel.mjs
- run: node ./internal/lsp/lsproto/_generate/generate.mjs

- name: Remove all converted fourslash tests
run: rm -rf internal/fourslash/tests/gen

- name: Regenerate fourslash tests
run: npm run convertfourslash
- name: Regenerate fourslash tests and update failing test list
run: npm run updatefailing

- run: git add .
- run: git diff --staged --exit-code --stat
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
uses: github/codeql-action/init@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
with:
config-file: ./.github/codeql/codeql-configuration.yml
# Override language selection by uncommenting this and choosing your languages
Expand All @@ -58,7 +58,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
uses: github/codeql-action/autobuild@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -72,4 +72,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
uses: github/codeql-action/analyze@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
5 changes: 5 additions & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ jobs:
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
- uses: ./.github/actions/setup-go
with:
# Updated to 1.25.0-rc.1 to improve compilation time
go-version: '>=1.25.0-rc.1'
cache-name: copilot-setup-steps
- run: npm i -g @playwright/[email protected]
- run: npm ci
# pull dprint caches before network access is blocked
- run: npx hereby check:format || true
# cache build and lint operations
- run: npx hereby build || true
- run: npx hereby lint || true
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ linters:
type: module

exclusions:
rules:
- path: internal/fourslash/tests/gen/
linters: misspell

presets:
- comments
- std-error-handling
Expand Down
1 change: 0 additions & 1 deletion cmd/tsgo/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func runAPI(args []string) int {
Out: os.Stdout,
Err: os.Stderr,
Cwd: *cwd,
NewLine: "\n",
DefaultLibraryPath: defaultLibraryPath,
})

Expand Down
8 changes: 0 additions & 8 deletions cmd/tsgo/sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import (
"fmt"
"io"
"os"
"runtime"
"time"

"github.com/microsoft/typescript-go/internal/bundled"
"github.com/microsoft/typescript-go/internal/core"
"github.com/microsoft/typescript-go/internal/execute"
"github.com/microsoft/typescript-go/internal/tspath"
"github.com/microsoft/typescript-go/internal/vfs"
Expand All @@ -19,7 +17,6 @@ type osSys struct {
writer io.Writer
fs vfs.FS
defaultLibraryPath string
newLine string
cwd string
start time.Time
}
Expand All @@ -44,10 +41,6 @@ func (s *osSys) GetCurrentDirectory() string {
return s.cwd
}

func (s *osSys) NewLine() string {
return s.newLine
}

func (s *osSys) Writer() io.Writer {
return s.writer
}
Expand All @@ -69,7 +62,6 @@ func newSystem() *osSys {
fs: bundled.WrapFS(osvfs.FS()),
defaultLibraryPath: bundled.LibPath(),
writer: os.Stdout,
newLine: core.IfElse(runtime.GOOS == "windows", "\r\n", "\n"),
start: time.Now(),
}
}
5 changes: 0 additions & 5 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ func (api *API) Trace(s string) {
api.options.Logger.Info(s)
}

// NewLine implements ProjectHost.
func (api *API) NewLine() string {
return api.host.NewLine()
}

// PositionEncoding implements ProjectHost.
func (api *API) PositionEncoding() lsproto.PositionEncodingKind {
return lsproto.PositionEncodingKindUTF8
Expand Down
1 change: 0 additions & 1 deletion internal/api/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ type APIHost interface {
FS() vfs.FS
DefaultLibraryPath() string
GetCurrentDirectory() string
NewLine() string
}
7 changes: 0 additions & 7 deletions internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type ServerOptions struct {
Out io.Writer
Err io.Writer
Cwd string
NewLine string
DefaultLibraryPath string
}

Expand Down Expand Up @@ -98,7 +97,6 @@ func NewServer(options *ServerOptions) *Server {
w: bufio.NewWriter(options.Out),
stderr: options.Err,
cwd: options.Cwd,
newLine: options.NewLine,
fs: bundled.WrapFS(osvfs.FS()),
defaultLibraryPath: options.DefaultLibraryPath,
}
Expand Down Expand Up @@ -126,11 +124,6 @@ func (s *Server) GetCurrentDirectory() string {
return s.cwd
}

// NewLine implements APIHost.
func (s *Server) NewLine() string {
return s.newLine
}

func (s *Server) Run() error {
for {
messageType, method, payload, err := s.readRequest("")
Expand Down
Loading