Repository navigation
{@link https...} inside a @remarks causes error TS2304: Cannot find name 'https' #49109
Description
Bug 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 2Here'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): voidIf 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): voidThe @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.

Activity
[-]`{@link https...}` inside a `@remark` causes error TS2304: Cannot find name 'https'[/-][+]`{@link https...}` inside a `@remarks` causes error TS2304: Cannot find name 'https'[/+]andrewbranch commentedon May 24, 2022
This is a tstl issue.
aSemy commentedon May 25, 2022
Thanks for investigating Andrew Branch (@andrewbranch), I appreciate it.
I thought the error was related to TypeScript because TSTL is producing correct LUA code, it's only the TypeScript compiler that complains. Can you provide more information on how you came to think that? What needs to change in TSTL to fix it?
andrewbranch commentedon May 25, 2022
I’m not 100% sure how it’s happening, but I was unable to reproduce the problem with TypeScript alone (whether with
tscor viewing errors in the editor). Also, I know we don’t issue name resolution errors on@linktags because doing so was a feature request we recently discussed that I argued we should decline. And the fact that the error appeared not on the JSDoc tag itself but on the usage of one of the things it decorated is very bizarre, which reads a lot like someone made a mistake leveraging the TS compiler. My investigation was pretty quick so there’s always a chance I’m wrong, but there was enough evidence that I feel comfortable saying you’d need to give a repro that doesn’t use external tools in order for me to believe the issue is not in the external tools.typescript-bot commentedon May 28, 2022
This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
Perryvw commentedon Jul 3, 2022
Andrew Branch (@andrewbranch) I have done some further investigation, this looks to me like we are using the TS API as intended, if not please correct me where we are going wrong:
This diagnostic seems to happen when calling getJsDocTags() on the signature of the CallExpression
script.on_init(() =>{ }).Effectively what we are doing is (where callExpression is the code above):
Full stacktrace of my little reproduction scenario is:

Digging a little further with my debugger it seems that

getDisplayPartsFromCommentis called with the following node:Node at index 0 seems fine, but the second node seems a bit suspicious. node.kind is 324, which is SyntaxKind.JSDocLink as expected, what is weird that node.name is an identifier 'https'. It then tries to resolve this symbol as if it was referring to a variable in code in using
checker.getSymbolAtLocation(link.name)inbuildLinkPartswhich ends up adding the diagnostic viaresolveEntityNameon this https identifier.I'm not sure what expected behavior is here, or what we could do to prevent this.
aSemy commentedon Jul 3, 2022
When I change
@remarkstoremarksthen it doesn't trigger the error tstl-playground exampleWhen I change
remarksback to@remarksit does tstl-playground example (make an incidental edit to trigger the error)Both examples have the same JSDocLink structure, with a
httpsas an IdentifierThe difference between the two is that the
@remarksversion has aFirstJSDocTagNode, while the other does not.The error is specifically triggered by an
{@link ...}being inside a@remarksblock - if the link is in a preceding block, it works tstl-playground exampleWhat does
tscdo inside of a@remarksblock that's different to a regular JSDoc block?Additionally, I think I found a workaround: changenever mind, it causes the same issue tstl playground{@link ... }to{@linkplain ... }when it's referring to a http link.8 remaining items
sandersn commentedon Jul 15, 2022
I looked briefly at the code and
@linktags are checked the same regardless of whether they're inside a tag or just the top-level comment text.Edit: re-reading Andrew Branch (@andrewbranch) 's comment, the problem might be the language service code in getSymbolOfNameOrPropertyAccessExpression, which might make
getSemanticDiagnosticsgive no error, butgetSymbolAtLocationgive an error.DanielRosenwasser commentedon Aug 17, 2022
Seems like this is not just an API concern, this comes up in the language service in #50341
shahrukhnasir commentedon Sep 2, 2022
SantoJambit commentedon Sep 28, 2022
Not sure if the same issue, but I get the same error message with just
@seeand@link(no@remarks):https://typescripttolua.github.io/play/#code/PQKhCgAIUhlB7AtgU0gYySgdgFyhaSAAQGdlUBvIgGwEssBrSACxxwAcSAuYYAc1o5mAVwBGAOgyJgiWmgBO8EvABmOYABUAnu2SwFtdutokSw5CWAAWAJwBGAAw2AvvmDhkAD3bx5OSCrCWGg4tPBYkACyWgBiQSFhWAAUAJSQFK5AA
for some reason, it only shows once you start typing in the editor.
Pentadome commentedon Feb 17, 2023
Did anyone find a workaround?
andrewbranch commentedon Feb 17, 2023
Mateusz Burzyński (@Andarist) recently fixed a few related bugs; I’m not sure if this got fixed as a side-effect.
sandersn commentedon May 5, 2023
If this is the same as #50341, which is very likely, then it's still broken as of 5.1 beta.
fix jsdoc errors in .ts in tsserver
Add test for microsoft#49109