I am importing this array:
const quotes = [
{ quote: "Design is intelligence made visible.", name: "Alina Wheeler" },
{
quote:
"The public is more familiar with bad design than good design. It is, in effect, conditioned to prefer bad design, because that is what it lives with. The new becomes threatening, the old reassuring.",
name: "Paul Rand",
},
{
quote: "Every great design begins with an even better story.",
name: "Lorinda Mamo",
}
];
into another .tsx file and using it this way:
import * as quotes from "./quotes/quotes";
const quoteLength = quotes.length - 1;
But I'm getting this error: Property 'length' does not exist on type 'typeof import
Any idea how I can fix this? How do I declare that array of objects as a type?
CodePudding user response:
- Have you exported the array from the quotes file?
- If you have then
call it using
import {quotes} from "./quotes/quotes";
CodePudding user response:
You have to export and import file this way, as you can see the below code
export const quotes = [
{
quote: 'Design is intelligence made visible.',
name: 'Alina Wheeler'
},
{
quote:
'The public is more familiar with bad design than good design. It is, in effect, conditioned to prefer bad design, because that is what it lives with. The new becomes threatening, the old reassuring.',
name: 'Paul Rand'
},
{
quote: 'Every great design begins with an even better story.',
name: 'Lorinda Mamo'
}
];
.tsx file
import {quotes} from "./quotes/quotes";
const quoteLength = quotes.length - 1;