Skip to content

This is a tutorial how to setup a typescript project and orchestrate the packages

License

Notifications You must be signed in to change notification settings

OttoHung/typescript.tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Content

What is Mono Repo?

yarn workspaces

yarn scripts

Typescript configurations

Use modules from workspace

Export settings

How to write Typescript

Command line prompt arguments

How to work with Express

Test source code by Jest

Note: jest ts-jest and @types/jest ts-jest configinit

ESLint Integration

Swagger Integration

Application Deployment on Kubernetes

Troubleshooting

Module from workspace not found with import keyword

There are some situations may cause this issue:

  1. Module is not defined in compilerOptions.paths in tsconfig.json

    Solution:

    Assume the name of module is @utils and the path of workspace is at workspaces/utils

    {
      "compilerOptions": {
         ...,
         "paths": {
           "@utils/*": "workspaces/utils/src/*"
         }
      } 
    }
  2. Path of Module is not defined correspondently in compilerOptions.paths in tsconfig.json

    Solution:

    If the script would like to use complied module of @utils in the workspaces/utils/dist. The path should be:

    {
      "compilerOptions": {
         ...,
         "paths": {
           "@utils/*": "workspaces/utils/dist/*"
         }
      } 
    }

    This approach may not resolve this problem while the workspaces/utils/dist does not exist. In this case, use source directory would be the better solution as follows:

    {
      "compilerOptions": {
         ...,
         "paths": {
           "@utils/*": "workspaces/utils/src/*"
         }
      } 
    }
  3. The directory of script or the script has been excluded in tsconfig.json.

    Solution:

    Remove the directory from exclude attribute.

About

This is a tutorial how to setup a typescript project and orchestrate the packages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published