<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: F. L. Speeking</title>
    <description>The latest articles on DEV Community by F. L. Speeking (@franklee).</description>
    <link>https://dev.to/franklee</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1678407%2F0d54a9a2-ac74-4dd0-a5a1-9b78dabbe5f7.png</url>
      <title>DEV Community: F. L. Speeking</title>
      <link>https://dev.to/franklee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/franklee"/>
    <language>en</language>
    <item>
      <title>Typescript newbie can't get Vue app to see his Type.</title>
      <dc:creator>F. L. Speeking</dc:creator>
      <pubDate>Tue, 25 Jun 2024 15:47:44 +0000</pubDate>
      <link>https://dev.to/franklee/typescript-newbie-cant-get-vue-app-to-see-his-type-588g</link>
      <guid>https://dev.to/franklee/typescript-newbie-cant-get-vue-app-to-see-his-type-588g</guid>
      <description>&lt;p&gt;Hello, everyone. I am developing a Vue 3 app with Vuetify 3 and Pinia. I'm functional on all of those but far from massively experienced with them. I'm trying to add Typescript to the mix because I'm quite excited about the good things Typescript does with respect to type safety. &lt;/p&gt;

&lt;p&gt;My app, especially the main Pinia store, makes heavy use of a type which I'll call Foo since the real name isn't important anyway. Foo is a pretty simple object consisting of just two numbers and two strings, and no methods for the moment since I want to get a Type without methods working first; I'll add the methods after I have got the basic version of Foo working. (The Pinia store is already complete and working wonderfully in Javascript as are my components.) I am having a great deal of trouble figuring out how and where to export and then import this Foo type. (By the way, I know from the Typescript manual that interfaces are preferred over types so I'm quite willing to use an interface if that is better in this case. However, my initial sense of things is that a Type will be sufficient for my needs.)  &lt;/p&gt;

&lt;p&gt;I'll be using Type Foo in both my Pinia store and in various components of my Vue app to ensure that any Foo objects conform to expectations. I should also mention that I am developing in VS Code, use Vite to scaffold my projects, and intend to use ES modules rather than JSCommon modules. &lt;/p&gt;

&lt;p&gt;So, with all that in mind, I've gone ahead and tried to write the code for Type Foo. I put it in a new subdirectory right below &lt;code&gt;src&lt;/code&gt;, called &lt;code&gt;types&lt;/code&gt;, and put it in a file called &lt;code&gt;Foo.d.ts&lt;/code&gt;. (I'm very confused still about when you use a &lt;code&gt;.ts&lt;/code&gt; suffix and when you should use a &lt;code&gt;.d.ts&lt;/code&gt; suffix so please correct me if I'm wrong!) &lt;/p&gt;

&lt;p&gt;My definition of Foo looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export Type Foo = {
  field1: number;
  field2: string;
  field3: string;
  field4: number
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My Pinia store, which is the heaviest user of Foo, is at &lt;code&gt;src/store/Tracker.ts&lt;/code&gt;. The import statement I'm using to pick up Foo is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import { Foo } from './types/Foo';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For what it's worth, I've tried several variations of that import but all of them result in that same error that this one does: Typescript error 2307, &lt;code&gt;cannot find module or its corresponding type definitions&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;My tsconfig.json, as generated by Vite is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "ESNext",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "strict": true,
    "jsx": "preserve",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "lib": ["ESNext", "DOM"],
    "skipLibCheck": true,
    "noEmit": true,
    "paths": {
      "@/*": [
       "src/*"
      ]
     }
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
  "references": [{ "path": "./tsconfig.node.json" }],
  "exclude": ["node_modules"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What do I need to do differently?&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>vue</category>
    </item>
  </channel>
</rss>
