'Cannot find name' errors for no reason
See original GitHub issueVolar works perfectly for all files, except for one. For some reason it thinks that I’m using “JSX” in templates. Here is code:
<template>
<div id="roundchat" class="roundchat chat">
<div class="chatroom">
Chat room
<input
id="checkbox"
title="Toggle the chat"
name="checkbox"
type="checkbox"
@click="toggle"
/>
</div>
<ol id="lobbychat-messages">
<div id="messages" v-if="hiddenChat">
<li v-for="i in messages" :key="i" class="message">
<div class="time">{{ i.time }}</div>
<span class="user">
<a href="/">{{ i.user }}</a>
</span>
<span> {{ i.message }} </span>
</li>
</div>
</ol>
<input
v-model="message"
v-on:keyup.enter="onEnter"
id="chat-entry"
maxlength="140"
type="text"
name="entry"
autocomplete="off"
:placeholder="setPlaceholder()"
/>
</div>
</template>
<script setup lang="ts">
import { ref, Ref } from "vue";
const props = defineProps({ messages: [], wsType: String });
const messages: Ref<ChatMessage[]> = ref(props.messages!);
const message = ref("");
const hiddenChat = ref(true);
function onEnter(): void {
if (message.value.length > 0 && message.value.length < 80) {
//ws.send...
message.value = "";
}
}
function setPlaceholder(): string {
let reg = false;
if (reg == false) {
return "Sign in to chat";
} else {
return "Please be nice in the chat!";
}
}
function toggle(): void {
hiddenChat.value = !hiddenChat.value;
}
interface ChatMessage {
time: String;
user: String;
message: String;
}
</script>
<style scoped>
.user {
padding-right: 6px;
font-weight: bold;
}
</style>
Project made with: Vue + Vite + Ts And when I want to use this component in my view, TypeScript complains with:
JSX element class does not support attributes because it does not have a '$props' property
Component inside view.
<template>
<ChatRoom :messages="[]" wsType="home_chat_message" />
</template>
<script setup lang="ts">
import ChatRoom from '@/components/ChatRoom.vue';
</script>
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Angular and Typescript: Can't find names - Error: cannot find ...
This fixed a lot of errors for me, but I still get errors like TS2304: Cannot find name 'module' and TS2339: Property 'find'...
Read more >Fix the Cannot Find Name 'require' Error in TypeScript
To fix the “cannot find name 'require'” error in TypeScript, install the @types/node package into your project by running npm i -D ...
Read more >TypeScript error TS2304 cannot find name require - Edureka
The error that I'm getting is the "TS2304: Cannot find name 'require' " when I attempt to transpile a simple TypeScript Node.js page....
Read more >TS2304: Cannot find name 'Request' · Issue #661 - GitHub
When compiling a Typescript file that uses MeiliSearch for Node.js, the error TS2304: Cannot find name 'Request' causes the build to fail.
Read more >Typescript getting error TS2304 cannot find name ' require'
If you are using TypeScript 2.x you no longer need to have Typings or Definitely Typed installed. Simply install the following package.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You should use
const props = defineProps({ messages: Array as PropType<Array<ChatMessage>>, wsType: String });
But I prefer use
This fixed the issue, thanks!