`{@link https...}` inside a `@remarks` causes error TS2304: Cannot find name 'https'
See original GitHub issueBug Report
š Search Terms
- jsdoc
- tsdoc
- TS2304: Cannot find name āhttpsā.
@link
@remarks
š Version & Regression Information
- This is the behaviour in every version I tried, and I reviewed the FAQ for entries ā
I checked on 4.6.4, 4.6.2.
I tried checking on 4.7.0-rc1 but I got unrelated errors.
āÆ Playground Link
I donāt understand how to use the āBug Workbenchā, it doesnāt seem to pick up the config I enter.
But when I set up those 3 files in a directory and run npm install
then npm build
, I get this error
...
Emitting ...
Emit finished!
node_modules/typed-factorio/generated/classes.d.ts:238:3 - error TS2304: Cannot find name 'https'.
238 on_init(f: (() => void) | undefined): void
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Process finished with exit code 2
Hereās a reproduction inside the TSTL playground. You might have to edit the file to trigger it
š» Code
An MRE is below, but the error originates in the TSDoc of the Typed Factorio project, in classes.d.ts
.
/**
* Register a function to be run on mod initialization...
*
* {@link https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.on_init View documentation}
* @param f The handler for this event. Passing `nil` will unregister it.
* @remarks For more context, refer to the {@link https://lua-api.factorio.com/latest/Data-Lifecycle.html Data Lifecycle} page.
* @example Initialize a `players` table in `global` for later use.
*
* ```
* script.on_init(function()
* global.players = {}
* end)
* ```
*/
on_init(f: (() => void) | undefined): void
If I remove the {@link ...}
from the @remarks
, then it works!
/**
* Register a function to be run on mod initialization...
*
* {@link https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.on_init View documentation}
* @param f The handler for this event. Passing `nil` will unregister it.
* @remarks For more context, refer to the xxxxxxxxxxxxxxxxxx page.
* @example Initialize a `players` table in `global` for later use.
*
* ```
* script.on_init(function()
* global.players = {}
* end)
* ```
*/
on_init(f: (() => void) | undefined): void
The @remarks
and the {@link ...}
was added last week:
If I revert Typed Factorio to v1.0.0, then again, thereās no error.
Minimal, reproducible example
click to expand
./control.ts
script.on_init(() => {
log(`mod is added to the save`)
})
./package.json
{
"name": "my-factorio-mod",
"version": "0.5.0",
"private": true,
"scripts": {
"build": "tstl",
"dev": "tstl --watch"
},
"engines": {
"node": "~14.19.1"
},
"devDependencies": {},
"dependencies": {
"lua-types": "^2.11.0",
"typescript-to-lua": "1.4.4",
"typed-factorio": "1.1.0",
"typescript": "4.6.2"
},
"license": "UNLICENSED",
"peerDependencies": {},
"optionalDependencies": {},
"bundledDependencies": []
}
./tsconfig.json
{
"$schema": "https://raw.githubusercontent.com/TypeScriptToLua/vscode-typescript-to-lua/master/tsconfig-schema.json",
"compilerOptions": {
"target": "esnext",
"lib": [
"esnext"
],
"module": "commonjs",
"moduleResolution": "node",
"types": [
"typescript-to-lua/language-extensions",
"lua-types/5.2",
"typed-factorio/runtime"
],
"plugins": [
{
"name": "typescript-tstl-plugin"
}
],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"explainFiles": true,
"forceConsistentCasingInFileNames": true,
"listEmittedFiles": true,
"listFiles": true,
"noImplicitAny": true,
"noImplicitThis": true,
"sourceMap": false,
"strict": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"traceResolution": true,
"noImplicitReturns": true,
"noImplicitOverride": true,
"noFallthroughCasesInSwitch": true
},
"tstl": {
"luaTarget": "5.2",
"tstlVerbose": true,
"noHeader": true,
"noImplicitSelf": true,
"luaLibImport": "require"
}
}
š Actual behavior
TSDoc with a {@link https:...}
inside of a @remark
block causes an error
* @remarks For more context, refer to the {@link https://lua-api.factorio.com/latest/Data-Lifecycle.html Data Lifecycle} page.
node_modules/typed-factorio/generated/classes.d.ts:238:3 - error TS2304: Cannot find name 'https'.
238 on_init(f: (() => void) | undefined): void
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Process finished with exit code 2
š Expected behavior
TSDoc with a {@link https:...}
inside of a @remark
block does not cause an error
Workaround
A workaround is to add "skipLibCheck": true
to tsconfig.json
> compilerOptions.
See also
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:13 (6 by maintainers)
Yeah, double checked with the team and itās definitely not supposed to happen, though I donāt find it too surprising.
The call to
getSymbolAtLocation
frombuildLinkParts
in src/services/utilities.ts is the first thing in the stack thatās possibly suspicious. That call should never be able to trigger an error thatgetSemanticDiagnostics
doesnāt also trigger. I think the checker should probably know based on the location that it shouldnāt trigger name resolution errors there. JSDoc@link
tags can probably just be explicitly exempt from errors inresolveEntityName
in checker.ts (@sandersn please correct me if thatās not right).Why this only happens when the
@link
tag comes after another tag (not just@remarks
, happens for any tag) is a total mystery to me.I looked briefly at the code and
@link
tags are checked the same regardless of whether theyāre inside a tag or just the top-level comment text.Edit: re-reading @andrewbranch 's comment, the problem might be the language service code in getSymbolOfNameOrPropertyAccessExpression, which might make
getSemanticDiagnostics
give no error, butgetSymbolAtLocation
give an error.