<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[טיפים לכתיבת שרת נוד ב TS]]></title><description><![CDATA[<p dir="rtl">סביבת פיתוח:<br />
להתקין</p>
<pre><code>npm i -D @types/node
npm i -D @types/express
</code></pre>
<p dir="rtl">נגדיר בקובץ package.json סקריפט בשם dev, שיריץ את הפקודה tsc --wach</p>
<pre><code>  "scripts": {
    "dev": "tsc --watch",
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
  },
</code></pre>
<p dir="rtl">בתיקית השורש של הפרוייקט, נוסיף את התיקיה  <code> .vscode</code> ובתוכה שני קבצים, launch.json</p>
<pre><code>{
    "configurations": [
        {
            "name": "Launch Program",
            "program": "${workspaceFolder}/app.ts",
            "request": "launch",
            "skipFiles": [
                "&lt;node_internals&gt;/**"
            ],
            "type": "node",
            "preLaunchTask": "npm: dev",
        }
    ]
}
</code></pre>
<p dir="auto">tasks.json</p>
<pre><code>{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "npm",
            "script": "dev",
            "problemMatcher": "$tsc-watch",
            "isBackground": true
        }
    ]
}
</code></pre>
<p dir="rtl">לא לשכוח להוסיף קובץ בתיקית השורש בשם tsconfig.json,</p>
<pre><code>{
    "compilerOptions": {
      "module": "commonjs",
      "esModuleInterop": true,
      "target": "es2021",
      "moduleResolution": "node",
      "sourceMap": true,
    },
    "lib": ["es2015"]
  }
</code></pre>
<p dir="rtl">כעת בהרצה יווצרו ליד כל קובץ ts שני קבצים, js &amp; js.map , זה מבלבל בעין, אז נוסיף לתיקיה .vscode קןבץ בשם settings.json עם התוכן הבא</p>
<pre><code>{
    "files.exclude": {
        "node_modules/": true,
        "*.js": true,
        "*.js.map": true,
    },
}
</code></pre>
<p dir="rtl">וכך הקבצים המיותרים יוסתרו</p>
]]></description><link>https://tchumim.com/topic/13410/טיפים-לכתיבת-שרת-נוד-ב-ts</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 03:27:35 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/13410.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 05 Jun 2022 23:31:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to טיפים לכתיבת שרת נוד ב TS on Mon, 06 Jun 2022 00:03:04 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A6%D7%93%D7%99%D7%A7-%D7%AA%D7%9E%D7%99%D7%9D" aria-label="Profile: צדיק-תמים">@<bdi>צדיק-תמים</bdi></a> אמר ב<a href="/post/140832">טיפים לכתיבת שרת נוד ב TS</a>:</p>
<blockquote>
<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%99%D7%95%D7%A1%D7%A3-%D7%91%D7%9F-%D7%A9%D7%9E%D7%A2%D7%95%D7%9F" aria-label="Profile: יוסף-בן-שמעון">@<bdi>יוסף-בן-שמעון</bdi></a> למה לא לכתוב בtsconfig</p>
<pre><code>        "outDir": "dist"
</code></pre>
<p dir="rtl">וכך הקבצים ייווצרו מלכתחילה בתקיה ייעודית? <img src="https://tchumim.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f914.png?v=cf1b4e11576" class="not-responsive emoji emoji-android emoji--thinking_face" style="height:23px;width:auto;vertical-align:middle" title="🤔" alt="🤔" /></p>
</blockquote>
<p dir="rtl">תלוי בסביבה ובדרישות, לא מתאים בכל מצב, ובכל מקרה, גם את התיקיה הייעודית כדאי להסתיר</p>
]]></description><link>https://tchumim.com/post/140834</link><guid isPermaLink="true">https://tchumim.com/post/140834</guid><dc:creator><![CDATA[יוסף בן שמעון]]></dc:creator><pubDate>Mon, 06 Jun 2022 00:03:04 GMT</pubDate></item><item><title><![CDATA[Reply to טיפים לכתיבת שרת נוד ב TS on Sun, 05 Jun 2022 23:58:52 GMT]]></title><description><![CDATA[<p dir="rtl">במידה ונרצה להוסיף מתודות ומאפיינים ייחודיים לאובייקטים של אקספרס, לדוגמא יוזר עם מספר נעליים, ניצור קובץ דומיין בשם <code> types.d.ts</code> עם התוכן הבא</p>
<pre><code>declare namespace Express {
    export interface Request {
        user?: {
            shoeSize: number
        }
    }
}
</code></pre>
<p dir="rtl">וכך עורך הקוד ומנוע הקימפול יכירו בו<br />
<img src="/assets/uploads/files/1654473508314-263ed6ce-f7d8-4be3-b852-8f8320b91f37-image.png" alt="263ed6ce-f7d8-4be3-b852-8f8320b91f37-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://tchumim.com/post/140833</link><guid isPermaLink="true">https://tchumim.com/post/140833</guid><dc:creator><![CDATA[יוסף בן שמעון]]></dc:creator><pubDate>Sun, 05 Jun 2022 23:58:52 GMT</pubDate></item><item><title><![CDATA[Reply to טיפים לכתיבת שרת נוד ב TS on Sun, 05 Jun 2022 23:46:57 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%99%D7%95%D7%A1%D7%A3-%D7%91%D7%9F-%D7%A9%D7%9E%D7%A2%D7%95%D7%9F" aria-label="Profile: יוסף-בן-שמעון">@<bdi>יוסף-בן-שמעון</bdi></a> למה לא לכתוב בtsconfig</p>
<pre><code>        "outDir": "dist"
</code></pre>
<p dir="rtl">וכך הקבצים ייווצרו מלכתחילה בתקיה ייעודית? <img src="https://tchumim.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f914.png?v=cf1b4e11576" class="not-responsive emoji emoji-android emoji--thinking_face" style="height:23px;width:auto;vertical-align:middle" title="🤔" alt="🤔" /></p>
]]></description><link>https://tchumim.com/post/140832</link><guid isPermaLink="true">https://tchumim.com/post/140832</guid><dc:creator><![CDATA[צדיק תמים]]></dc:creator><pubDate>Sun, 05 Jun 2022 23:46:57 GMT</pubDate></item></channel></rss>