Jsdoc for ExpressJs app without using typescript - express

I try to comment my ExpressJS function using JSCode but it does not work as expected.
/** #typedef { import('express').Request} Request */
/** #typedef { import('express').Response} Response */
/**
* Description
* #param {Request} request - test
* #param {Response} response - test
*/
function myRouteFunction(request, response) {
//request.
}
I have installed the package #types/node and #types/express.
When I type request. I'd like to have a suggestion of all ExpressJS function in the request object.

Request and Response clash with fetch types from lib.dom. You can rename types:
/** #typedef {import('express').Request} ExpressRequest */
/** #typedef {import('express').Response} ExpressResponse */
/**
* #param {ExpressRequest} request - test
* #param {ExpressResponse} response - test
*/
function myRouteFunction(request, response) {
//request.
}
or create tsconfig file for your project
{
"compilerOptions": {
"lib": [ "ES2022" ],
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"noImplicitAny": false,
"moduleResolution": "node",
"typeRoots": [ "./node_modules/#types" ]
},
"include": [ "*.js" ]
}

Related

app crashes on launch with absolute imports

In case it matters, this is my first time doing react-native on a Mac. The application works well when I am using relative imports but it crushes if I try absolute imports. My set up is:
bable.config.js
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'babel-plugin-transform-typescript-metadata',
['#babel/plugin-proposal-decorators', {legacy: true}]
],
};
tsconfig.js
// prettier-ignore
{
"extends": "#tsconfig/react-native/tsconfig.json", /* Recommended React Native TSConfig base */
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
"baseUrl": ".",
"paths": {
"myapp/*": ["src/*"]
},
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"experimentalDecorators": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"skipDefaultLibCheck": true,
}
}
After restarting my IDE, it does find the imports with no issue but compilation fails:
import { Btn } from 'myapp/components/Btn';
below works well:
import { Btn } from '../../components/Btn';

I unable to connect TYPO3 backend to front app

I have plain TYPO3 version 11.5.x setup with headless version 3.1.2. Backend working perfect and frontend URL returning proper JSON data.
API URL looks like: https://t3-pwa.ddev.site:4403/typo3/
I created front directory in the project root. Project directory looks like this.
Directory
fileadmin
front - created front app with nuxt-typo3 contain node package
node_modules
server
jsconfig.json
nuxt.config.js
package.json
tsconfig.json
typo3
typo3conf
vendor
typo3temp
.ddev
index.php
.htaccess
Command
Created app with yarn create nuxt-typo3
Configured with default settings
Run yarn dev
It starts application properly but when I visit frontend on default url: http://localhost:3000 It does not starting.
Console Start app : https://i.stack.imgur.com/LDr6U.png
Front: https://i.stack.imgur.com/ms6l2.png
Console: https://i.stack.imgur.com/9ZoBm.png
nuxt.config.js: Looks like this
export default {
/*
** Headers of the page
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#ff8700' },
/*
** Global CSS
*/
css: [
],
/*
** Plugins to load before mounting the App
*/
plugins: [
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
// Doc: https://github.com/macopedia/nuxt-typo3-theme
'nuxt-typo3-tailwind',
// Doc: https://github.com/TYPO3-Initiatives/nuxt-typo3
'nuxt-typo3',
],
/*
** Nuxt.js modules
*/
modules: [
'#nuxtjs/pwa',
],
/*
** TYPO3 module configuration
** https://github.com/TYPO3-Initiatives/nuxt-typo3
*/
typo3: {
baseURL: process.env.NUXT_HOST,
forms: true,
api: {
baseURL: 'https://t3-pwa.ddev.site'
},
},
typo3tailwind: {
layouts: false
},
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
extend (config, ctx) {
}
}
}
Also, default frontend URL returns the same JSON URL. Can anyone share some hint? Also, minimal solution from scratch?
It looks like your baseURL in frontend application is not valid. You should keep only https://t3-pwa.ddev.site:4403 in baseURL in nuxt.config.js file.
Please remember that nuxt-typo3 frontend application tries to fetch ?type=834 URL at start, and if you add /typo3 at start, it's not valid anymore.
You should adjust your baseURL, rebuild and you are ready to go. You can also take a look at our pwa-demo, which uses nuxt-typo3 and TYPO3 Headless with ddev https://github.com/TYPO3-Headless/pwa-demo.

How to prevent #param types from becoming broken links

When generating docs, the type "string" (among others) will become a link to "string.html" which does not exist. How do we prevent that from happening? I want plain text to show for these types.
/**
* the comment
*
* #param {string} myString
*/
config:
"opts": {
"encoding": "utf8",
"recurse": true,
"destination": "out/clean/",
"template": "./node_modules/clean-jsdoc-theme/"
},
"tags": {
"allowUnknownTags": false,
"dictionaries": ["jsdoc","closure"]
},
"source": {
"includePattern": ".+\\.js?$",
"include": ["path/to/file"]
},
"plugins": ["plugins/markdown"],
"markdown": {
"hardwrap": false,
"idInHeadings": true
}
My issue was that I had a "#memberof string", which then jsdoc made a "string.html" file out of.

Why my file index.d.ts not being included when doing "yarn publish" command?

I want to publish my first npm package using yarn but I got an issue where, the type definition file index.d.ts not included inside types folder when doing yarn publish command, any idea?
Structure folder
android
---
example
---
types
index.d.ts
tsconfig.json
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "ESNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": [
"types"
],
"exclude": ["node_modules"]
}
package.json
{
"name": "react-native-popup-progress-bar",
"title": "React Native Popup Progress Bar",
"version": "1.0.4",
"description": "Android ProgressDialog for React Native",
"main": "index.js",
"files": [
"README.md",
"android",
"index.js"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/VEmpink/react-native-popup-progress-bar.git",
"baseUrl": "https://github.com/VEmpink/react-native-popup-progress-bar"
},
"keywords": [
"react-native",
"android",
"popup",
"modal",
"dialog",
"progress bar",
"ProgressBar",
"ProgressDialog",
"spinner",
"loading"
],
"author": {
"name": "VEmpink",
"email": "fiermandt#gmail.com"
},
"license": "MIT",
"licenseFilename": "LICENSE",
"readmeFilename": "README.md",
"peerDependencies": {
"react": "^16.8.1",
"react-native": ">=0.60.0-rc.0 <1.0.x"
},
"devDependencies": {
"react": "^16.9.0",
"react-native": "^0.61.5",
"typescript": "^4.1.3"
}
}

Why is webpack outputting the const keyword instead of var?

Webpack appears to be outputting the const keyword instead of the var keyword which is breaking PhantomJS (as it doesn't support ES6 syntax).
...
/* 2 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
const testing_1 = __webpack_require__(3); // const keyword breaking PhantomJS
testing_1.describe('App', () => {
So PhantomJS reports
PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR
SyntaxError: Unexpected token 'const'
The file in question (karma-shim.js) is being processed by the karma-webpack preprocessor
karma-shim.js
'use strict';
Error.stackTraceLimit = Infinity;
require('es6-shim');
require('angular2/bundles/angular2-polyfills.js');
require('angular2/testing');
var appContext = require.context('./src', true, /root\.spec\.ts/);
appContext.keys().forEach(appContext);
var testing = require('angular2/testing');
var browser = require('angular2/platform/testing/browser');
testing.setBaseTestProviders(browser.TEST_BROWSER_PLATFORM_PROVIDERS, browser.TEST_BROWSER_APPLICATION_PROVIDERS);
karma.conf.js
...
preprocessors: {
'./karma-shim.js': ['webpack', 'sourcemap']
},
tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"moduleResolution": "node",
"jsx": "react"
},
"exclude": [
"node_modules"
],
"compileOnSave": false,
"buildOnSave": false
}
webpack.config.js Is part of generator-ng2-webpack (https://github.com/cmelion/generator-ng2-webpack) but doesn't appear to mention transpilation.
Why would webpack be outputting const instead of var and is there anything I can do about it to help PhantomJS?