Skip to content

typescript didn't enabled for a fresh CRA app  #12300

@j0053f

Description

@j0053f

I have a CRA app. I want to start using typescript.
according to this guide for adding typescript to an existing Create React App project I installed the typescript and required type definitions:

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

and add a file named test.tsx contains:

export default function Test(){
    return (
        <div>this is test to see typescirpt</div>
    )
}

and import and use it in main.js
ctrl+c previous development server.
and did npm start.
I'm getting bellow error.

    Failed to compile.  
    Module not found: Error: Can't resolve './test' in '/home/g/w/projects/movie_watch_list_frontend/src'   
    ERROR in ./src/App.js 15:0-26  
    Module not found: Error: Can't resolve './test' in '/home/g/w/projects/movie_watch_list_frontend/src'  
    webpack compiled with 1 error

also, there isn't any auto-created tsconfig file in the project folder.

I pushed the change that I made in a new branch named typescript to my reposity

also, I repeat this process for a fresh CRA app, and the same error happened.

am I doing something wrong?

Originally posted by @j0053f in #12295

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions