Skip to content

Example on the correct way to use typescript in NON SPA application #38003

@valeriob

Description

@valeriob

Hi,
we develop a lot of web application, we start with server side rendering (aspnet core) and on each page that need some enhancement we add some Typescript with various npm libraries (vuejs and so on).
Until now i've always being using typescript with namespaces, so each page like Index.cshtml, has his companion Index.ts, and references as script the compiled index.js.

I would like to use modules instead of namespaces, what would it be the correct way to configure typescript compiler and keep my lightweight workflow ?
I've instructed tsconfig.json to use ES6 module system, and i had to specify "moduleResolution" :"node".
So now when it loads the module, the browser fails with this error :

Uncaught TypeError: Failed to resolve module specifier "rxjs". Relative references must start with either "/", "./", or "../".

Here is the example, it should print in the console the numbers from 1 to 100 :
WebApplication17.zip

Thanks
Valerio

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions