Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions examples/errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// @ts-check

/**
* @typedef {Object} Person
* @property {string} name
* @property {number} age
* @property {Object} address
* @property {string} address.street
* @property {string} address.city
* @property {string} address.country
*/

/**
* @type {Person}
*/
const john = {
name: "John Doe",
age: 30,
address: {
street: "123 Main St",
city: "New York",
},
};

/**
* @typedef {Function} GetUserFunction
* @returns {{ user: { name: string, email: string, age: number } }}
*/

const getPerson = () => ({
person: {
username: "usr",
email: "[email protected]",
},
});


/**
* @typedef {Object} JSAnimal
* @property {string} name
* @property {number} age
*/

/**
* @template {JSAnimal} T
* @param {T} animal
* @returns
*/
function run(animal) {
return animal;
}

run({ firstName: "John", weight: 20 });

/**
* @typedef {Object} MyError
* @property {number} code
*/

try {
// ...
} catch (/** @type {MyError} */ error) {
console.log(error.code);
}

export {}
2 changes: 2 additions & 0 deletions examples/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ try {
} catch (error: MyError) {
console.log(error.code);
}

export {}
8 changes: 1 addition & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"ts-dedent": "^2.2.0",
"typedash": "^3.2.5",
"vscode-languageclient": "^9.0.1",
"vscode-languageserver-types": "^3.17.5",
"vscode-uri": "^3.0.8"
"vscode-languageserver-types": "^3.17.5"
}
}
4 changes: 2 additions & 2 deletions src/format/embedSymbolLinks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Diagnostic } from "vscode-languageserver-types";
import { URI } from "vscode-uri";

export function embedSymbolLinks(diagnostic: Diagnostic): Diagnostic {
if (
Expand All @@ -14,11 +13,12 @@ export function embedSymbolLinks(diagnostic: Diagnostic): Diagnostic {
if (!symbol) {
return diagnostic;
}

return {
...diagnostic,
message: diagnostic.message.replaceAll(
symbol,
`${symbol} <a href="${URI.parse(ref.location.uri).path}#${
`${symbol} <a href="${ref.location.uri}#${
ref.location.range.start.line + 1
},${
ref.location.range.start.character + 1
Expand Down