-
-
Notifications
You must be signed in to change notification settings - Fork 532
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
ReferenceError: Request is not defined #1134
Comments
Looks like a JavaScript error. Have you verified that the code executes
correctly with tsc? As opposed to compiling.
…On Sat, Oct 24, 2020, 10:07 AM Karl Stoney ***@***.***> wrote:
I have an issue with Request from WebWorker.
It appears to be fine with tsc but not ts-node.
As an example:
tsconfig.json:
{
"compilerOptions": {
"types": ***@***.***/workers-types", "mocha"],
"module": "CommonJS",
"target": "es2020",
"lib": ["es2017", "WebWorker"],
"rootDir": "./",
"outDir": "./built",
"baseUrl": "./",
"allowJs": true,
"checkJs": true,
"alwaysStrict": true,
"noImplicitAny": false,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"noEmitOnError": false,
"sourceMap": false
},
"include": ["lib/**/*.ts", "test/**/*.ts"],
"exclude": ["node_modules"]
}
and lib/example.ts:
const example = new Request({} as any)
console.log(example)
./node_modules/.bin/tsc lib/example.ts = completes fine
ts-node however, does not:
❯ ./node_modules/.bin/ts-node --project tsconfig.json lib/example.ts
/Users/karl.stoney/git/autotrader/at-global-worker/lib/example.ts:1
const example = new Request({} as any)
^
ReferenceError: Request is not defined
at Object.<anonymous> (/Users/karl.stoney/git/autotrader/at-global-worker/lib/example.ts:1:17)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Module.m._compile (/Users/karl.stoney/git/autotrader/at-global-worker/node_modules/ts-node/src/index.ts:1043:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
at Object.require.extensions.<computed> [as .ts] (/Users/karl.stoney/git/autotrader/at-global-worker/node_modules/ts-node/src/index.ts:1046:12)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at main (/Users/karl.stoney/git/autotrader/at-global-worker/node_modules/ts-node/src/bin.ts:225:14)
at Object.<anonymous> (/Users/karl.stoney/git/autotrader/at-global-worker/node_modules/ts-node/src/bin.ts:512:3)
As a result, I'm unable to use ts-node to run the project or tests.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1134>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OBAKEJH47WQZGMAX33SMLNRHANCNFSM4S5TO2ZA>
.
|
@Stono this looks like a problem with the workers-types Your code does |
I'm gonna go ahead and close this since it looks like an external issue. If you find any information that shows it's a ts-node issue, and we need to make a bugfix, let us know and we'll reopen the ticket. |
I have an issue with
Request
fromWebWorker
.It appears to be fine with
tsc
but notts-node
.As an example:
tsconfig.json
:and
lib/example.ts
:./node_modules/.bin/tsc lib/example.ts
= completes fineIntellisense in vscode = fine.
ts-node
however, does not:As a result, I'm unable to use
ts-node
to run the project or tests.The text was updated successfully, but these errors were encountered: