microsoft / microsoft/TypeScript

should be able to run typescript under `--frozen-intrinsics`

Open
#53,699 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Experience Enhancement Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms
  • --frozen-intrinsics
  • Error.stackTraceLimit
  • prototype protection
🕗 Version & Regression Information
  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______
⏯ Playground Link

Playground link with relevant code

💻 Code
import ts from 'typescript'
console.log(ts.sys.fileExists("reproduce.mjs"))
🙁 Actual behavior
$ node --frozen-intrinsics reproduce.mjs 
(node:239937) ExperimentalWarning: The --frozen-intrinsics flag is experimental
(Use `node --trace-warnings ...` to show where the warning was created)
/path/to/node_modules/typescript/lib/typescript.js:6530
            Error.stackTraceLimit = 0;
                                  ^

TypeError <Object <Object <[Object: null prototype] {}>>>: Cannot assign to read only property 'stackTraceLimit' of function 'function Error() { [native code] }'
    at fileSystemEntryExists (/path/to/node_modules/typescript/lib/typescript.js:6530:35)
    at fileExists (/path/to/node_modules/typescript/lib/typescript.js:6551:20)
    at isFileSystemCaseSensitive (/path/to/node_modules/typescript/lib/typescript.js:6397:21)
    at getNodeSystem (/path/to/node_modules/typescript/lib/typescript.js:6189:45)
    at /path/to/node_modules/typescript/lib/typescript.js:6603:18
    at src/compiler/sys.ts (/path/to/node_modules/typescript/lib/typescript.js:6609:9)
    at __init (/path/to/node_modules/typescript/lib/typescript.js:22:58)
    at src/compiler/_namespaces/ts.ts (/path/to/node_modules/typescript/lib/typescript.js:125073:7)
    at __init (/path/to/node_modules/typescript/lib/typescript.js:22:58)
    at src/typescript/_namespaces/ts.ts (/path/to/node_modules/typescript/lib/typescript.js:169775:7)

Node.js v18.15.0
🙂 Expected behavior
$ node reproduce.mjs 
true
$ node --frozen-intrinsics reproduce.mjs 
true

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with node --frozen-intrinsics using the shown reproduce.mjs example, then inspect src/compiler/sys.ts around fileSystemEntryExists and the corresponding typescript.js location. The work is done when importing TypeScript and calling ts.sys.fileExists succeeds under --frozen-intrinsics and returns true as shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.